You've already forked qlg.tsgz.moe
							
							烂笔头
This commit is contained in:
		| @@ -10,7 +10,7 @@ class Note extends Base | |||||||
| { | { | ||||||
|     public function index(){ |     public function index(){ | ||||||
|         $userId = (int)session('WST_USER.userId'); |         $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") |             ->where(["user_id"=>$userId])->order("update_time", "desc") | ||||||
|             ->select(); |             ->select(); | ||||||
|         return WSTReturn("OK", 1, $model); |         return WSTReturn("OK", 1, $model); | ||||||
| @@ -19,9 +19,10 @@ class Note extends Base | |||||||
|     public function detail(){ |     public function detail(){ | ||||||
|         $userId = (int)session('WST_USER.userId'); |         $userId = (int)session('WST_USER.userId'); | ||||||
|         if(($id = (int)input( 'id', 0)) > 0){ |         if(($id = (int)input( 'id', 0)) > 0){ | ||||||
|             $detail = model("note")->field(true) |             $detail = Db::name('note') | ||||||
|                 ->where(["user_id"=>$userId, "id"=>$id])->find(); |                 ->where(["user_id"=>$userId, "id"=>$id])->find(); | ||||||
|             if(!$detail) return WSTReturn("该条内容已被删除",0); |             if(!$detail) return WSTReturn("该条内容已被删除",0); | ||||||
|  |             $detail['content'] = htmlspecialchars_decode($detail['content']); | ||||||
|             return WSTReturn("OK", 1, $detail); |             return WSTReturn("OK", 1, $detail); | ||||||
|         } |         } | ||||||
|         return WSTReturn("异常请求",0); |         return WSTReturn("异常请求",0); | ||||||
| @@ -31,25 +32,27 @@ class Note extends Base | |||||||
|         $userId = (int)session('WST_USER.userId'); |         $userId = (int)session('WST_USER.userId'); | ||||||
|         $id = (int)input( 'post.id', 0); |         $id = (int)input( 'post.id', 0); | ||||||
|         $title = input("post.title"); |         $title = input("post.title"); | ||||||
|         $content = input("post.content"); |         $content = request()->post("content"); | ||||||
|  |         $content = htmlspecialchars_decode($content); | ||||||
|         if(empty($title)) return WSTReturn("请填写标题",0); |         if(empty($title)) return WSTReturn("请填写标题",0); | ||||||
|         if(empty($content)) return WSTReturn("请填写内容",0); |         if(empty($content)) return WSTReturn("请填写内容",0); | ||||||
|         if($id > 0){ |         if($id > 0){ | ||||||
|             $detail = model("note")->field(true) |             $detail = Db::name('note')->field(true) | ||||||
|                 ->where(["user_id"=>$userId, "id"=>$id])->select(); |                 ->where(["user_id"=>$userId, "id"=>$id])->select(); | ||||||
|             if(!$detail) return WSTReturn("该条内容已被删除",0); |             if(!$detail) return WSTReturn("该条内容已被删除",0); | ||||||
|             model("note")->where(["user_id"=>$userId, "id"=>$id]) |             Db::name('note')->where(["user_id"=>$userId, "id"=>$id]) | ||||||
|                 ->save([ |                 ->update([ | ||||||
|                     "title"=>$title, |                     "title"=>$title, | ||||||
|                     "content"=>$content, |                     "content"=>$content, | ||||||
|                     "update_time"=>date("Y-m-d H:i:s"), |                     "update_time"=>date("Y-m-d H:i:s"), | ||||||
|                 ]); |                 ]); | ||||||
|             return WSTReturn("成功", 1); |             return WSTReturn("成功", 1); | ||||||
|         }elseif($id == 0){ |         }elseif($id == 0){ | ||||||
|             model("note")->save([ |             Db::name('note')->insert([ | ||||||
|                 "title"=>$title, |                 "title"=>$title, | ||||||
|                 "content"=>$content, |                 "content"=>$content, | ||||||
|                 "user_id"=>$userId, |                 "user_id"=>$userId, | ||||||
|  |                 "create_time"=>date("Y-m-d H:i:s"), | ||||||
|                 "update_time"=>date("Y-m-d H:i:s"), |                 "update_time"=>date("Y-m-d H:i:s"), | ||||||
|             ]); |             ]); | ||||||
|             return WSTReturn("成功", 1); |             return WSTReturn("成功", 1); | ||||||
| @@ -59,7 +62,7 @@ class Note extends Base | |||||||
|  |  | ||||||
|     public function creditIndex(){ |     public function creditIndex(){ | ||||||
|         $userId = (int)session('WST_USER.userId'); |         $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") |             ->where(["user_id"=>$userId])->order("update_time", "desc") | ||||||
|             ->select(); |             ->select(); | ||||||
|         return WSTReturn("OK", 1, $model); |         return WSTReturn("OK", 1, $model); | ||||||
| @@ -76,7 +79,7 @@ class Note extends Base | |||||||
|         $cash = (float)input("post.cash"); |         $cash = (float)input("post.cash"); | ||||||
|         Db::startTrans(); |         Db::startTrans(); | ||||||
|         try{ |         try{ | ||||||
|             $id = model("note_credit")->save([ |             $id = Db::name('note_credit')->save([ | ||||||
|                 "title"=>$title, |                 "title"=>$title, | ||||||
|                 "content"=>$content, |                 "content"=>$content, | ||||||
|                 "user_id"=>$userId, |                 "user_id"=>$userId, | ||||||
| @@ -103,7 +106,7 @@ class Note extends Base | |||||||
|         $type = (int)input("post.type", 1); |         $type = (int)input("post.type", 1); | ||||||
|         $content = input("post.content"); |         $content = input("post.content"); | ||||||
|         $cash = (float)input("post.cash"); |         $cash = (float)input("post.cash"); | ||||||
|         $credit = model("note_credit")->where([ |         $credit = Db::name('note_credit')->where([ | ||||||
|             "user_id"=>$userId, |             "user_id"=>$userId, | ||||||
|             "id"=>$id, |             "id"=>$id, | ||||||
|         ])->field(true)->find(); |         ])->field(true)->find(); | ||||||
| @@ -126,7 +129,7 @@ class Note extends Base | |||||||
|         } |         } | ||||||
|         Db::startTrans(); |         Db::startTrans(); | ||||||
|         try{ |         try{ | ||||||
|             model("note_credit")->where([ |             Db::name('note_credit')->where([ | ||||||
|                 "user_id"=>$userId, |                 "user_id"=>$userId, | ||||||
|                 "id"=>$id, |                 "id"=>$id, | ||||||
|             ])->save($credit); |             ])->save($credit); | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user