作者 开飞机的舒克

后台修改

@@ -80,7 +80,8 @@ class Study extends Backend @@ -80,7 +80,8 @@ class Study extends Backend
80 $this->error('已生成条形码,无需重复生成'); 80 $this->error('已生成条形码,无需重复生成');
81 } 81 }
82 $brpath = Resource::StudyBar($ids); 82 $brpath = Resource::StudyBar($ids);
83 - $this->model->save(['qrcode' => $brpath], ['id' => $ids]); 83 + halt($brpath);
  84 + $this->model->save(['barcode' => $brpath], ['id' => $ids]);
84 $this->success('操作成功'); 85 $this->success('操作成功');
85 } 86 }
86 87
@@ -7,6 +7,7 @@ use app\api\model\Study; @@ -7,6 +7,7 @@ use app\api\model\Study;
7 use app\api\model\StudyScore; 7 use app\api\model\StudyScore;
8 use app\common\controller\Api; 8 use app\common\controller\Api;
9 use app\common\library\Auth; 9 use app\common\library\Auth;
  10 +use app\common\model\ScoreLog;
10 use think\Db; 11 use think\Db;
11 12
12 /** 13 /**
@@ -22,57 +23,45 @@ class Index extends Api @@ -22,57 +23,45 @@ class Index extends Api
22 * @ApiTitle (首页) 23 * @ApiTitle (首页)
23 * @ApiMethod (POST) 24 * @ApiMethod (POST)
24 * @ApiParams (name="campus", type="string", required=true, description="校区id[必填]") 25 * @ApiParams (name="campus", type="string", required=true, description="校区id[必填]")
25 - * @ApiParams (name="row", type="string", required=false, description="每页显示行数[非必填]")  
26 - * @ApiParams (name="page", type="string", required=false, description="当前页[非必填]")  
27 * @ApiReturn ({"code":状态码, 26 * @ApiReturn ({"code":状态码,
28 "msg":"提示信息" 27 "msg":"提示信息"
29 "time": "时间戳", 28 "time": "时间戳",
30 - "data": [  
31 - "total": 所有数据,  
32 - "per_page": 每页几行,  
33 - "current_page": 当前页,  
34 - "last_page": 最后一页,  
35 "data": { 29 "data": {
36 - "id": 分数id,  
37 - "sum_score": "总分",  
38 - "study_id": '学生id',  
39 - "study": "学生姓名",  
40 - "active_study_score": 当前登录用户绑定的学生总分,  
41 - "active_study_info": "当前登录用户绑定的学生"  
42 - },  
43 - ] 30 + "id": '学生id',
  31 + "name": "学生姓名",
  32 + "score_num": "学生分数",
  33 + "rank": "排名"
  34 + }
44 }) 35 })
45 */ 36 */
46 public function index() 37 public function index()
47 { 38 {
48 $campus = $this->request->param('campus'); 39 $campus = $this->request->param('campus');
49 - $row = $this->request->param('row');  
50 - $page = $this->request->param('page');  
51 - $row = $row ? $row : 10;  
52 - $page = $page ? $page : 1;  
53 if (empty($campus)) { 40 if (empty($campus)) {
54 $this->error('参数错误', ['status' => 2]); 41 $this->error('参数错误', ['status' => 2]);
55 } 42 }
56 $userinfo = $this->auth->getUserinfo(); 43 $userinfo = $this->auth->getUserinfo();
57 - $sid = \db('study')->where('user_id', $userinfo['id'])->value('id');  
58 - //个人排行榜  
59 - $data = \db('study_score_log')  
60 - ->field('id,SUM(score) as sum_score,study_id')  
61 - ->where('campus_id', $campus)  
62 - ->group('study_id')  
63 - ->order('sum_score DESC')  
64 - ->paginate($row, false, ['page' => $page])  
65 - ->each(function ($item, $key) {  
66 - $item['study'] = db('study')->where('id', $item['study_id'])->value('name');  
67 - return $item;  
68 - });  
69 - $data['active_study_score'] = \db('study_score_log')  
70 - ->where(['study_id' => $sid, 'campus_id' => $campus])  
71 - ->sum('score');  
72 - $data['active_study_info'] = \db('study')->where('id', $sid)->value('name');  
73 - $this->success('获取成功', $data); 44 + $sid = \db('study')->where('user_id', $userinfo['id'])->find();
  45 + $count = \db('study_score_log')->where(
  46 + [
  47 + 'study_id' => $sid['id'],
  48 + 'campus_id' => $campus,
  49 + ]
  50 + )->sum('score');
  51 + $data = \db('study_score_log')->field('study_id, SUM(score) as sum_score')->group('study_id')->order('sum_score', 'desc')->select();
  52 + $list = [];
  53 + foreach ($data as $k => $v) {
  54 + if ($v['study_id'] == $sid['id']) {
  55 + $list['id'] = $sid['id'];
  56 + $list['name'] = $sid['name'];
  57 + $list['score_num'] = $v['sum_score'];
  58 + $list['rank'] = $k + 1;
  59 + }
  60 + }
  61 + $this->success('获取成功', $list);
74 } 62 }
75 63
  64 +
