Sort.php
2.1 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
<?php
namespace app\api\controller;
use app\common\controller\Api;
use think\Validate;
/**
* 品类接口
*/
class Sort extends Api
{
protected $noNeedLogin = ['*'];
protected $noNeedRight = ['*'];
protected $uid = '';
public function _initialize()
{
parent::_initialize();
$this->uid = $this->auth->getUserId();
}
/**
* @ApiTitle (品类分类)
* @ApiSummary (品类分类)
* @ApiMethod (GET)
* @ApiRoute (/api/sort/sortType)
*
* @ApiReturn({
"code": 1,
"msg": "成功",
"time": "1574939035",
"data": [
{
"id": 1,//品类分类id
"image": "http://jinglong.springchunjia.cn/uploads/20191127/6b3a06ba3404d5cd74e2483a1b7e93b2.png",//图片路径
"images": [//轮播图路径
"http://jinglong.springchunjia.cn/uploads/20191127/febfea9a34c918cb2f100f669ede2547.png",
"http://jinglong.springchunjia.cn/uploads/20191127/042a3256122af7b10e26efb5e7649904.png"
],
"name": "箱包"//品类分类名称
},
{
"id": 2,
"image": "http://jinglong.springchunjia.cn/uploads/20191127/287ca016a4d41a239ec77c91d982309d.png",
"images": [
"http://jinglong.springchunjia.cn/uploads/20191127/febfea9a34c918cb2f100f669ede2547.png",
"http://jinglong.springchunjia.cn/uploads/20191127/042a3256122af7b10e26efb5e7649904.png"
],
"name": "配饰"
},
]
})
*/
public function sortType(){
if($this->request->isGet()){
$res = Common::selectData('gtype','id,image,images,name','sort desc,id desc');
foreach ($res as &$value){
$value['image'] = $this->auth->absolutionUrlOne($value['image']);
$value['images'] = $this->auth->absolutionUrl($value['images']);
}
$this->success('成功',$res);
}else{
$this->error('请求方式错误');
}
}
}