作者 开飞机的舒克

后台修改

... ... @@ -80,7 +80,8 @@ class Study extends Backend
$this->error('已生成条形码,无需重复生成');
}
$brpath = Resource::StudyBar($ids);
$this->model->save(['qrcode' => $brpath], ['id' => $ids]);
halt($brpath);
$this->model->save(['barcode' => $brpath], ['id' => $ids]);
$this->success('操作成功');
}
... ...
... ... @@ -7,6 +7,7 @@ use app\api\model\Study;
use app\api\model\StudyScore;
use app\common\controller\Api;
use app\common\library\Auth;
use app\common\model\ScoreLog;
use think\Db;
/**
... ... @@ -22,57 +23,45 @@ class Index extends Api
* @ApiTitle (首页)
* @ApiMethod (POST)
* @ApiParams (name="campus", type="string", required=true, description="校区id[必填]")
* @ApiParams (name="row", type="string", required=false, description="每页显示行数[非必填]")
* @ApiParams (name="page", type="string", required=false, description="当前页[非必填]")
* @ApiReturn ({"code":状态码,
"msg":"提示信息"
"time": "时间戳",
"data": [
"total": 所有数据,
"per_page": 每页几行,
"current_page": 当前页,
"last_page": 最后一页,
"data": {
"id": 分数id,
"sum_score": "总分",
"study_id": '学生id',
"study": "学生姓名",
"active_study_score": 当前登录用户绑定的学生总分,
"active_study_info": "当前登录用户绑定的学生"
},
]
"id": '学生id',
"name": "学生姓名",
"score_num": "学生分数",
"rank": "排名"
}
})
*/
public function index()
{
$campus = $this->request->param('campus');
$row = $this->request->param('row');
$page = $this->request->param('page');
$row = $row ? $row : 10;
$page = $page ? $page : 1;
if (empty($campus)) {
$this->error('参数错误', ['status' => 2]);
}
$userinfo = $this->auth->getUserinfo();
$sid = \db('study')->where('user_id', $userinfo['id'])->value('id');
//个人排行榜
$data = \db('study_score_log')
->field('id,SUM(score) as sum_score,study_id')
->where('campus_id', $campus)
->group('study_id')
->order('sum_score DESC')
->paginate($row, false, ['page' => $page])
->each(function ($item, $key) {
$item['study'] = db('study')->where('id', $item['study_id'])->value('name');
return $item;
});
$data['active_study_score'] = \db('study_score_log')
->where(['study_id' => $sid, 'campus_id' => $campus])
->sum('score');
$data['active_study_info'] = \db('study')->where('id', $sid)->value('name');
$this->success('获取成功', $data);
$sid = \db('study')->where('user_id', $userinfo['id'])->find();
$count = \db('study_score_log')->where(
[
'study_id' => $sid['id'],
'campus_id' => $campus,
]
)->sum('score');
$data = \db('study_score_log')->field('study_id, SUM(score) as sum_score')->group('study_id')->order('sum_score', 'desc')->select();
$list = [];
foreach ($data as $k => $v) {
if ($v['study_id'] == $sid['id']) {
$list['id'] = $sid['id'];
$list['name'] = $sid['name'];
$list['score_num'] = $v['sum_score'];
$list['rank'] = $k + 1;
}
}
$this->success('获取成功', $list);
}
/**
* @ApiTitle (获取轮播图)
* @ApiMethod (POST)
... ... @@ -91,7 +80,8 @@ class Index extends Api
"createtime_text": "2023-03-07"
})
*/
public function getBanner(){
public function getBanner()
{
$data = \db('banner')
->order('createtime DESC')
->select();
... ... @@ -99,8 +89,8 @@ class Index extends Api
$data[$k]['images'] = cdnurl($v['images'], true);
$data[$k]['url'] = cdnurl($v['url'], true);
}
if (!$data){
$this->error('当前还没有轮播图',['status'=>2]);
if (!$data) {
$this->error('当前还没有轮播图', ['status' => 2]);
}
$this->success('获取轮播图成功', $data);
}
... ... @@ -122,7 +112,7 @@ class Index extends Api
"updatetime": "更新时间",
"is_url_text": "否",
"createtime_text": "2023-03-07"
})
})
*/
public function banner()
{
... ... @@ -232,7 +222,7 @@ class Index extends Api
->order('sum_score DESC')
->paginate($row, false, ['page' => $page])
->each(function ($item, $key) {
$item['study'] = db('study')->where('id', $item['study_id'])->value('name');
$item['study_name'] = db('study')->where('id', $item['study_id'])->value('name');
return $item;
});
//最终显示
... ...
... ... @@ -1033,18 +1033,6 @@
<td></td>
<td>校区id[必填]</td>
</tr>
<tr>
<td>row</td>
<td>string</td>
<td></td>
<td>每页显示行数[非必填]</td>
</tr>
<tr>
<td>page</td>
<td>string</td>
<td></td>
<td>当前页[非必填]</td>
</tr>
</tbody>
</table>
</div>
... ... @@ -1071,14 +1059,6 @@
<label class="control-label" for="campus">campus</label>
<input type="string" class="form-control input-sm" id="campus" required placeholder="校区id[必填]" name="campus">
</div>
<div class="form-group">
<label class="control-label" for="row">row</label>
<input type="string" class="form-control input-sm" id="row" placeholder="每页显示行数[非必填]" name="row">
</div>
<div class="form-group">
<label class="control-label" for="page">page</label>
<input type="string" class="form-control input-sm" id="page" placeholder="当前页[非必填]" name="page">
</div>
<div class="form-group form-group-submit">
<button type="submit" class="btn btn-success send" rel="13">提交</button>
<button type="reset" class="btn btn-info" rel="13">重置</button>
... ... @@ -1113,20 +1093,12 @@
<pre id="sample_response13">{"code":状态码,
"msg":"提示信息"
"time": "时间戳",
"data": [
"total": 所有数据,
"per_page": 每页几行,
"current_page": 当前页,
"last_page": 最后一页,
"data": {
"id": 分数id,
"sum_score": "总分",
"study_id": '学生id',
"study": "学生姓名",
"active_study_score": 当前登录用户绑定的学生总分,
"active_study_info": "当前登录用户绑定的学生"
},
]
"id": '学生id',
"name": "学生姓名",
"score_num": "学生分数",
"rank": "排名"
}
}</pre>
</div>
</div>
... ... @@ -1397,7 +1369,7 @@
"updatetime": "更新时间",
"is_url_text": "否",
"createtime_text": "2023-03-07"
}</pre>
}</pre>
</div>
</div>
</div><!-- #sample -->
... ... @@ -4308,7 +4280,7 @@
</div>
<div class="col-md-6" align="right">
Generated on 2023-03-10 16:13:38 <a href="./" target="_blank">校园活动</a>
Generated on 2023-03-10 18:45:38 <a href="./" target="_blank">校园活动</a>
</div>
</div>
... ...
... ... @@ -106,12 +106,12 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
title: __('生成条形码'),
classname: 'btn btn-xs btn-primary btn-ajax',
icon: 'fa fa-qrcode',
confirm: '确认生成新的条形码',
url: function(ids){
var x = JSON.stringify(ids);
var s = ids.id;
return 'study/barcode?ids='+s;
},
confirm: '确认生成新的条形码',
success: function (data, ret) {
return true;
},
... ...