Feedback.php 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. <?php
  2. namespace app\api\controller;
  3. use app\common\controller\Api;
  4. use think\Db;
  5. /**
  6. * 智能助手 提交反馈
  7. */
  8. class Feedback extends Api
  9. {
  10. protected $noNeedLogin = ['category'];
  11. protected $noNeedRight = ['*'];
  12. //分类
  13. public function category(){
  14. $list = Db::name('feedback_category')->field('id, name')->where('status',1)->order('weigh', 'desc')->select();
  15. $this->success(1,$list);
  16. }
  17. public function submit(){
  18. $category = input('category','','trim');
  19. $info = input('info','','trim');
  20. $images = input('images','','trim');
  21. $data = [
  22. 'user_id' => $this->auth->id,
  23. 'category' => $category,
  24. 'info' => $info,
  25. 'images' => $images,
  26. 'createtime' => time(),
  27. 'updatetime' => time(),
  28. ];
  29. $id = Db::name('feedback')->insertGetId($data);
  30. $this->success('提交成功', $id);
  31. }
  32. public function lists(){
  33. $status = input('status',0);
  34. $where = [
  35. 'user_id' => $this->auth->id,
  36. 'status' => $status,
  37. ];
  38. $list = Db::name('feedback')->where($where)->order('id desc')->autopage()->select();
  39. $list = list_domain_image($list,['images']);
  40. $this->success(1, $list);
  41. }
  42. }