Browse Source

假,新闻与活动的非必要登录,屏蔽和举报

lizhen_gitee 6 months ago
parent
commit
174ec40312
2 changed files with 61 additions and 8 deletions
  1. 34 7
      application/api/controller/zzz/Huodong.php
  2. 27 1
      application/api/controller/zzz/News.php

+ 34 - 7
application/api/controller/zzz/Huodong.php

@@ -9,7 +9,7 @@ use think\Db;
  */
 class Huodong extends Api
 {
-    protected $noNeedLogin = ['typelist','duixianglist'];
+    protected $noNeedLogin = ['typelist','duixianglist','huodong_list','huodong_info','huodong_joinuser'];
     protected $noNeedRight = ['*'];
 
     //活动类型
@@ -51,8 +51,17 @@ class Huodong extends Api
     //活动列表
     public function huodong_list(){
         $type_id = input('type_id',0);
-        $where = [];
 
+        //是否屏蔽
+        $map = [];
+        if($this->auth->isLogin()){
+            $screen_ids = Db::name('zzz_huodong_screen')->where('user_id',$this->auth->id)->column('huodong_id');
+            if(!empty($screen_ids)){
+                $map['hd.id'] = ['NOTIN',$screen_ids];
+            }
+        }
+
+        $where = [];
         if(!empty($type_id)){
             $where['hd.type_id'] = $type_id;
         }
@@ -61,6 +70,7 @@ class Huodong extends Api
             ->field('hd.*,user.avatar,user.nickname,user.gender')
             ->join('user','hd.user_id = user.id','LEFT')
             ->where($where)
+            ->where($map)
             ->autopage()
             ->order('hd.id desc')
             ->select();
@@ -70,8 +80,11 @@ class Huodong extends Api
         if(!empty($list)){
 
             //我参与的活动ids
-            $hd_ids = array_column($list,'id');
-            $my_join_log = Db::name('zzz_hd_joinlog')->where('user_id',$this->auth->id)->where('hd_id','IN',$hd_ids)->column('hd_id');
+            $my_join_log = [];
+            if($this->auth->isLogin()){
+                $hd_ids = array_column($list,'id');
+                $my_join_log = Db::name('zzz_hd_joinlog')->where('user_id',$this->auth->id)->where('hd_id','IN',$hd_ids)->column('hd_id');
+            }
 
             foreach($list as $key => &$val){
                 //是否已加入
@@ -104,9 +117,11 @@ class Huodong extends Api
 
         //是否已加入
         $info['is_joined'] = 0;
-        $my_join_log = Db::name('zzz_hd_joinlog')->where('user_id',$this->auth->id)->where('hd_id',$id)->find();
-        if($my_join_log){
-            $info['is_joined'] = 1;
+        if($this->auth->isLogin()){
+            $my_join_log = Db::name('zzz_hd_joinlog')->where('user_id',$this->auth->id)->where('hd_id',$id)->find();
+            if($my_join_log){
+                $info['is_joined'] = 1;
+            }
         }
 
         //显示时间
@@ -218,5 +233,17 @@ class Huodong extends Api
         $this->success();
     }
 
+    //不感兴趣
+    public function screen(){
+        $id = input('id',0);
+
+        $data = [
+            'huodong_id' => $id,
+            'user_id' => $this->auth->id,
+        ];
+        Db::name('zzz_huodong_screen')->insertGetId($data);
+        $this->success();
+    }
+
 
 }

+ 27 - 1
application/api/controller/zzz/News.php

@@ -23,7 +23,16 @@ class News extends Api
     public function newslist(){
         $type_id = input('type_id',0);
 
-        $list = Db::name('zzz_news')->field('content',true)->where('type_id',$type_id)->autopage()->select();
+        //是否屏蔽
+        $map = [];
+        if($this->auth->isLogin()){
+            $screen_ids = Db::name('zzz_news_screen')->where('user_id',$this->auth->id)->column('news_id');
+            if(!empty($screen_ids)){
+                $map['id'] = ['NOTIN',$screen_ids];
+            }
+        }
+
+        $list = Db::name('zzz_news')->field('content',true)->where('type_id',$type_id)->where($map)->autopage()->select();
         $list = list_domain_image($list,['image']);
 
         $this->success(1, $list);
@@ -37,4 +46,21 @@ class News extends Api
 
         $this->success(1, $info);
     }
+
+    //举报
+    public function report(){
+        $this->success('举报成功,客服人员即将处理');
+    }
+
+    //不感兴趣
+    public function screen(){
+        $id = input('id',0);
+
+        $data = [
+            'news_id' => $id,
+            'user_id' => $this->auth->id,
+        ];
+        Db::name('zzz_news_screen')->insertGetId($data);
+        $this->success();
+    }
 }