Issue.php 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | ThinkAdmin
  4. // +----------------------------------------------------------------------
  5. // | 版权所有 2014~2019 广州楚才信息科技有限公司 [ http://www.cuci.cc ]
  6. // +----------------------------------------------------------------------
  7. // | 官方网站: http://demo.thinkadmin.top
  8. // +----------------------------------------------------------------------
  9. // | 开源协议 ( https://mit-license.org )
  10. // +----------------------------------------------------------------------
  11. // | gitee 代码仓库:https://gitee.com/zoujingli/ThinkAdmin
  12. // | github 代码仓库:https://github.com/zoujingli/ThinkAdmin
  13. // +----------------------------------------------------------------------
  14. namespace app\store\controller;
  15. use library\Controller;
  16. use library\tools\Data;
  17. use think\Db;
  18. /**
  19. * 常见问题
  20. * Class GoodsCate
  21. * @package app\store\controller
  22. */
  23. class Issue extends Controller
  24. {
  25. /**
  26. * 绑定数据表
  27. * @var string
  28. */
  29. protected $table = 'store_goods_issue';
  30. /**
  31. * 装修需求管理
  32. * @auth true
  33. * @menu true
  34. * @throws \think\Exception
  35. * @throws \think\db\exception\DataNotFoundException
  36. * @throws \think\db\exception\ModelNotFoundException
  37. * @throws \think\exception\DbException
  38. * @throws \think\exception\PDOException
  39. */
  40. public function index()
  41. {
  42. $this->title = '常见问题管理';
  43. $goods_id = input('goods_id');
  44. if(empty($goods_id)){
  45. $this->error('非法操作');
  46. }
  47. $this->app->session->set('goods_id', $goods_id);
  48. $query = $this->_query($this->table)->like('title');
  49. $query->where(['goods_id'=>$goods_id])->order('sort desc,id desc')->page();
  50. }
  51. /**需求列表处理
  52. * @param array $data
  53. * @throws \think\db\exception\DataNotFoundException
  54. * @throws \think\db\exception\ModelNotFoundException
  55. * @throws \think\exception\DbException
  56. */
  57. protected function _index_page_filter(array &$data)
  58. {
  59. foreach ($data as &$vo) {
  60. }
  61. }
  62. /**
  63. * 表单数据处理
  64. * @param array $data
  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. protected function _form_filter(&$data)
  72. {
  73. // 生成活动ID
  74. if ($this->request->isGet()) {
  75. } elseif ($this->request->isPost()) {
  76. if (empty($data['answer'])) $this->error('请填写解答内容');
  77. $data['goods_id'] = $this->app->session->get('goods_id');
  78. }
  79. }
  80. /**
  81. * 添加常见问题
  82. * @auth true
  83. * @throws \think\Exception
  84. * @throws \think\db\exception\DataNotFoundException
  85. * @throws \think\db\exception\ModelNotFoundException
  86. * @throws \think\exception\DbException
  87. * @throws \think\exception\PDOException
  88. */
  89. public function add()
  90. {
  91. $this->title = '添加常见问题';
  92. $this->isAddMode = '1';
  93. $this->_form($this->table, 'form');
  94. }
  95. /**
  96. * 编辑常见问题
  97. * @auth true
  98. * @throws \think\Exception
  99. * @throws \think\db\exception\DataNotFoundException
  100. * @throws \think\db\exception\ModelNotFoundException
  101. * @throws \think\exception\DbException
  102. * @throws \think\exception\PDOException
  103. */
  104. public function edit()
  105. {
  106. $this->title = '编辑常见问题';
  107. $this->isAddMode = '0';
  108. $this->_form($this->table, 'form');
  109. }
  110. /**
  111. * 表单结果处理
  112. * @param boolean $result
  113. */
  114. protected function _form_result($result)
  115. {
  116. if ($result && $this->request->isPost()) {
  117. $this->success('编辑成功!', 'javascript:history.back()');
  118. }
  119. }
  120. /**
  121. * 禁用常见问题
  122. * @auth true
  123. * @throws \think\Exception
  124. * @throws \think\exception\PDOException
  125. */
  126. public function forbid()
  127. {
  128. $this->_save($this->table, ['status' => '0']);
  129. }
  130. /**
  131. * 启用常见问题
  132. * @auth true
  133. * @throws \think\Exception
  134. * @throws \think\exception\PDOException
  135. */
  136. public function resume()
  137. {
  138. $this->_save($this->table, ['status' => '1']);
  139. }
  140. /**
  141. * 删除常见问题
  142. * @auth true
  143. * @throws \think\Exception
  144. * @throws \think\exception\PDOException
  145. */
  146. public function remove()
  147. {
  148. $this->_delete($this->table);
  149. }
  150. }