lizhen_gitee 3 years ago
parent
commit
97d9211301
2 changed files with 50 additions and 1 deletions
  1. 1 1
      application/api/controller/Newmessage.php
  2. 49 0
      application/api/controller/Report.php

+ 1 - 1
application/api/controller/Newmessage.php

@@ -19,7 +19,7 @@ class Newmessage extends Api
             $this->error('不能为空');
         }
 
-        if($images && strpos(',',$images)){
+        if($images && strpos($images,',')){
             if(count(explode(',',$images)) > 9){
                 $this->error('一次最多只能上传9张图片');
             }

+ 49 - 0
application/api/controller/Report.php

@@ -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();
+    }
+}