作者 开飞机的舒克

接口优化

@@ -122,16 +122,25 @@ class Activity extends Api @@ -122,16 +122,25 @@ class Activity extends Api
122 if (empty($cid)) { 122 if (empty($cid)) {
123 $this->error('参数错误', ['status' => 2]); 123 $this->error('参数错误', ['status' => 2]);
124 } 124 }
125 - $data = db('ronda')  
126 - ->where('campus_id',$cid)  
127 - ->select();  
128 - foreach ($data as $k => $v){  
129 - $data[$k]['campus_title'] = db('campus')->where('id',$v['campus_id'])->value('title');  
130 - $data[$k]['ronda_title'] = $v['title'];  
131 - $data[$k]['ronda_holdtime'] = date('Y-m-d',$v['holdtime']);  
132 - $data[$k]['images'] = cdnurl($v['images'],true);  
133 - $data[$k]['details'] = strip_tags($v['details']);  
134 - } 125 + $data = db('ronda r')
  126 + ->join('campus c','c.id = r.campus_id')
  127 + ->field('r.id as rid,c.title as campus_title,r.title as ronda_title,r.holdtime as ronda_holdtime')
  128 + ->where('r.campus_id',$cid)
  129 + ->paginate(10,false)
  130 + ->each(function ($item,$key){
  131 + $item['holdtime'] = date('Y-m-d',$item['ronda_holdtime']);
  132 + return $item;
  133 + });
  134 +// $data = db('ronda')
  135 +// ->where('campus_id',$cid)
  136 +// ->select();
  137 +// foreach ($data as $k => $v){
  138 +// $data[$k]['campus_title'] = db('campus')->where('id',$v['campus_id'])->value('title');
  139 +// $data[$k]['ronda_title'] = $v['title'];
  140 +// $data[$k]['ronda_holdtime'] = date('Y-m-d',$v['holdtime']);
  141 +// $data[$k]['images'] = cdnurl($v['images'],true);
  142 +// $data[$k]['details'] = strip_tags($v['details']);
  143 +// }
135 $this->success('获取场次列表成功', $data); 144 $this->success('获取场次列表成功', $data);
136 } 145 }
137 146
@@ -162,7 +171,7 @@ class Activity extends Api @@ -162,7 +171,7 @@ class Activity extends Api
162 $list = $model->where('id',$rid)->value('item_ids'); 171 $list = $model->where('id',$rid)->value('item_ids');
163 $item = explode(',',$list); 172 $item = explode(',',$list);
164 foreach ($item as $k){ 173 foreach ($item as $k){
165 - $data[] = db('item')->where('id',$k)->find(); 174 + $data[] = db('item')->where('id',$k)->field('id,title')->find();
166 } 175 }
167 $this->success('获取项目列表成功', $data); 176 $this->success('获取项目列表成功', $data);
168 } 177 }
@@ -6324,7 +6324,7 @@ @@ -6324,7 +6324,7 @@
6324 6324
6325 </div> 6325 </div>
6326 <div class="col-md-6" align="right"> 6326 <div class="col-md-6" align="right">
6327 - Generated on 2023-04-21 11:06:07 <a href="./" target="_blank">校园活动</a> 6327 + Generated on 2023-04-21 11:12:27 <a href="./" target="_blank">校园活动</a>
6328 </div> 6328 </div>
6329 </div> 6329 </div>
6330 6330