Report.php 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. <?php
  2. namespace app\api\controller;
  3. use app\common\controller\Api;
  4. use think\Db;
  5. /**
  6. * 意见反馈
  7. */
  8. class Report extends Api
  9. {
  10. protected $noNeedLogin = ['typelist'];
  11. protected $noNeedRight = ['*'];
  12. //类型列表
  13. public function typelist(){
  14. $list = Db::name('report_type')->order('id asc')->select();
  15. $this->success('success',$list);
  16. }
  17. //新增举报
  18. public function addone(){
  19. $type = input('type','');
  20. $to_user_id = input('to_user_id',0);
  21. $content = input('content','');
  22. $images = input('images','');
  23. if(empty($content)){
  24. $this->error('内容不能为空');
  25. }
  26. if(!empty($images) && strpos($images,',')){
  27. if(count(explode(',',$images)) > 8){
  28. $this->error('一次最多只能上传9张图片');
  29. }
  30. }
  31. $data = [
  32. 'user_id' => $this->auth->id,
  33. 'to_user_id' => $to_user_id,
  34. 'type' => $type,
  35. 'content' => $content,
  36. 'images' => $images,
  37. 'createtime' => time(),
  38. 'updatetime' => time(),
  39. ];
  40. $id = Db::name('report')->insertGetId($data);
  41. $this->success();
  42. }
  43. //IM举报
  44. public function addone_im(){
  45. $type = input('type',1);//类型:1=文字,2=语音,3=图片,4=阅后即焚
  46. $to_user_id = input('to_user_id',0);
  47. $content = input('content','');
  48. $image = input('images','');
  49. $audio_file = input('audio_file','');
  50. $data = [
  51. 'type' => $type,
  52. 'user_id' => $this->auth->id,
  53. 'to_user_id' => $to_user_id,
  54. 'content' => $content,
  55. 'image' => $image,
  56. 'audio_file' => $audio_file,
  57. 'createtime' => time(),
  58. 'updatetime' => time(),
  59. ];
  60. $id = Db::name('report_im')->insertGetId($data);
  61. $this->success('举报成功');
  62. }
  63. }