package com.yiqi.api.controller.common;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.yiqi.common.constant.UrlConstants;
import com.yiqi.common.core.domain.R;
import com.yiqi.common.enums.StatusType;
import com.yiqi.core.domain.GoodsCategory;
import com.yiqi.core.service.IGoodsCategoryService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author xiaohei
 * @date 2023/10/4
 */
@Api(tags = "商品类别")
@RestController
@RequestMapping(value = UrlConstants.wxappApi + "/goods/category")
public class WeAppGoodsCategoryController {

    @Autowired
    private IGoodsCategoryService goodsCategoryService;

    @ApiOperation("获取商品类别列表")
    @GetMapping(value = "list")
    public R<List<GoodsCategory>> list(@RequestParam @ApiParam("商品类型，0：普通商品，2：生活服务商品，3：汽车美容商品") String goodsType) throws Exception{
        return R.ok(goodsCategoryService.list(new QueryWrapper<GoodsCategory>().lambda()
                .eq(GoodsCategory::getGoodsType,goodsType)
                .eq(GoodsCategory::getStatus, StatusType.OK.getCode())));
    }
}
