|
@@ -0,0 +1,94 @@
|
|
|
+package cn.iocoder.yudao.module.supplier.controller.admin.product;
|
|
|
+
|
|
|
+import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog;
|
|
|
+import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
|
|
+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.ProductCategoryPageReqVO;
|
|
|
+import cn.iocoder.yudao.module.supplier.controller.admin.product.vo.ProductCategoryRespVO;
|
|
|
+import cn.iocoder.yudao.module.supplier.controller.admin.product.vo.ProductCategorySaveReqVO;
|
|
|
+import cn.iocoder.yudao.module.supplier.dal.dataobject.product.ProductCategoryDO;
|
|
|
+import cn.iocoder.yudao.module.supplier.service.product.ProductCategoryService;
|
|
|
+import io.swagger.v3.oas.annotations.Operation;
|
|
|
+import io.swagger.v3.oas.annotations.Parameter;
|
|
|
+import io.swagger.v3.oas.annotations.tags.Tag;
|
|
|
+import org.springframework.security.access.prepost.PreAuthorize;
|
|
|
+import org.springframework.validation.annotation.Validated;
|
|
|
+import org.springframework.web.bind.annotation.*;
|
|
|
+
|
|
|
+import javax.annotation.Resource;
|
|
|
+import javax.servlet.http.HttpServletResponse;
|
|
|
+import javax.validation.Valid;
|
|
|
+import java.io.IOException;
|
|
|
+import java.util.List;
|
|
|
+
|
|
|
+import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.EXPORT;
|
|
|
+import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
|
|
+
|
|
|
+
|
|
|
+@Tag(name = "管理后台 - 商品分类")
|
|
|
+@RestController
|
|
|
+@RequestMapping("/supplier/product-category")
|
|
|
+@Validated
|
|
|
+public class ProductCategoryController {
|
|
|
+
|
|
|
+ @Resource
|
|
|
+ private ProductCategoryService productCategoryService;
|
|
|
+
|
|
|
+ @PostMapping("/create")
|
|
|
+ @Operation(summary = "创建商品分类")
|
|
|
+ @PreAuthorize("@ss.hasPermission('supplier:product-category:create')")
|
|
|
+ public CommonResult<Long> createProductCategory(@Valid @RequestBody ProductCategorySaveReqVO createReqVO) {
|
|
|
+ return success(productCategoryService.createProductCategory(createReqVO));
|
|
|
+ }
|
|
|
+
|
|
|
+ @PutMapping("/update")
|
|
|
+ @Operation(summary = "更新商品分类")
|
|
|
+ @PreAuthorize("@ss.hasPermission('supplier:product-category:update')")
|
|
|
+ public CommonResult<Boolean> updateProductCategory(@Valid @RequestBody ProductCategorySaveReqVO updateReqVO) {
|
|
|
+ productCategoryService.updateProductCategory(updateReqVO);
|
|
|
+ return success(true);
|
|
|
+ }
|
|
|
+
|
|
|
+ @DeleteMapping("/delete")
|
|
|
+ @Operation(summary = "删除商品分类")
|
|
|
+ @Parameter(name = "id", description = "编号", required = true)
|
|
|
+ @PreAuthorize("@ss.hasPermission('supplier:product-category:delete')")
|
|
|
+ public CommonResult<Boolean> deleteProductCategory(@RequestParam("id") Long id) {
|
|
|
+ productCategoryService.deleteProductCategory(id);
|
|
|
+ return success(true);
|
|
|
+ }
|
|
|
+
|
|
|
+ @GetMapping("/get")
|
|
|
+ @Operation(summary = "获得商品分类")
|
|
|
+ @Parameter(name = "id", description = "编号", required = true, example = "1024")
|
|
|
+ @PreAuthorize("@ss.hasPermission('supplier:product-category:query')")
|
|
|
+ public CommonResult<ProductCategoryRespVO> getProductCategory(@RequestParam("id") Long id) {
|
|
|
+ ProductCategoryDO productCategory = productCategoryService.getProductCategory(id);
|
|
|
+ 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));
|
|
|
+ }
|
|
|
+
|
|
|
+}
|