123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596 |
- <?php
- namespace addons\unishop\controller;
- use app\common\controller\Api;
- use think\Db;
- /**
- * 分类
- */
- class Category extends Api
- {
- protected $frequently = ['all','menu','inlist'];
- protected $noNeedLogin = ['all','menu','inlist'];
- protected $noNeedRight = ['*'];
- public function _initialize()
- {
- parent::_initialize();
- $this->model = new \addons\unishop\model\Category();
- }
- /**
- * @ApiTitle (全部分类数据)
- * @ApiSummary (全部分类数据)
- * @ApiMethod (GET)
- * @ApiHeaders (name=token, type=string, required=true, description="用户登录的Token", sample="a2e3cc70-d2d1-41e6-9c14-f1d774ee5e1e")
- * @ApiHeaders (name=cookie, type=string, required=false, description="用户会话的cookie")
- * @ApiReturn ({"code":1,"msg":"","data":[]})
- *
- * @ApiReturnParams (name="id", type="integer", description="分类id")
- * @ApiReturnParams (name="name", type="string", description="分类名称")
- * @ApiReturnParams (name="pid", type="integer", description="上级id")
- * @ApiReturnParams (name="image", type="string", description="图片")
- * @ApiReturnParams (name="type", type="string", description="类型")
- * @ApiReturnParams (name="flag", type="integer", description="标签/位置")
- * @ApiReturnParams (name="weigh", type="integer", description="排序")
- */
- public function all(){
- $all = $this->model
- ->where('type','product')
- ->where('status','normal')
- ->field('id,name,pid,image,type,flag,weigh')
- ->order('weigh ASC')
- ->select();
- if ($all) {
- $all = collection($all)->toArray();
- }
- $this->success('',$all);
- }
- public function inlist(){
- $list = Db::name('unishop_category')
- ->where('status','normal')
- ->field('id,name,image')
- ->order('weigh ASC')
- ->select();
- $list = list_domain_image($list,['image']);
- $this->success(1,$list);
- }
- /**
- * @ApiTitle (首页广告下面的分类)
- * @ApiSummary (首页广告下面的分类)
- * @ApiMethod (GET)
- * @ApiHeaders (name=token, type=string, required=true, description="用户登录的Token", sample="a2e3cc70-d2d1-41e6-9c14-f1d774ee5e1e")
- * @ApiHeaders (name=cookie, type=string, required=false, description="用户会话的cookie")
- * @ApiReturn ({"code":1,"msg":"","data":{}})
- *
- * @ApiReturnParams (name="id", type="integer", description="分类id")
- * @ApiReturnParams (name="name", type="string", description="分类名称")
- * @ApiReturnParams (name="pid", type="integer", description="上级id")
- * @ApiReturnParams (name="image", type="string", description="图片")
- * @ApiReturnParams (name="type", type="string", description="类型")
- * @ApiReturnParams (name="flag", type="integer", description="标签/位置")
- * @ApiReturnParams (name="weigh", type="integer", description="排序")
- */
- public function menu()
- {
- $list = $this->model
- ->where('flag','index')
- ->where('status','normal')
- ->select();
- if ($list) {
- $list = collection($list)->toArray();
- }
- $this->success('菜单',$list);
- }
- }
|