Browse Source

选手下拉列表,今日绑定选手

lizhen_gitee 4 months ago
parent
commit
9a2693d6a8

+ 1 - 1
addons/exam/controller/Base.php

@@ -16,7 +16,7 @@ class Base extends Api
         $controller = strtolower($this->request->controller());
         $this->loadlang($controller);
 
-        $this->getAppVersion();
+        //$this->getAppVersion();
     }
 
     /**

+ 1 - 1
addons/exam/controller/Correction.php

@@ -58,7 +58,7 @@ class Correction extends Base
     /**
      * 纠错反馈列表
      */
-    public function list()
+    public function lists()
     {
         $list = CorrectionQuestionModel::with([
             'question' => function ($query) {

+ 36 - 1
application/api/controller/Player.php

@@ -9,9 +9,44 @@ use think\Db;
  */
 class Player extends Api
 {
-    protected $noNeedLogin = [];
+    protected $noNeedLogin = ['playerlist'];
     protected $noNeedRight = ['*'];
 
+    //选手列表
+    public function playerlist(){
+        $subject_id = 1;
+
+        $map = [
+            'subject_id' => $subject_id,
+            'status' => 1,
+        ];
+
+        //搜索
+        $keyword = input('keyword','');
+        if($keyword){
+            $map['title|suozaidanwei|tuijiangonghui'] = ['LIKE','%'.$keyword.'%'];
+        }
+
+        $lists = Db::name('vote_player')->field('id,title')
+            ->where($map)->order('votes desc,id desc')->autopage()->select();
+
+        $this->success(1,$lists);
+    }
+
+
+    //用户绑定选手
+    public function bind_player(){
+        $player_id = input('player_id',0);
+
+        $data = [
+            'bind_player_id'   => $player_id,
+            'bind_player_date' => strtotime(date('Y-m-d')),
+        ];
+        Db::name('user')->where('id',$this->auth->id)->update($data);
+
+        $this->success('绑定成功');
+    }
+
     //给选手投票
     public function record(){
         $player_id = input('player_id','');

+ 4 - 13
application/api/controller/Subject.php

@@ -18,7 +18,7 @@ class Subject extends Api
     //进行中的唯一一个投票活动
     public function info(){
 
-        $find = Db::name('vote_subject')->where('status',1)->order('id desc')->find();
+        $find = Db::name('vote_subject')->where('id',1)->find();
         if(!$find){
             $this->error('没有进行中的投票活动');
         }
@@ -28,10 +28,7 @@ class Subject extends Api
 
     //选手列表
     public function playerlist(){
-        $subject_id = Db::name('vote_subject')->where('status',1)->order('id desc')->value('id');
-        if(!$subject_id){
-            $this->success(1,[]);
-        }
+        $subject_id = 1;
 
         $map = [
             'subject_id' => $subject_id,
@@ -77,10 +74,7 @@ class Subject extends Api
 
     //选手票数排行榜,按票
     public function playerlist_votes(){
-        $subject_id = Db::name('vote_subject')->where('status',1)->order('id desc')->value('id');
-        if(!$subject_id){
-            $this->success(1,[]);
-        }
+        $subject_id = 1;
 
         $map = [
             'subject_id' => $subject_id,
@@ -97,10 +91,7 @@ class Subject extends Api
 
     //选手票数排行榜,按分
     public function playerlist_score(){
-        $subject_id = Db::name('vote_subject')->where('status',1)->order('id desc')->value('id');
-        if(!$subject_id){
-            $this->success(1,[]);
-        }
+        $subject_id = 1;
 
         $map = [
             'subject_id' => $subject_id,