Activity.php
4.9 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
<?php
namespace app\api\controller;
use app\common\controller\Api;
/**
* 活动接口
* @ApiWeigh (97)
*/
class Activity extends Api
{
protected $noNeedLogin = [''];
protected $noNeedRight = ['*'];
/**
* @ApiTitle (活动首页)
* @ApiMethod (POST)
* @ApiParams (name="row", type="string", required=false, description="每页显示行数[非必填]")
* @ApiParams (name="page", type="string", required=false, description="当前页[非必填]")
* @ApiReturn ({"code":状态码,
"msg":"提示信息"
"time": "时间戳",
"data": [
"id": 1,
"title": "活动名称",
"images": "活动图片",
"depict": "描述",
]
})
*/
public function index()
{
$row = $this->request->param('row');
$page = $this->request->param('page');
$row = $row ? $row : 10;
$page = $page ? $page : 1;
$data = db('activity')
->order('createtime DESC')
->paginate($row,false,['page'=>$page])
->each(function ($item,$key){
$item['images'] = cdnurl($item['images'], true);
$item['createtime'] = date('Y-m-d', $item['createtime']);
return $item;
});
if (!$data) {
$this->error('当前还没有活动', ['status' => 2]);
}
$this->success('全部项目', $data);
}
/**
* @ApiTitle (项目校区)
* @ApiMethod (POST)
* @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()
{
$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')
->paginate(10,false);
if (empty($data)) {
$this->error('当前还没有校区', ['status' => 2]);
}
$this->success('项目校区', $data);
}
/**
* @ApiTitle (项目日期场次)
* @ApiMethod (POST)
* @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": "场次",
"ronda_holdtime": "场次时间",
"title": "项目名称",
"images": "项目图片",
"details": "项目详情"
}
})
*/
public function getItemRonda()
{
$id = $this->request->param('id');
if (empty($id)) {
$this->error('参数错误', ['status' => 2]);
}
$data = db('item i')
->join('item_details d','d.item_id = i.id')
->join('ronda r','i.ronda_id = r.id')
->join('campus c','c.id = i.campus_id')
->field('c.title as campus_title,r.title as ronda_title,r.holdtime as ronda_holdtime,i.title,d.images,i.details')
->where('i.campus_id',$id)
->paginate(10)
->each(function ($item,$key){
$item['images'] = cdnurl($item['images'],true);
return $item;
});
$this->success('项目场次日期', $data);
}
/**
* @ApiTitle (项目详情)
* @ApiMethod (POST)
* @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": "校区名称",
"images": "项目图片",
"details": "项目详情"
})
*/
public function getItemDetails()
{
$id = $this->request->param('id');
$data = db('item i')
->join('item_details d','d.item_id = i.id')
->join('campus c','c.id = i.campus_id')
->field('c.title as campus_title,d.images,i.details')
->where('i.id', $id)
->find();
$data['images'] = cdnurl($data['images'], true);
$this->success('获取项目详情成功', $data);
}
}