浏览代码

各种列表

lizhen_gitee 6 月之前
父节点
当前提交
f0496da35f
共有 1 个文件被更改,包括 29 次插入3 次删除
  1. 29 3
      application/api/controller/Index.php

+ 29 - 3
application/api/controller/Index.php

@@ -21,11 +21,18 @@ class Index extends Api
     public function index()
     {
         $now    = time();
+
+        //非实名,只能看一部分
+        $where_auth = "";
+        if($this->auth->idcard_status != 1){
+            $where_auth = "(find_in_set('".$this->auth->id."',user_ids) )";
+        }
+
         $papers = Db::name('exam_paper')->field('id,image,title,start_time,end_time,total_score,limit_time,user_ids')
             ->where('status', 'NORMAL')
             ->where('deletetime', NULL)
-//            ->whereRaw("((start_time = 0 and end_time = 0) or (start_time < {$now} and end_time > {$now}))")
             ->whereRaw("((end_time = 0) or (end_time > {$now}))")
+            ->where($where_auth)
 //            ->where('find_in_set(:user_ids,user_ids)', ['user_ids' => $this->auth->id])
             ->limit(3)
             ->order('start_time desc')
@@ -55,11 +62,17 @@ class Index extends Api
     public function index_trainactive(){
         $now    = time();
 
+        //非实名,只能看一部分
+        $where_auth = "";
+        if($this->auth->idcard_status != 1){
+            $where_auth = "(userauth_status = 1) or (find_in_set('".$this->auth->id."',user_ids) )";
+        }
+
         $lists = Db::name('train_active')->field('id,title,logo_image,starttime,endtime,pingjia_time,pingjia_uid')
             ->where('status', 1)
             ->where('deletetime', NULL)
             ->whereRaw("((endtime = 0) or (endtime > {$now}))")
-            //->where("(userauth_status = 1) or (find_in_set('".$this->auth->id."',user_ids) )")
+            ->where($where_auth)
             ->limit(3)
             ->order('starttime desc')
             ->select();
@@ -85,11 +98,17 @@ class Index extends Api
 
     //考试,更多,所有考试列表
     public function all_paper_list(){
-        if($this->auth->idcard_status != 1){$this->success(1,[]);}
+
+        //非实名,只能看一部分
+        $where_auth = "";
+        if($this->auth->idcard_status != 1){
+            $where_auth = "(find_in_set('".$this->auth->id."',user_ids) )";
+        }
 
         $papers = Db::name('exam_paper')->field('id,image,title,start_time,end_time,total_score,limit_time')
             ->where('status', 'NORMAL')
             ->where('deletetime', NULL)
+            ->where($where_auth)
             ->autopage()
             ->select();
 
@@ -119,10 +138,17 @@ class Index extends Api
             $where['endtime'] = ['gt',$now];
         }
 
+        //非实名,只能看一部分
+        $where_auth = "";
+        if($this->auth->idcard_status != 1){
+            $where_auth = "(userauth_status = 1) or (find_in_set('".$this->auth->id."',user_ids) )";
+        }
+
         $papers = Db::name('train_active')->field('id,title,logo_image,starttime,endtime,pingjia_time,pingjia_uid')
             ->where('status', 1)
             ->where('deletetime', NULL)
             ->where($where)
+            ->where($where_auth)
             ->autopage()
             ->order('starttime desc')
             ->select();