作者 开飞机的舒克

接口优化

@@ -100,7 +100,7 @@ class Activity extends Api @@ -100,7 +100,7 @@ class Activity extends Api
100 } 100 }
101 $data = db('ronda r') 101 $data = db('ronda r')
102 ->join('campus c','c.id = r.campus_id') 102 ->join('campus c','c.id = r.campus_id')
103 - ->field('c.title as campus_title,r.title as ronda_title,r.holdtime as ronda_holdtime') 103 + ->field('c.title as campus_title,r.title as ronda_title,r.holdtime as ronda_holdtime,r.id')
104 ->where('r.campus_id',$id) 104 ->where('r.campus_id',$id)
105 ->paginate(10,false); 105 ->paginate(10,false);
106 $this->success('获取场次列表成功', $data); 106 $this->success('获取场次列表成功', $data);
@@ -109,8 +109,7 @@ class Activity extends Api @@ -109,8 +109,7 @@ class Activity extends Api
109 /** 109 /**
110 * @ApiTitle (项目筛选) 110 * @ApiTitle (项目筛选)
111 * @ApiMethod (POST) 111 * @ApiMethod (POST)
112 - * @ApiParams (name="id", type="string", required=false, description="校区id")  
113 - * @ApiParams (name="rid", type="string", required=false, description="场次id") 112 + * @ApiParams (name="id", type="string", required=false, description="场次id")
114 * @ApiReturnParams (name="code", type="integer", required=true, description="状态码") 113 * @ApiReturnParams (name="code", type="integer", required=true, description="状态码")
115 * @ApiReturnParams (name="msg", type="string", required=true, description="提示语") 114 * @ApiReturnParams (name="msg", type="string", required=true, description="提示语")
116 * @ApiReturnParams (name="data", type="object", description="扩展数据返回") 115 * @ApiReturnParams (name="data", type="object", description="扩展数据返回")
@@ -127,17 +126,15 @@ class Activity extends Api @@ -127,17 +126,15 @@ class Activity extends Api
127 public function getItem() 126 public function getItem()
128 { 127 {
129 $id = $this->request->param('id'); 128 $id = $this->request->param('id');
130 - $rid = $this->request->param('rid');  
131 if (empty($id)) { 129 if (empty($id)) {
132 $this->error('参数错误', ['status' => 2]); 130 $this->error('参数错误', ['status' => 2]);
133 } 131 }
134 $data = db('item i') 132 $data = db('item i')
135 - ->join('campus c','c.id = i.campus_id')  
136 ->join('ronda r','r.id = i.ronda_id') 133 ->join('ronda r','r.id = i.ronda_id')
137 - ->field('i.*') 134 + ->join('campus c','r.campus_id as c.id')
  135 + ->field('i.*,c.title as campus_title')
138 ->where([ 136 ->where([
139 - 'i.campus_id' => $id,  
140 - 'i.ronda_id' => $rid 137 + 'i.ronda_id' => $id
141 ]) 138 ])
142 ->paginate(10,false); 139 ->paginate(10,false);
143 $this->success('获取项目列表成功', $data); 140 $this->success('获取项目列表成功', $data);
@@ -171,7 +168,6 @@ class Activity extends Api @@ -171,7 +168,6 @@ class Activity extends Api
171 /** 168 /**
172 * @ApiTitle (项目详情) 169 * @ApiTitle (项目详情)
173 * @ApiMethod (POST) 170 * @ApiMethod (POST)
174 - * @ApiParams (name="cid", type="string", required=false, description="校区id")  
175 * @ApiParams (name="rid", type="string", required=false, description="场次id") 171 * @ApiParams (name="rid", type="string", required=false, description="场次id")
176 * @ApiParams (name="id", type="string", required=false, description="项目id") 172 * @ApiParams (name="id", type="string", required=false, description="项目id")
177 * @ApiReturnParams (name="code", type="integer", required=true, description="状态码") 173 * @ApiReturnParams (name="code", type="integer", required=true, description="状态码")
@@ -182,26 +178,27 @@ class Activity extends Api @@ -182,26 +178,27 @@ class Activity extends Api
182 "msg": "提示消息", 178 "msg": "提示消息",
183 "data": { 179 "data": {
184 "campus_title": "校区名称", 180 "campus_title": "校区名称",
  181 + "ronda_title": "场次名称",
185 "images": "项目图片", 182 "images": "项目图片",
186 "details": "项目详情" 183 "details": "项目详情"
187 }) 184 })
188 */ 185 */
189 public function getItemDetails() 186 public function getItemDetails()
190 { 187 {
191 - $cid = $this->request->param('cid');  
192 $rid = $this->request->param('rid'); 188 $rid = $this->request->param('rid');
193 $id = $this->request->param('id'); 189 $id = $this->request->param('id');
194 $data = db('item i') 190 $data = db('item i')
195 ->join('item_details d','d.item_id = i.id') 191 ->join('item_details d','d.item_id = i.id')
196 - ->join('campus c','c.id = i.campus_id')  
197 - ->field('c.title as campus_title,d.images,i.details') 192 + ->join('ronda r','i.ronda_id = r.id')
  193 + ->join('campus c','c.id = r.campus_id')
  194 + ->field('c.title as campus_title,r.title as ronda_title,r.holdtime,d.images,i.details')
198 ->where([ 195 ->where([
199 - 'i.campus_id'=>$cid,  
200 'i.ronda_id'=>$rid, 196 'i.ronda_id'=>$rid,
201 'i.id'=> $id, 197 'i.id'=> $id,
202 ]) 198 ])
203 ->find(); 199 ->find();
204 $data['images'] = cdnurl($data['images'], true); 200 $data['images'] = cdnurl($data['images'], true);
  201 + $data['holdtime'] = date('Ymd',$data['holdtime']);
205 $this->success('获取项目详情成功', $data); 202 $this->success('获取项目详情成功', $data);
206 } 203 }
207 } 204 }
@@ -2294,12 +2294,6 @@ @@ -2294,12 +2294,6 @@
2294 <td>id</td> 2294 <td>id</td>
2295 <td>string</td> 2295 <td>string</td>
2296 <td></td> 2296 <td></td>
2297 - <td>校区id</td>  
2298 - </tr>  
2299 - <tr>  
2300 - <td>rid</td>  
2301 - <td>string</td>  
2302 - <td></td>  
2303 <td>场次id</td> 2297 <td>场次id</td>
2304 </tr> 2298 </tr>
2305 </tbody> 2299 </tbody>
@@ -2326,11 +2320,7 @@ @@ -2326,11 +2320,7 @@
2326 <form enctype="application/x-www-form-urlencoded" role="form" action="/api/activity/getItem" method="POST" name="form3" id="form3"> 2320 <form enctype="application/x-www-form-urlencoded" role="form" action="/api/activity/getItem" method="POST" name="form3" id="form3">
2327 <div class="form-group"> 2321 <div class="form-group">
2328 <label class="control-label" for="id">id</label> 2322 <label class="control-label" for="id">id</label>
2329 - <input type="string" class="form-control input-sm" id="id" placeholder="校区id" name="id">  
2330 - </div>  
2331 - <div class="form-group">  
2332 - <label class="control-label" for="rid">rid</label>  
2333 - <input type="string" class="form-control input-sm" id="rid" placeholder="场次id" name="rid"> 2323 + <input type="string" class="form-control input-sm" id="id" placeholder="场次id" name="id">
2334 </div> 2324 </div>
2335 <div class="form-group form-group-submit"> 2325 <div class="form-group form-group-submit">
2336 <button type="submit" class="btn btn-success send" rel="3">提交</button> 2326 <button type="submit" class="btn btn-success send" rel="3">提交</button>
@@ -2627,12 +2617,6 @@ @@ -2627,12 +2617,6 @@
2627 </thead> 2617 </thead>
2628 <tbody> 2618 <tbody>
2629 <tr> 2619 <tr>
2630 - <td>cid</td>  
2631 - <td>string</td>  
2632 - <td></td>  
2633 - <td>校区id</td>  
2634 - </tr>  
2635 - <tr>  
2636 <td>rid</td> 2620 <td>rid</td>
2637 <td>string</td> 2621 <td>string</td>
2638 <td></td> 2622 <td></td>
@@ -2667,10 +2651,6 @@ @@ -2667,10 +2651,6 @@
2667 <div class="panel-body"> 2651 <div class="panel-body">
2668 <form enctype="application/x-www-form-urlencoded" role="form" action="/api/activity/getItemDetails" method="POST" name="form5" id="form5"> 2652 <form enctype="application/x-www-form-urlencoded" role="form" action="/api/activity/getItemDetails" method="POST" name="form5" id="form5">
2669 <div class="form-group"> 2653 <div class="form-group">
2670 - <label class="control-label" for="cid">cid</label>  
2671 - <input type="string" class="form-control input-sm" id="cid" placeholder="校区id" name="cid">  
2672 - </div>  
2673 - <div class="form-group">  
2674 <label class="control-label" for="rid">rid</label> 2654 <label class="control-label" for="rid">rid</label>
2675 <input type="string" class="form-control input-sm" id="rid" placeholder="场次id" name="rid"> 2655 <input type="string" class="form-control input-sm" id="rid" placeholder="场次id" name="rid">
2676 </div> 2656 </div>
@@ -2739,6 +2719,7 @@ @@ -2739,6 +2719,7 @@
2739 "msg": "提示消息", 2719 "msg": "提示消息",
2740 "data": { 2720 "data": {
2741 "campus_title": "校区名称", 2721 "campus_title": "校区名称",
  2722 + "ronda_title": "场次名称",
2742 "images": "项目图片", 2723 "images": "项目图片",
2743 "details": "项目详情" 2724 "details": "项目详情"
2744 }</pre> 2725 }</pre>
@@ -5219,7 +5200,7 @@ @@ -5219,7 +5200,7 @@
5219 5200
5220 </div> 5201 </div>
5221 <div class="col-md-6" align="right"> 5202 <div class="col-md-6" align="right">
5222 - Generated on 2023-03-17 11:49:18 <a href="./" target="_blank">校园活动</a> 5203 + Generated on 2023-03-17 13:46:22 <a href="./" target="_blank">校园活动</a>
5223 </div> 5204 </div>
5224 </div> 5205 </div>
5225 5206