76 /** 65 /**
77 * @ApiTitle (获取轮播图) 66 * @ApiTitle (获取轮播图)
78 * @ApiMethod (POST) 67 * @ApiMethod (POST)
@@ -91,7 +80,8 @@ class Index extends Api @@ -91,7 +80,8 @@ class Index extends Api
91 "createtime_text": "2023-03-07" 80 "createtime_text": "2023-03-07"
92 }) 81 })
93 */ 82 */
94 - public function getBanner(){ 83 + public function getBanner()
  84 + {
95 $data = \db('banner') 85 $data = \db('banner')
96 ->order('createtime DESC') 86 ->order('createtime DESC')
97 ->select(); 87 ->select();
@@ -99,8 +89,8 @@ class Index extends Api @@ -99,8 +89,8 @@ class Index extends Api
99 $data[$k]['images'] = cdnurl($v['images'], true); 89 $data[$k]['images'] = cdnurl($v['images'], true);
100 $data[$k]['url'] = cdnurl($v['url'], true); 90 $data[$k]['url'] = cdnurl($v['url'], true);
101 } 91 }
102 - if (!$data){  
103 - $this->error('当前还没有轮播图',['status'=>2]); 92 + if (!$data) {
  93 + $this->error('当前还没有轮播图', ['status' => 2]);
104 } 94 }
105 $this->success('获取轮播图成功', $data); 95 $this->success('获取轮播图成功', $data);
106 } 96 }
@@ -122,7 +112,7 @@ class Index extends Api @@ -122,7 +112,7 @@ class Index extends Api
122 "updatetime": "更新时间", 112 "updatetime": "更新时间",
123 "is_url_text": "否", 113 "is_url_text": "否",
124 "createtime_text": "2023-03-07" 114 "createtime_text": "2023-03-07"
125 - }) 115 + })
126 */ 116 */
127 public function banner() 117 public function banner()
128 { 118 {
@@ -232,7 +222,7 @@ class Index extends Api @@ -232,7 +222,7 @@ class Index extends Api
232 ->order('sum_score DESC') 222 ->order('sum_score DESC')
233 ->paginate($row, false, ['page' => $page]) 223 ->paginate($row, false, ['page' => $page])
234 ->each(function ($item, $key) { 224 ->each(function ($item, $key) {
235 - $item['study'] = db('study')->where('id', $item['study_id'])->value('name'); 225 + $item['study_name'] = db('study')->where('id', $item['study_id'])->value('name');
236 return $item; 226 return $item;
237 }); 227 });
238 //最终显示 228 //最终显示
@@ -1033,18 +1033,6 @@ @@ -1033,18 +1033,6 @@
1033 <td></td> 1033 <td></td>
1034 <td>校区id[必填]</td> 1034 <td>校区id[必填]</td>
1035 </tr> 1035 </tr>
1036 - <tr>  
1037 - <td>row</td>  
1038 - <td>string</td>  
1039 - <td></td>  
1040 - <td>每页显示行数[非必填]</td>  
1041 - </tr>  
1042 - <tr>  
1043 - <td>page</td>  
1044 - <td>string</td>  
1045 - <td></td>  
1046 - <td>当前页[非必填]</td>  
1047 - </tr>  
1048 </tbody> 1036 </tbody>
1049 </table> 1037 </table>
1050 </div> 1038 </div>
@@ -1071,14 +1059,6 @@ @@ -1071,14 +1059,6 @@
1071 <label class="control-label" for="campus">campus</label> 1059 <label class="control-label" for="campus">campus</label>
1072 <input type="string" class="form-control input-sm" id="campus" required placeholder="校区id[必填]" name="campus"> 1060 <input type="string" class="form-control input-sm" id="campus" required placeholder="校区id[必填]" name="campus">
1073 </div> 1061 </div>
1074 - <div class="form-group">  
1075 - <label class="control-label" for="row">row</label>  
1076 - <input type="string" class="form-control input-sm" id="row" placeholder="每页显示行数[非必填]" name="row">  
1077 - </div>  
1078 - <div class="form-group">  
1079 - <label class="control-label" for="page">page</label>  
1080 - <input type="string" class="form-control input-sm" id="page" placeholder="当前页[非必填]" name="page">  
1081 - </div>  
1082 <div class="form-group form-group-submit"> 1062 <div class="form-group form-group-submit">
1083 <button type="submit" class="btn btn-success send" rel="13">提交</button> 1063 <button type="submit" class="btn btn-success send" rel="13">提交</button>
1084 <button type="reset" class="btn btn-info" rel="13">重置</button> 1064 <button type="reset" class="btn btn-info" rel="13">重置</button>
@@ -1113,20 +1093,12 @@ @@ -1113,20 +1093,12 @@
1113 <pre id="sample_response13">{"code":状态码, 1093 <pre id="sample_response13">{"code":状态码,
1114 "msg":"提示信息" 1094 "msg":"提示信息"
1115 "time": "时间戳", 1095 "time": "时间戳",
1116 - "data": [  
1117 - "total": 所有数据,  
1118 - "per_page": 每页几行,  
1119 - "current_page": 当前页,  
1120 - "last_page": 最后一页,  
1121 "data": { 1096 "data": {
1122 - "id": 分数id,  
1123 - "sum_score": "总分",  
1124 - "study_id": '学生id',  
1125 - "study": "学生姓名",  
1126 - "active_study_score": 当前登录用户绑定的学生总分,  
1127 - "active_study_info": "当前登录用户绑定的学生"  
1128 - },  
1129 - ] 1097 + "id": '学生id',
  1098 + "name": "学生姓名",
  1099 + "score_num": "学生分数",
  1100 + "rank": "排名"
  1101 + }
1130 }</pre> 1102 }</pre>
1131 </div> 1103 </div>
1132 </div> 1104 </div>
@@ -1397,7 +1369,7 @@ @@ -1397,7 +1369,7 @@
1397 "updatetime": "更新时间", 1369 "updatetime": "更新时间",
1398 "is_url_text": "否", 1370 "is_url_text": "否",
1399 "createtime_text": "2023-03-07" 1371 "createtime_text": "2023-03-07"
1400 - }</pre> 1372 + }</pre>
1401 </div> 1373 </div>
1402 </div> 1374 </div>
1403 </div><!-- #sample --> 1375 </div><!-- #sample -->
@@ -4308,7 +4280,7 @@ @@ -4308,7 +4280,7 @@
4308 4280
4309 </div> 4281 </div>
4310 <div class="col-md-6" align="right"> 4282 <div class="col-md-6" align="right">
4311 - Generated on 2023-03-10 16:13:38 <a href="./" target="_blank">校园活动</a> 4283 + Generated on 2023-03-10 18:45:38 <a href="./" target="_blank">校园活动</a>
4312 </div> 4284 </div>
4313 </div> 4285 </div>
4314 4286
@@ -106,12 +106,12 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin @@ -106,12 +106,12 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
106 title: __('生成条形码'), 106 title: __('生成条形码'),
107 classname: 'btn btn-xs btn-primary btn-ajax', 107 classname: 'btn btn-xs btn-primary btn-ajax',
108 icon: 'fa fa-qrcode', 108 icon: 'fa fa-qrcode',
  109 + confirm: '确认生成新的条形码',
109 url: function(ids){ 110 url: function(ids){
110 var x = JSON.stringify(ids); 111 var x = JSON.stringify(ids);
111 var s = ids.id; 112 var s = ids.id;
112 return 'study/barcode?ids='+s; 113 return 'study/barcode?ids='+s;
113 }, 114 },
114 - confirm: '确认生成新的条形码',  
115 success: function (data, ret) { 115 success: function (data, ret) {
116 return true; 116 return true;
117 }, 117 },