Feedback.php 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  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 = ['addone'];
  11. protected $noNeedRight = ['*'];
  12. public function addone(){
  13. $type = input('type','');
  14. $content = input('content','');
  15. $images = input('images','');
  16. $mobile = input('mobile','');
  17. if(empty($content)){
  18. //$this->error('内容不能为空');
  19. }
  20. if(!empty($images) && strpos($images,',')){
  21. if(count(explode(',',$images)) > 8){
  22. $this->error('一次最多只能上传9张图片');
  23. }
  24. }
  25. $data = [
  26. 'user_id' => $this->auth->id,
  27. 'type' => $type,
  28. 'content' => $content,
  29. 'images' => $images,
  30. 'mobile' => $mobile,
  31. 'createtime' => time(),
  32. 'updatetime' => time(),
  33. ];
  34. $id = Db::name('feedback')->insertGetId($data);
  35. $this->success();
  36. }
  37. //我提出的建议
  38. public function lists(){
  39. $list = Db::name('feedback')->where('user_id',$this->auth->id)->order('id desc')->autopage()->select();
  40. $list = list_domain_image($list,['images']);
  41. $this->success('success',$list);
  42. }
  43. }