DatumComment.php 2.7 KB

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