diff --git a/hyhproject/app/controller/Note.php b/hyhproject/app/controller/Note.php index f7aa534..5a9d318 100644 --- a/hyhproject/app/controller/Note.php +++ b/hyhproject/app/controller/Note.php @@ -10,7 +10,7 @@ class Note extends Base { public function index(){ $userId = (int)session('WST_USER.userId'); - $model = model("note")->field(true) + $model = Db::name('note')->field(true) ->where(["user_id"=>$userId])->order("update_time", "desc") ->select(); return WSTReturn("OK", 1, $model); @@ -19,9 +19,10 @@ class Note extends Base public function detail(){ $userId = (int)session('WST_USER.userId'); if(($id = (int)input( 'id', 0)) > 0){ - $detail = model("note")->field(true) + $detail = Db::name('note') ->where(["user_id"=>$userId, "id"=>$id])->find(); if(!$detail) return WSTReturn("该条内容已被删除",0); + $detail['content'] = htmlspecialchars_decode($detail['content']); return WSTReturn("OK", 1, $detail); } return WSTReturn("异常请求",0); @@ -31,25 +32,27 @@ class Note extends Base $userId = (int)session('WST_USER.userId'); $id = (int)input( 'post.id', 0); $title = input("post.title"); - $content = input("post.content"); + $content = request()->post("content"); + $content = htmlspecialchars_decode($content); if(empty($title)) return WSTReturn("请填写标题",0); if(empty($content)) return WSTReturn("请填写内容",0); if($id > 0){ - $detail = model("note")->field(true) + $detail = Db::name('note')->field(true) ->where(["user_id"=>$userId, "id"=>$id])->select(); if(!$detail) return WSTReturn("该条内容已被删除",0); - model("note")->where(["user_id"=>$userId, "id"=>$id]) - ->save([ + Db::name('note')->where(["user_id"=>$userId, "id"=>$id]) + ->update([ "title"=>$title, "content"=>$content, "update_time"=>date("Y-m-d H:i:s"), ]); return WSTReturn("成功", 1); }elseif($id == 0){ - model("note")->save([ + Db::name('note')->insert([ "title"=>$title, "content"=>$content, "user_id"=>$userId, + "create_time"=>date("Y-m-d H:i:s"), "update_time"=>date("Y-m-d H:i:s"), ]); return WSTReturn("成功", 1); @@ -59,7 +62,7 @@ class Note extends Base public function creditIndex(){ $userId = (int)session('WST_USER.userId'); - $model = model("note_credit")->field(true) + $model = Db::name('note_credit')->field(true) ->where(["user_id"=>$userId])->order("update_time", "desc") ->select(); return WSTReturn("OK", 1, $model); @@ -76,7 +79,7 @@ class Note extends Base $cash = (float)input("post.cash"); Db::startTrans(); try{ - $id = model("note_credit")->save([ + $id = Db::name('note_credit')->save([ "title"=>$title, "content"=>$content, "user_id"=>$userId, @@ -103,7 +106,7 @@ class Note extends Base $type = (int)input("post.type", 1); $content = input("post.content"); $cash = (float)input("post.cash"); - $credit = model("note_credit")->where([ + $credit = Db::name('note_credit')->where([ "user_id"=>$userId, "id"=>$id, ])->field(true)->find(); @@ -126,7 +129,7 @@ class Note extends Base } Db::startTrans(); try{ - model("note_credit")->where([ + Db::name('note_credit')->where([ "user_id"=>$userId, "id"=>$id, ])->save($credit);