Feedback.php 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. <?php
  2. namespace app\api\controller\worker;
  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. $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. 'content' => $content,
  26. 'images' => $images,
  27. 'createtime' => time(),
  28. 'updatetime' => time(),
  29. ];
  30. $id = Db::name('worker_feedback')->insertGetId($data);
  31. $this->success();
  32. }
  33. //我提出的建议
  34. public function lists(){
  35. $list = Db::name('worker_feedback')->where('worker_id',$this->auth->id)->order('id desc')->autopage()->select();
  36. $list = list_domain_image($list,['images']);
  37. $this->success('success',$list);
  38. }
  39. }