ArticleComment.php 2.9 KB

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