0
0

PostReply.php 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. <?php
  2. namespace app\api\controller\v1;
  3. use app\api\controller\Base;
  4. use app\hander\HelpHander;
  5. use think\Db;
  6. class PostReply extends Base
  7. {
  8. public function addReply(){
  9. $data=[
  10. 'post_id'=>input('postId'),
  11. 'content'=>trim(input('content')),
  12. 'user_id'=>$this->userId,
  13. 'enable'=>1,
  14. 'create_time'=>getTime(),
  15. 'update_time'=>getTime(),
  16. 'post_reply_id'=>input('replyId/d',0)
  17. ];
  18. if(!$data['content']){
  19. HelpHander::error('回复消息不能为空');
  20. }
  21. $ret=Db::name('post_reply')->insert($data);
  22. if($ret){
  23. HelpHander::success([],'回复成功');
  24. }else{
  25. HelpHander::error('回复失败');
  26. }
  27. }
  28. public function delReplay(){
  29. $id=input('id');
  30. $data=['del'=>1];
  31. $ret=Db::name('post_reply')
  32. ->where('id',$id)
  33. ->where('user_id',$this->userId)
  34. ->update($data);
  35. if($ret){
  36. HelpHander::success([],'删除成功');
  37. }else{
  38. HelpHander::error('删除失败');
  39. }
  40. }
  41. }