|
@@ -0,0 +1,49 @@
|
|
|
+<?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_id = input('type_id',1);
|
|
|
+ $content = input('content','');
|
|
|
+ $images = input('images','');
|
|
|
+
|
|
|
+ if(empty($content)){
|
|
|
+ $this->error('内容不能为空');
|
|
|
+ }
|
|
|
+
|
|
|
+ if(!empty($images) && strpos($images,',')){
|
|
|
+ if(count(explode(',',$images)) > 3){
|
|
|
+ $this->error('一次最多只能上传3张图片');
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ $data = [
|
|
|
+ 'user_id' => $this->auth->id,
|
|
|
+ 'type_id' => $type_id,
|
|
|
+ 'content' => $content,
|
|
|
+ 'images' => $images,
|
|
|
+ 'createtime' => time(),
|
|
|
+ 'updatetime' => time(),
|
|
|
+ ];
|
|
|
+
|
|
|
+ $id = Db::name('report')->insertGetId($data);
|
|
|
+ $this->success();
|
|
|
+ }
|
|
|
+}
|