package com.cyl.h5.controller;

import com.cyl.manager.pms.convert.ProductCategoryConvert;
import com.cyl.manager.pms.domain.entity.ProductCategory;
import com.cyl.manager.pms.domain.query.ProductCategoryQuery;
import com.cyl.manager.pms.domain.vo.ProductCategoryVO;
import com.cyl.manager.pms.service.ProductCategoryService;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.enums.BusinessType;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 商品分类Controller
 * 
 * @author zcc
 * @date 2022-11-28
 */
@Api(description ="小程序-商品分类接口列表")
@RestController
@RequestMapping("/h5/productCategory")
public class H5ProductCategoryController extends BaseController {
    @Autowired
    private ProductCategoryService service;
    @Autowired
    private ProductCategoryConvert convert;

    @ApiOperation("小程序-查询商品分类列表")
    @PostMapping("/list")
    public ResponseEntity<List<ProductCategoryVO>> list(@RequestBody ProductCategoryQuery query) {
        List<ProductCategoryVO> list = service.selectList(query, null);
        return ResponseEntity.ok(list);
    }

    @ApiOperation("小程序-获取商品分类详细信息")
    @GetMapping(value = "/{id}")
    public ResponseEntity<ProductCategory> getInfo(@PathVariable("id") Long id) {
        return ResponseEntity.ok(service.selectById(id));
    }
}
