Activity.php
8.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
<?php
namespace app\api\controller;
use app\common\controller\Api;
use app\common\model\Active;
use app\common\model\Item;
use app\common\model\Ronda;
/**
* 活动接口
* @ApiWeigh (97)
*/
class Activity extends Api
{
protected $noNeedLogin = [''];
protected $noNeedRight = ['*'];
/**
* @ApiTitle (活动首页)
* @ApiMethod (POST)
* @ApiParams (name="page", type="string", required=false, description="当前页[非必填]")
* @ApiReturn ({"code":状态码,
"msg":"提示信息"
"time": "时间戳",
"data": [
"id": 1,
"title": "活动名称",
"images": "活动图片",
"depict": "描述",
]
})
*/
public function index()
{
$page = $this->request->param('page');
$data = db('activity')
->order('createtime DESC')
->paginate(10,false,['page'=>$page])
->each(function ($item,$key){
$item['images'] = cdnurl($item['image'], true);
$item['createtime'] = date('Y-m-d', $item['createtime']);
return $item;
});
if (!$data) {
$this->error('当前还没有活动', ['status' => 2]);
}
$this->success('全部活动', $data);
}
/**
* @ApiTitle (活动详情)
* @ApiMethod (POST)
* @ApiParams (name="id", type="interge", required=false, description="活动ID")
* @ApiReturn ({"code":状态码,
"msg":"提示信息"
"time": "时间戳",
"data": [
"title": "活动名称",
"images": "活动图片",
"depict": "描述",
]
})
*/
public function activeDetails(){
$id = $this->request->param('id');
$model = new Active();
$data = $model->where('id',$id)->find()->toArray();
$this->success('',$data);
}
/**
* @ApiTitle (届次)
* @ApiMethod (POST)
* @ApiParams (name="id", type="interge", required=true, description="活动id")
* @ApiReturnParams (name="code", type="integer", required=true, description="状态码")
* @ApiReturnParams (name="msg", type="string", required=true, description="提示语")
* @ApiReturnParams (name="data", type="object", description="扩展数据返回")
* @ApiReturn ({
"code":"状态码",
"msg": "提示消息",
"data": {}
})
*/
public function getSchoolItem()
{
$param = $this->request->param();
$data = db('campus c')
->join('activity a','a.id = c.activity_id')
->join('school s','s.id = c.school_id')
->field('c.*,a.title as activity_name,s.title as school_name')
->where('c.activity_id',$param['id'])
->select();
if (empty($data)) {
$this->error('当前还没有届次', ['status' => 2]);
}
$this->success('届次', $data);
}
/**
* @ApiTitle (场次筛选)
* @ApiMethod (POST)
* @ApiParams (name="cid", type="string", required=false, description="届次id")
* @ApiReturnParams (name="code", type="integer", required=true, description="状态码")
* @ApiReturnParams (name="msg", type="string", required=true, description="提示语")
* @ApiReturnParams (name="data", type="object", description="扩展数据返回")
* @ApiReturn ({
"code":"状态码",
"msg": "提示消息",
"data": {
"campus_title": "届次名称",
"ronda_title": "场次",
"ronda_holdtime": "场次时间",
}
})
*/
public function getRonda()
{
$cid = $this->request->param('cid');
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)
// ->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['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;
});
$this->success('获取场次列表成功', $data);
}
/**
* @ApiTitle (项目筛选)
* @ApiMethod (POST)
* @ApiParams (name="rid", type="string", required=false, description="场次id")
* @ApiReturnParams (name="code", type="integer", required=true, description="状态码")
* @ApiReturnParams (name="msg", type="string", required=true, description="提示语")
* @ApiReturnParams (name="data", type="object", description="扩展数据返回")
* @ApiReturn ({
"code":"状态码",
"msg": "提示消息",
"data": {
"campus_title": "届次名称",
"ronda_title": "场次",
"ronda_holdtime": "场次时间",
}
})
*/
public function getItem()
{
$rid = $this->request->param('rid');
if (empty($rid)) {
$this->error('参数错误', ['status' => 2]);
}
$model = new Ronda();
$list = $model->where('id',$rid)->value('item_ids');
$item = explode(',',$list);
foreach ($item as $k){
$data[] = db('item')->where('id',$k)->field('id,title')->find();
}
$this->success('获取项目列表成功', $data);
}
/**
* @ApiTitle (场次详情)
* @ApiMethod (POST)
* @ApiParams (name="rid", type="string", required=false, description="场次id")
* @ApiReturnParams (name="code", type="integer", required=true, description="状态码")
* @ApiReturnParams (name="msg", type="string", required=true, description="提示语")
* @ApiReturnParams (name="data", type="object", description="扩展数据返回")
* @ApiReturn ({
"code":"状态码",
"msg": "提示消息",
"data": {
"images": "场次图片",
"details": "场次详情"
})
*/
public function getRondaDetails()
{
$rid = $this->request->param('rid');
$data = db('ronda')
->where('id', $rid)
->find();
$images = explode(',',$data['images']);
foreach ($images as $k){
$list[] = cdnurl($data['images'], true);
}
$data['images'] = $list;
$this->success('获取场次详情成功', $data);
}
/**
* @ApiTitle (项目详情)
* @ApiMethod (POST)
* @ApiParams (name="rid", type="string", required=false, description="场次id")
* @ApiParams (name="id", type="string", required=false, description="项目id")
* @ApiReturnParams (name="code", type="integer", required=true, description="状态码")
* @ApiReturnParams (name="msg", type="string", required=true, description="提示语")
* @ApiReturnParams (name="data", type="object", description="扩展数据返回")
* @ApiReturn ({
"code":"状态码",
"msg": "提示消息",
"data": {
"campus_title": "届次名称",
"ronda_title": "场次名称",
"images": "项目图片",
"details": "项目详情"
})
*/
public function getItemDetails()
{
$rid = $this->request->param('rid');
$id = $this->request->param('id');
$where['ronda_ids'] = ['in',$rid];
$where['id'] = $id;
$model = new Item();
$data = $model->where($where)->find();
$data['details'] = strip_tags($data['details']);
$this->success('获取项目详情成功', $data);
}
}