DemandComment.php 3.0 KB

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