Feedback.php 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. <?php
  2. namespace app\api\controller;
  3. use app\common\controller\Api;
  4. use app\common\library\Keyworld;
  5. use think\Db;
  6. /**
  7. * 智能助手 提交反馈
  8. */
  9. class Feedback extends Api
  10. {
  11. protected $noNeedLogin = ['category'];
  12. protected $noNeedRight = ['*'];
  13. //分类
  14. public function category(){
  15. $list = Db::name('feedback_category')->field('id, name')->where('status',1)->order('weigh', 'desc')->select();
  16. $this->success(1,$list);
  17. }
  18. public function submit(){
  19. $category = input('category','','trim');
  20. $info = input('info','','trim');
  21. $images = input('images','','trim');
  22. $is_hidden = input('is_hidden',0);
  23. $images_arr = explode(',',$images);
  24. if(count($images_arr) > 9){
  25. $this->error('最多只能传9张图片');
  26. }
  27. //关键字替换
  28. $info = Keyworld::sensitive($info);
  29. $data = [
  30. 'user_id' => $this->auth->id,
  31. 'category' => $category,
  32. 'info' => $info,
  33. 'images' => $images,
  34. 'is_hidden' => $is_hidden,
  35. 'createtime' => time(),
  36. 'updatetime' => time(),
  37. ];
  38. $id = Db::name('feedback')->insertGetId($data);
  39. $this->success('提交成功', $id);
  40. }
  41. public function lists(){
  42. $status = input('status',0);
  43. $where = [
  44. 'user_id' => $this->auth->id,
  45. 'status' => $status,
  46. ];
  47. $list = Db::name('feedback')->where($where)->order('id desc')->autopage()->select();
  48. $list = list_domain_image($list,['images']);
  49. $this->success(1, $list);
  50. }
  51. }