作者 开飞机的舒克

接口优化

... ... @@ -122,25 +122,27 @@ class Activity extends Api
if (empty($cid)) {
$this->error('参数错误', ['status' => 2]);
}
$data = db('ronda r')
->join('campus c','c.id = r.campus_id')
->field('r.id as rid,c.title as campus_title,r.title as ronda_title,r.holdtime as ronda_holdtime')
->where('r.campus_id',$cid)
// $data = db('ronda r')
// ->join('campus c','c.id = r.campus_id')
// ->field('r.id as rid,c.title as campus_title,r.title as ronda_title,r.holdtime as ronda_holdtime')
// ->where('r.campus_id',$cid)
// ->paginate(10,false)
// ->each(function ($item,$key){
// $item['holdtime'] = date('Y-m-d',$item['ronda_holdtime']);
// return $item;
// });
$data = db('ronda')
->where('campus_id',$cid)
->paginate(10,false)
->each(function ($item,$key){
$item['holdtime'] = date('Y-m-d',$item['ronda_holdtime']);
$item['rid'] = $item['id'];
$item['campus_title'] = db('campus')->where('id',$item['campus_id'])->value('title');
$item['ronda_title'] = $item['title'];
$item['ronda_holdtime'] = date('Y-m-d',$item['holdtime']);
$item['images'] = cdnurl($item['images'],true);
$item['details'] = strip_tags($item['details']);
return $item;
});
// $data = db('ronda')
// ->where('campus_id',$cid)
// ->select();
// foreach ($data as $k => $v){
// $data[$k]['campus_title'] = db('campus')->where('id',$v['campus_id'])->value('title');
// $data[$k]['ronda_title'] = $v['title'];
// $data[$k]['ronda_holdtime'] = date('Y-m-d',$v['holdtime']);
// $data[$k]['images'] = cdnurl($v['images'],true);
// $data[$k]['details'] = strip_tags($v['details']);
// }
$this->success('获取场次列表成功', $data);
}
... ...