123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475 |
- <?php
- namespace app\api\controller;
- use app\common\controller\Api;
- use think\Db;
- /**
- * 意见反馈
- */
- class Report extends Api
- {
- protected $noNeedLogin = ['typelist'];
- protected $noNeedRight = ['*'];
- //类型列表
- public function typelist(){
- $list = Db::name('report_type')->order('id asc')->select();
- $this->success('success',$list);
- }
- //新增举报
- public function addone(){
- $type = input('type','');
- $to_user_id = input('to_user_id',0);
- $content = input('content','');
- $images = input('images','');
- if(empty($content)){
- $this->error('内容不能为空');
- }
- if(!empty($images) && strpos($images,',')){
- if(count(explode(',',$images)) > 8){
- $this->error('一次最多只能上传9张图片');
- }
- }
- $data = [
- 'user_id' => $this->auth->id,
- 'to_user_id' => $to_user_id,
- 'type' => $type,
- 'content' => $content,
- 'images' => $images,
- 'createtime' => time(),
- 'updatetime' => time(),
- ];
- $id = Db::name('report')->insertGetId($data);
- $this->success();
- }
- //IM举报
- public function addone_im(){
- $type = input('type',1);//类型:1=文字,2=语音,3=图片,4=阅后即焚
- $to_user_id = input('to_user_id',0);
- $content = input('content','');
- $image = input('images','');
- $audio_file = input('audio_file','');
- $data = [
- 'type' => $type,
- 'user_id' => $this->auth->id,
- 'to_user_id' => $to_user_id,
- 'content' => $content,
- 'image' => $image,
- 'audio_file' => $audio_file,
- 'createtime' => time(),
- 'updatetime' => time(),
- ];
- $id = Db::name('report_im')->insertGetId($data);
- $this->success('举报成功');
- }
- }
|