|
@@ -1,5 +1,6 @@
|
|
|
package cn.iocoder.yudao.module.erp.controller.admin.product;
|
|
|
|
|
|
+import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum;
|
|
|
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
|
|
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
|
|
import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
|
|
@@ -23,6 +24,7 @@ import java.io.IOException;
|
|
|
import java.util.List;
|
|
|
|
|
|
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
|
|
+import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertList;
|
|
|
import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.EXPORT;
|
|
|
|
|
|
@Tag(name = "管理后台 - ERP 产品分类")
|
|
@@ -35,14 +37,14 @@ public class ErpProductCategoryController {
|
|
|
private ErpProductCategoryService productCategoryService;
|
|
|
|
|
|
@PostMapping("/create")
|
|
|
- @Operation(summary = "创建ERP 产品分类")
|
|
|
+ @Operation(summary = "创建产品分类")
|
|
|
@PreAuthorize("@ss.hasPermission('erp:product-category:create')")
|
|
|
public CommonResult<Long> createProductCategory(@Valid @RequestBody ErpProductCategorySaveReqVO createReqVO) {
|
|
|
return success(productCategoryService.createProductCategory(createReqVO));
|
|
|
}
|
|
|
|
|
|
@PutMapping("/update")
|
|
|
- @Operation(summary = "更新ERP 产品分类")
|
|
|
+ @Operation(summary = "更新产品分类")
|
|
|
@PreAuthorize("@ss.hasPermission('erp:product-category:update')")
|
|
|
public CommonResult<Boolean> updateProductCategory(@Valid @RequestBody ErpProductCategorySaveReqVO updateReqVO) {
|
|
|
productCategoryService.updateProductCategory(updateReqVO);
|
|
@@ -50,7 +52,7 @@ public class ErpProductCategoryController {
|
|
|
}
|
|
|
|
|
|
@DeleteMapping("/delete")
|
|
|
- @Operation(summary = "删除ERP 产品分类")
|
|
|
+ @Operation(summary = "删除产品分类")
|
|
|
@Parameter(name = "id", description = "编号", required = true)
|
|
|
@PreAuthorize("@ss.hasPermission('erp:product-category:delete')")
|
|
|
public CommonResult<Boolean> deleteProductCategory(@RequestParam("id") Long id) {
|
|
@@ -59,31 +61,40 @@ public class ErpProductCategoryController {
|
|
|
}
|
|
|
|
|
|
@GetMapping("/get")
|
|
|
- @Operation(summary = "获得ERP 产品分类")
|
|
|
+ @Operation(summary = "获得产品分类")
|
|
|
@Parameter(name = "id", description = "编号", required = true, example = "1024")
|
|
|
@PreAuthorize("@ss.hasPermission('erp:product-category:query')")
|
|
|
public CommonResult<ErpProductCategoryRespVO> getProductCategory(@RequestParam("id") Long id) {
|
|
|
- ErpProductCategoryDO productCategory = productCategoryService.getProductCategory(id);
|
|
|
- return success(BeanUtils.toBean(productCategory, ErpProductCategoryRespVO.class));
|
|
|
+ ErpProductCategoryDO category = productCategoryService.getProductCategory(id);
|
|
|
+ return success(BeanUtils.toBean(category, ErpProductCategoryRespVO.class));
|
|
|
}
|
|
|
|
|
|
@GetMapping("/list")
|
|
|
- @Operation(summary = "获得ERP 产品分类列表")
|
|
|
+ @Operation(summary = "获得产品分类列表")
|
|
|
@PreAuthorize("@ss.hasPermission('erp:product-category:query')")
|
|
|
public CommonResult<List<ErpProductCategoryRespVO>> getProductCategoryList(@Valid ErpProductCategoryListReqVO listReqVO) {
|
|
|
List<ErpProductCategoryDO> list = productCategoryService.getProductCategoryList(listReqVO);
|
|
|
return success(BeanUtils.toBean(list, ErpProductCategoryRespVO.class));
|
|
|
}
|
|
|
|
|
|
+ @GetMapping("/simple-list")
|
|
|
+ @Operation(summary = "获得产品分类精简列表", description = "只包含被开启的分类,主要用于前端的下拉选项")
|
|
|
+ public CommonResult<List<ErpProductCategoryRespVO>> getProductCategorySimpleList() {
|
|
|
+ List<ErpProductCategoryDO> list = productCategoryService.getProductCategoryList(
|
|
|
+ new ErpProductCategoryListReqVO().setStatus(CommonStatusEnum.ENABLE.getStatus()));
|
|
|
+ return success(convertList(list, category -> new ErpProductCategoryRespVO()
|
|
|
+ .setId(category.getId()).setName(category.getName()).setParentId(category.getParentId())));
|
|
|
+ }
|
|
|
+
|
|
|
@GetMapping("/export-excel")
|
|
|
- @Operation(summary = "导出ERP 产品分类 Excel")
|
|
|
+ @Operation(summary = "导出产品分类 Excel")
|
|
|
@PreAuthorize("@ss.hasPermission('erp:product-category:export')")
|
|
|
@OperateLog(type = EXPORT)
|
|
|
public void exportProductCategoryExcel(@Valid ErpProductCategoryListReqVO listReqVO,
|
|
|
HttpServletResponse response) throws IOException {
|
|
|
List<ErpProductCategoryDO> list = productCategoryService.getProductCategoryList(listReqVO);
|
|
|
// 导出 Excel
|
|
|
- ExcelUtils.write(response, "ERP 产品分类.xls", "数据", ErpProductCategoryRespVO.class,
|
|
|
+ ExcelUtils.write(response, "产品分类.xls", "数据", ErpProductCategoryRespVO.class,
|
|
|
BeanUtils.toBean(list, ErpProductCategoryRespVO.class));
|
|
|
}
|
|
|
|