ReplyComment.php 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. <?php
  2. namespace app\operate\controller;
  3. use library\Controller;
  4. /**
  5. * 问答评论
  6. * Class ReplyComment
  7. * @package app\operate\controller
  8. */
  9. class ReplyComment extends Controller
  10. {
  11. /**
  12. * 绑定数据表
  13. * @var string
  14. */
  15. protected $table = 'ForumReplyComment';
  16. /**
  17. * 列表
  18. * @auth true
  19. * @menu true
  20. * @throws \think\Exception
  21. * @throws \think\db\exception\DataNotFoundException
  22. * @throws \think\db\exception\ModelNotFoundException
  23. * @throws \think\exception\DbException
  24. * @throws \think\exception\PDOException
  25. */
  26. public function index()
  27. {
  28. $this->title = '列表';
  29. $this->forum_id = input('forum_id');
  30. $this->reply_id = input('reply_id');
  31. $sel_where = [];
  32. $sel_where[] = ['c.is_deleted','=',0];
  33. $sel_where[] = ['c.forum_id','=',$this->forum_id];
  34. $sel_where[] = ['c.reply_id','=',$this->reply_id];
  35. if($content = $this->request->get('content'))$sel_where[] = ['c.content','like','%'.$content.'%'];
  36. if($name = $this->request->get('name'))$sel_where[] = ['u.name','like','%'.$name.'%'];
  37. $query = $this->_query($this->table)->alias('c')
  38. ->field('c.*,u.name,u.headimg')
  39. ->leftJoin("store_member u",'u.id = c.user_id')
  40. ->where($sel_where)->order('id desc')->page();
  41. }
  42. /**
  43. * 数据列表处理
  44. * @auth true
  45. * @menu true
  46. * @param array $data
  47. * @throws \think\db\exception\DataNotFoundException
  48. * @throws \think\db\exception\ModelNotFoundException
  49. * @throws \think\exception\DbException
  50. */
  51. protected function _index_page_filter(&$data)
  52. {
  53. }
  54. // 回复
  55. public function reply()
  56. {
  57. $this->title = '回复';
  58. $this->_form($this->table, 'form');
  59. }
  60. /**
  61. * 删除
  62. * @auth true
  63. * @menu true
  64. * @throws \think\Exception
  65. * @throws \think\db\exception\DataNotFoundException
  66. * @throws \think\db\exception\ModelNotFoundException
  67. * @throws \think\exception\DbException
  68. * @throws \think\exception\PDOException
  69. */
  70. public function del()
  71. {
  72. $this->_save($this->table, ['is_deleted' => 1]);
  73. }
  74. /**
  75. * 表单数据处理
  76. * @auth true
  77. * @menu true
  78. * @param array $data
  79. */
  80. protected function _form_filter(&$data)
  81. {
  82. if($this->request->isGet()) {
  83. $this->source_id = $data['source_id'] ? $data['source_id'] : $data['id'];
  84. }
  85. }
  86. /**
  87. * 置顶设置
  88. * @auth true
  89. * @menu true
  90. * @param array $data
  91. */
  92. public function stick()
  93. {
  94. $this->_save($this->table, ['is_top' => input('is_top')]);
  95. }
  96. }