package org.dromara.app;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.wzj.soopin.goods.convert.ProductCategoryConvert;
import com.wzj.soopin.goods.domain.bo.ProductCategoryBo;
import com.wzj.soopin.goods.domain.entity.ProductCategory;
import com.wzj.soopin.goods.domain.vo.ProductCategoryVO;
import com.wzj.soopin.goods.service.impl.ProductCategoryServiceImpl;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.dromara.common.core.domain.R;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@Tag(name ="商品分类")
@RestController
@RequestMapping("/app/product/category")
@RequiredArgsConstructor
public class AppProductCategoryController {


    private final ProductCategoryServiceImpl service;
    private final ProductCategoryConvert convert;

    @Operation(summary = "查询商品分类列表")
    @PostMapping("page")
    public R<Page<ProductCategoryVO>> page(@RequestBody ProductCategoryBo query, Page<ProductCategory> page) {
        Page<ProductCategory> productCategoryPage = service.page(page,query.toWrapper());
        return R.ok(convert.toVO(productCategoryPage));
    }
    @Operation(summary = "查询列表")
    @PostMapping("/tree")
    public R<List<ProductCategoryVO>> tree(@RequestBody ProductCategoryBo bo ) {
        List<ProductCategoryVO> articleList = service.tree( bo.toWrapper());
        return R.ok( articleList);
    }

}
