Feedback.php 1.4 KB

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