Feedback.php 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. <?php
  2. namespace app\api\controller\worker;
  3. use app\common\controller\Apiw;
  4. use think\Db;
  5. /**
  6. * 提建议
  7. */
  8. class Feedback extends Apiw
  9. {
  10. protected $noNeedLogin = ['addone'];
  11. protected $noNeedRight = ['*'];
  12. public function addone(){
  13. $content = input('content','');
  14. $images = input('images','');
  15. if(empty($content)){
  16. //$this->error('内容不能为空');
  17. }
  18. if(!empty($images) && strpos($images,',')){
  19. if(count(explode(',',$images)) > 8){
  20. $this->error('一次最多只能上传9张图片');
  21. }
  22. }
  23. $data = [
  24. 'worker_id' => $this->auth->id,
  25. 'company_id' => $this->auth->company_id,
  26. 'content' => $content,
  27. 'images' => $images,
  28. 'createtime' => time(),
  29. 'updatetime' => time(),
  30. ];
  31. $id = Db::name('worker_feedback')->insertGetId($data);
  32. $this->success();
  33. }
  34. //我提出的建议
  35. public function lists(){
  36. $list = Db::name('worker_feedback')->where('worker_id',$this->auth->id)->order('id desc')->autopage()->select();
  37. $list = list_domain_image($list,['images']);
  38. $this->success('success',$list);
  39. }
  40. }