|
@@ -6,6 +6,7 @@ import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
|
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
|
|
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
|
|
import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
|
|
|
+import cn.iocoder.yudao.module.supplier.controller.admin.product.vo.ProductCategoryListReqVO;
|
|
|
import cn.iocoder.yudao.module.supplier.controller.admin.product.vo.ProductCategoryPageReqVO;
|
|
|
import cn.iocoder.yudao.module.supplier.controller.admin.product.vo.ProductCategoryRespVO;
|
|
|
import cn.iocoder.yudao.module.supplier.controller.admin.product.vo.ProductCategorySaveReqVO;
|
|
@@ -22,6 +23,7 @@ import javax.annotation.Resource;
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
import javax.validation.Valid;
|
|
|
import java.io.IOException;
|
|
|
+import java.util.Comparator;
|
|
|
import java.util.List;
|
|
|
|
|
|
import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.EXPORT;
|
|
@@ -37,6 +39,15 @@ public class ProductCategoryController {
|
|
|
@Resource
|
|
|
private ProductCategoryService productCategoryService;
|
|
|
|
|
|
+ @GetMapping("/list")
|
|
|
+ @Operation(summary = "获得商品分类列表")
|
|
|
+ @PreAuthorize("@ss.hasPermission('product:category:query')")
|
|
|
+ public CommonResult<List<ProductCategoryRespVO>> getCategoryList(@Valid ProductCategoryListReqVO listReqVO) {
|
|
|
+ List<ProductCategoryDO> list = productCategoryService.getCategoryList(listReqVO);
|
|
|
+ list.sort(Comparator.comparing(ProductCategoryDO::getSort));
|
|
|
+ return success(BeanUtils.toBean(list, ProductCategoryRespVO.class));
|
|
|
+ }
|
|
|
+
|
|
|
@PostMapping("/create")
|
|
|
@Operation(summary = "创建商品分类")
|
|
|
@PreAuthorize("@ss.hasPermission('supplier:product-category:create')")
|
|
@@ -70,25 +81,5 @@ public class ProductCategoryController {
|
|
|
return success(BeanUtils.toBean(productCategory, ProductCategoryRespVO.class));
|
|
|
}
|
|
|
|
|
|
- @GetMapping("/page")
|
|
|
- @Operation(summary = "获得商品分类分页")
|
|
|
- @PreAuthorize("@ss.hasPermission('supplier:product-category:query')")
|
|
|
- public CommonResult<PageResult<ProductCategoryRespVO>> getProductCategoryPage(@Valid ProductCategoryPageReqVO pageReqVO) {
|
|
|
- PageResult<ProductCategoryDO> pageResult = productCategoryService.getProductCategoryPage(pageReqVO);
|
|
|
- return success(BeanUtils.toBean(pageResult, ProductCategoryRespVO.class));
|
|
|
- }
|
|
|
-
|
|
|
- @GetMapping("/export-excel")
|
|
|
- @Operation(summary = "导出商品分类 Excel")
|
|
|
- @PreAuthorize("@ss.hasPermission('supplier:product-category:export')")
|
|
|
- @ApiAccessLog(operateType = EXPORT)
|
|
|
- public void exportProductCategoryExcel(@Valid ProductCategoryPageReqVO pageReqVO,
|
|
|
- HttpServletResponse response) throws IOException {
|
|
|
- pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
|
|
|
- List<ProductCategoryDO> list = productCategoryService.getProductCategoryPage(pageReqVO).getList();
|
|
|
- // 导出 Excel
|
|
|
- ExcelUtils.write(response, "商品分类.xls", "数据", ProductCategoryRespVO.class,
|
|
|
- BeanUtils.toBean(list, ProductCategoryRespVO.class));
|
|
|
- }
|
|
|
|
|
|
}
|