正在显示
3 个修改的文件
包含
68 行增加
和
11 行删除
@@ -3,6 +3,7 @@ | @@ -3,6 +3,7 @@ | ||
3 | namespace app\api\controller; | 3 | namespace app\api\controller; |
4 | 4 | ||
5 | use app\common\controller\Api; | 5 | use app\common\controller\Api; |
6 | +use app\common\model\Item; | ||
6 | use app\common\model\ItemDetails; | 7 | use app\common\model\ItemDetails; |
7 | 8 | ||
8 | /** | 9 | /** |
@@ -199,17 +200,12 @@ class Activity extends Api | @@ -199,17 +200,12 @@ class Activity extends Api | ||
199 | { | 200 | { |
200 | $rid = $this->request->param('rid'); | 201 | $rid = $this->request->param('rid'); |
201 | $id = $this->request->param('id'); | 202 | $id = $this->request->param('id'); |
202 | - $data = db('item i') | ||
203 | - ->join('ronda r','i.ronda_id = r.id') | ||
204 | - ->join('campus c','c.id = r.campus_id') | ||
205 | - ->field('c.title as campus_title,r.title as ronda_title,r.holdtime,i.details,i.images') | ||
206 | - ->where([ | ||
207 | - 'i.ronda_id'=>$rid, | ||
208 | - 'i.id'=> $id, | ||
209 | - ]) | ||
210 | - ->find(); | 203 | + $where['ronda_ids'] = ['in',$rid]; |
204 | + $where['id'] = $id; | ||
205 | + $model = new Item(); | ||
206 | + $data = $model->where($where)->find(); | ||
211 | 207 | ||
212 | - $data['holdtime'] = date('Y-m-d',$data['holdtime']); | 208 | + //$data['holdtime'] = date('Y-m-d',$data['holdtime']); |
213 | $data['details'] = strip_tags($data['details']); | 209 | $data['details'] = strip_tags($data['details']); |
214 | $this->success('获取项目详情成功', $data); | 210 | $this->success('获取项目详情成功', $data); |
215 | } | 211 | } |
application/common/model/Item.php
0 → 100644
1 | +<?php | ||
2 | + | ||
3 | +namespace app\common\model; | ||
4 | + | ||
5 | +use think\Model; | ||
6 | + | ||
7 | +class Item extends Model | ||
8 | +{ | ||
9 | + // 表名 | ||
10 | + protected $name = 'item'; | ||
11 | + // 自动写入时间戳字段 | ||
12 | + protected $autoWriteTimestamp = 'int'; | ||
13 | + // 定义时间戳字段名 | ||
14 | + protected $createTime = 'createtime'; | ||
15 | + protected $updateTime = 'updatetime'; | ||
16 | + // 追加属性 | ||
17 | + protected $append = [ | ||
18 | + 'campus_text', | ||
19 | + 'ronda_text', | ||
20 | + 'radar_text', | ||
21 | + ]; | ||
22 | + | ||
23 | + public function getImagesAttr($value,$data){ | ||
24 | + $images = explode(',',$data['images']); | ||
25 | + foreach ($images as $k){ | ||
26 | + $list[] = cdnurl($k,true); | ||
27 | + } | ||
28 | + return $list; | ||
29 | + } | ||
30 | + | ||
31 | + public function getCampusTextAttr($value,$data){ | ||
32 | + $campus = explode(',',$data['campus_ids']); | ||
33 | + $title = []; | ||
34 | + foreach ($campus as $k){ | ||
35 | + $title[] = db('campus')->where('id',$k)->value('title'); | ||
36 | + } | ||
37 | + //$value = implode(',',$title); | ||
38 | + return $title; | ||
39 | + } | ||
40 | + | ||
41 | + public function getRondaTextAttr($value,$data){ | ||
42 | + $ronda = explode(',',$data['ronda_ids']); | ||
43 | + $title = []; | ||
44 | + foreach ($ronda as $k){ | ||
45 | + $title[] = db('ronda')->where('id',$k)->value('title'); | ||
46 | + } | ||
47 | + //$value = implode(',',$title); | ||
48 | + return $title; | ||
49 | + } | ||
50 | + | ||
51 | + public function getRadarTextAttr($value,$data){ | ||
52 | + $radar = explode(',',$data['radar_ids']); | ||
53 | + $title = []; | ||
54 | + foreach ($radar as $k){ | ||
55 | + $title[] = db('radar')->where('id',$k)->value('title'); | ||
56 | + } | ||
57 | + //$value = implode(',',$title); | ||
58 | + return $title; | ||
59 | + } | ||
60 | + | ||
61 | +} |
@@ -6197,7 +6197,7 @@ | @@ -6197,7 +6197,7 @@ | ||
6197 | 6197 | ||
6198 | </div> | 6198 | </div> |
6199 | <div class="col-md-6" align="right"> | 6199 | <div class="col-md-6" align="right"> |
6200 | - Generated on 2023-04-12 14:01:08 <a href="./" target="_blank">校园活动</a> | 6200 | + Generated on 2023-04-12 15:32:47 <a href="./" target="_blank">校园活动</a> |
6201 | </div> | 6201 | </div> |
6202 | </div> | 6202 | </div> |
6203 | 6203 |
-
请 注册 或 登录 后发表评论