作者 开飞机的舒克

接口优化

... ... @@ -10,7 +10,7 @@ use app\common\controller\Api;
*/
class Screen extends Api
{
protected $noNeedLogin = [''];
protected $noNeedLogin = ['*'];
protected $noNeedRight = ['*'];
/**
... ... @@ -19,37 +19,18 @@ class Screen extends Api
* @ApiReturn ({"code":状态码,
"msg":"提示信息"
"time": "时间戳",
"data": [
"id": 大屏id,
"school_id": 校区id,
"images": 活动图片,
"starttime": 校区活动开始时间,
"endtime": 校区活动结束时间,
"is_view": 是否展示,
"createtime": 创建时间,
"updatetime": 更新时间,
"count_down": "倒计时",
"team": 战队排行{
"total": 24,
"per_page": 4,
"current_page": 1,
"last_page": 6,
"data": [
{
"title": "坦克战队",
"score": "13.00",
"team_id": 1,
"study": 战队个人排行{
"data": [{
"name": "李四",
"earn_score": "12.00"
},]
})
"data": "大屏图片",
"time": "当前时间",
"campus": "活动名称",
"team_rank": 战队排行[从高到底排],
"study_rank": 个人排行[每个战队中从高到低排]
}
*/
public function index(){
$time = time();
$list = [];
$data = db('data_screen')->find();
$data['images'] = cdnurl($data['images'],true);
$list['images'] = cdnurl($data['images'],true);
if ($data['starttime']<=$time || $data['endtime']>=$time){
$times = $data['endtime'] - $time;
$data['count_down'] = date('H:i:s',$times);
... ... @@ -60,21 +41,23 @@ class Screen extends Api
->where('c.id',$data['campus_id'])
->field('c.activity_id,c.school_id,c.date,s.title as school_name,a.title as activity_name')
->find();
$data['time'] = date('Y-m-d H:i:s',time());
$data['campus'] = $res['date'].$res['school_name'].$res['activity_name'];
$data['team_score'] = \db('study_score_log')
$list['time'] = date('Y-m-d H:i:s',time());
$list['campus'] = $res['date'].$res['school_name'].$res['activity_name'];
$list['team_rank'] = \db('study_score_log')
->field('SUM(score) as sum_score,team_id')
->where('campus_id',$data['campus_id'])
->group('team_id')
->order('sum_score DESC')
->paginate(4,false);
$data['study_score'] = db('study_score_log')
->limit(4)
->select();
$list['study_rank'] = db('study_score_log')
->field('study_id,SUM(score) as sum_score,team_id')
->where('campus_id',$data['campus_id'])
->order('sum_score DESC')
->group('study_id')
->paginate(10);
$this->success('获取成功',[$data, 'status' => 1]);
->limit('0,10')
->select();
$this->success('获取成功',$list);
}
}
\ No newline at end of file
... ...
... ... @@ -241,7 +241,6 @@
<a href="#数据大屏" class="list-group-item" data-toggle="collapse" data-parent="#sidebar">数据大屏 <i class="fa fa-caret-down"></i></a>
<div class="child collapse" id="数据大屏">
<a href="javascript:;" data-id="22" class="list-group-item">大屏管理 <span class="tag">
<span class="label label-success pull-right noneedlogin"></span>
</span>
</a>
</div>
... ... @@ -3075,7 +3074,7 @@
<tbody>
<tr>
<td>登录</td>
<td></td>
<td></td>
</tr>
<tr>
<td>鉴权</td>
... ... @@ -3149,35 +3148,7 @@
<div class="tab-pane" id="sample22">
<div class="row">
<div class="col-md-12">
<pre id="sample_response22">{"code":状态码,
"msg":"提示信息"
"time": "时间戳",
"data": [
"id": 大屏id,
"school_id": 校区id,
"images": 活动图片,
"starttime": 校区活动开始时间,
"endtime": 校区活动结束时间,
"is_view": 是否展示,
"createtime": 创建时间,
"updatetime": 更新时间,
"count_down": "倒计时",
"team": 战队排行{
"total": 24,
"per_page": 4,
"current_page": 1,
"last_page": 6,
"data": [
{
"title": "坦克战队",
"score": "13.00",
"team_id": 1,
"study": 战队个人排行{
"data": [{
"name": "李四",
"earn_score": "12.00"
},]
}</pre>
<pre id="sample_response22"></pre>
</div>
</div>
</div><!-- #sample -->
... ... @@ -4843,7 +4814,7 @@
</div>
<div class="col-md-6" align="right">
Generated on 2023-03-10 20:21:20 <a href="./" target="_blank">校园活动</a>
Generated on 2023-03-11 08:47:29 <a href="./" target="_blank">校园活动</a>
</div>
</div>
... ...