NewsReply.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 NewsReply extends Base
  7. {
  8. public function addReply(){
  9. $data=[
  10. 'news_id'=>input('newsId'),
  11. 'content'=>trim(input('content')),
  12. 'user_id'=>$this->userId,
  13. 'enable'=>1,
  14. 'create_time'=>date('y-m-d h:i:s'),
  15. 'news_reply_id'=>input('replyId')
  16. ];
  17. if(!$data['content']){
  18. HelpHander::error('回复消息不能为空');
  19. }
  20. $ret=Db::name('news_reply')
  21. ->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('news_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. }