package shop.alien.second.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiSort;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;
import shop.alien.entity.result.R;
import shop.alien.entity.second.SecondGoodsCategory;
import shop.alien.second.service.SecondGoodsCategoryService;

import java.util.List;

@Slf4j
@Api(tags = {"二手平台-商品类型"})
@ApiSort(9)
@CrossOrigin
@RestController
@RequestMapping("/second/goodsCategory")
@RequiredArgsConstructor
public class SecondGoodsCategoryController {

    private final SecondGoodsCategoryService service;

    @ApiOperation("搜索商品类型")
    @PostMapping("/querySecondGoodsByParentId")
    public R<List<SecondGoodsCategory>> querySecondGoodsByParentId(
            @RequestParam(value = "parentId", required = false) Integer parentId,
            @RequestParam(value = "categoryState", required = false) Integer categoryState) throws Exception {
        return R.data(service.querySecondGoodsByParentId(parentId, categoryState), "查询成功");
    }
}
