ForumComment.php 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. <?php
  2. namespace app\operate\controller;
  3. use library\Controller;
  4. /**
  5. * 评论
  6. * Class ForumComment
  7. * @package app\operate\controller
  8. */
  9. class ForumComment 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. $sel_where = [];
  31. $sel_where[] = ['c.is_deleted','in','0,1'];
  32. $sel_where[] = ['c.forum_id','=',$this->forum_id];
  33. if($content = $this->request->get('content'))$sel_where[] = ['c.content','like','%'.$content.'%'];
  34. if($name = $this->request->get('name'))$sel_where[] = ['u.name','like','%'.$name.'%'];
  35. if($id= $this->request->get('id'))$sel_where[] = ['c.id','=',$this->request->get('id')];
  36. $query = $this->_query($this->table)->alias('c')
  37. ->field('c.*,u.name,u.headimg')
  38. ->leftJoin("store_member u",'u.id = c.user_id')
  39. ->where($sel_where)->order('is_top desc,id desc')->page();
  40. }
  41. /**
  42. * 数据列表处理
  43. * @auth true
  44. * @menu true
  45. * @param array $data
  46. * @throws \think\db\exception\DataNotFoundException
  47. * @throws \think\db\exception\ModelNotFoundException
  48. * @throws \think\exception\DbException
  49. */
  50. protected function _index_page_filter(&$data)
  51. {
  52. }
  53. // 回复
  54. public function reply()
  55. {
  56. $this->title = '回复';
  57. $this->_form($this->table, 'form');
  58. }
  59. /**
  60. * 删除
  61. * @auth true
  62. * @menu true
  63. * @throws \think\Exception
  64. * @throws \think\db\exception\DataNotFoundException
  65. * @throws \think\db\exception\ModelNotFoundException
  66. * @throws \think\exception\DbException
  67. * @throws \think\exception\PDOException
  68. */
  69. public function del()
  70. {
  71. $this->_save($this->table, ['is_deleted' => 2]);
  72. }
  73. /**
  74. * 删除
  75. * @auth true
  76. * @menu true
  77. * @throws \think\Exception
  78. * @throws \think\db\exception\DataNotFoundException
  79. * @throws \think\db\exception\ModelNotFoundException
  80. * @throws \think\exception\DbException
  81. * @throws \think\exception\PDOException
  82. */
  83. public function remove()
  84. {
  85. $this->_save($this->table, ['is_deleted' => 1]);
  86. }
  87. /**
  88. * 表单数据处理
  89. * @auth true
  90. * @menu true
  91. * @param array $data
  92. */
  93. protected function _form_filter(&$data)
  94. {
  95. if($this->request->isGet()) {
  96. $this->source_id = $data['source_id'] ? $data['source_id'] : $data['id'];
  97. }
  98. }
  99. /**
  100. * 置顶设置
  101. * @auth true
  102. * @menu true
  103. * @param array $data
  104. */
  105. public function stick()
  106. {
  107. $this->_save($this->table, ['is_top' => input('is_top')]);
  108. }
  109. }