瀏覽代碼

首页热门考试,首页热门培训

lizhen_gitee 6 月之前
父節點
當前提交
42ea87bd9a
共有 2 個文件被更改,包括 59 次插入3 次删除
  1. 58 3
      application/api/controller/Index.php
  2. 1 0
      application/api/controller/User.php

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

@@ -14,16 +14,17 @@ class Index extends Api
 
     /**
      * 首页
-     *
+     * 热门试卷3个
+     * 未开始的 + 进行中的
      */
     public function index()
     {
-        //热门试卷列表
         $now    = time();
         $papers = Db::name('exam_paper')->field('id,image,title,start_time,end_time,total_score,limit_time')
             ->where('status', 'NORMAL')
             ->where('deletetime', NULL)
-            ->whereRaw("((start_time = 0 and end_time = 0) or (start_time < {$now} and end_time > {$now}))")
+//            ->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('find_in_set(:user_ids,user_ids)', ['user_ids' => $this->auth->id])
             ->limit(3)
             ->select();
@@ -37,6 +38,60 @@ class Index extends Api
         $this->success('', $papers);
     }
 
+    /**
+     * 首页
+     * 全部培训3个
+     * 未开始的 + 进行中的
+     */
+    public function index_trainactive(){
+        $now    = time();
+
+        $lists = Db::name('train_active')->field('id,title,logo_image,starttime,endtime')
+            ->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) )")
+            ->limit(3)
+            ->select();
+
+        foreach($lists as $key => &$val){
+            $val['image'] = localpath_to_netpath($val['logo_image']);
+
+            if($now < $val['starttime']){
+                $val['show_status'] = 1;
+                $val['show_status_text'] = '待开始';
+            }
+            if($val['starttime'] < $now && $now < $val['endtime']){
+                $val['show_status'] = 2;
+                $val['show_status_text'] = '进行中';
+            }
+            if($val['endtime'] < $now){
+                $val['show_status'] = 3;
+                $val['show_status_text'] = '已结束';
+            }
+        }
+
+        $this->success('', $lists);
+    }
+
+    //考试,更多,所有考试列表
+    public function all_paper_list(){
+
+        $papers = Db::name('exam_paper')->field('id,image,title,start_time,end_time,total_score,limit_time')
+            ->where('status', 'NORMAL')
+            ->where('deletetime', NULL)
+            ->autopage()
+            ->select();
+
+        foreach($papers as $key => &$val){
+            $val['image'] = localpath_to_netpath($val['image']);
+            $val['limit_time'] = $val['limit_time']/60; //秒转换分种
+            $val['is_start'] = 1;
+        }
+
+        $this->success('', $papers);
+    }
+
     //在线考试
     //我的考试
     //可参加考试

+ 1 - 0
application/api/controller/User.php

@@ -193,6 +193,7 @@ class User extends Api
         if(!empty($nickname) && $this->auth->idcard_status != 1)
         {
             $data['nickname'] = $nickname;
+            $data['nickname_time'] = time();
         }
 
         if(!empty($data)){