Feedback.php 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  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. $images_arr = explode(',',$images);
  23. if(count($images_arr) > 9){
  24. $this->error('最多只能传9张图片');
  25. }
  26. //关键字替换
  27. $info = Keyworld::sensitive($info);
  28. $data = [
  29. 'user_id' => $this->auth->id,
  30. 'category' => $category,
  31. 'info' => $info,
  32. 'images' => $images,
  33. 'createtime' => time(),
  34. 'updatetime' => time(),
  35. ];
  36. $id = Db::name('feedback')->insertGetId($data);
  37. $this->success('提交成功', $id);
  38. }
  39. public function lists(){
  40. $status = input('status',0);
  41. $where = [
  42. 'user_id' => $this->auth->id,
  43. 'status' => $status,
  44. ];
  45. $list = Db::name('feedback')->where($where)->order('id desc')->autopage()->select();
  46. $list = list_domain_image($list,['images']);
  47. $this->success(1, $list);
  48. }
  49. }