<?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('请求方式错误');
        }
    }

}