|
@@ -0,0 +1,75 @@
|
|
|
|
+package cn.cslg.pas.controller;
|
|
|
|
+
|
|
|
|
+import cn.cslg.pas.common.core.base.Constants;
|
|
|
|
+import cn.cslg.pas.common.dto.business.ProductCategoryDTO;
|
|
|
|
+import cn.cslg.pas.common.model.request.StringRequest;
|
|
|
|
+import cn.cslg.pas.common.utils.Response;
|
|
|
|
+
|
|
|
|
+import cn.cslg.pas.factorys.businessFactory.Business;
|
|
|
|
+import cn.cslg.pas.factorys.businessFactory.BusinessFactory;
|
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
|
+import io.swagger.v3.oas.annotations.Operation;
|
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
+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 org.springframework.web.multipart.MultipartFile;
|
|
|
|
+
|
|
|
|
+import java.util.List;
|
|
|
|
+
|
|
|
|
+/**
|
|
|
|
+ * 产品类别的Controller层
|
|
|
|
+ * @Author xiexiang
|
|
|
|
+ * @Date 2023/10/24
|
|
|
|
+ */
|
|
|
|
+@Slf4j
|
|
|
|
+@RequestMapping(Constants.API_XiaoSHI + "/productCategory")
|
|
|
|
+@RestController
|
|
|
|
+public class ProductCategoryController {
|
|
|
|
+ @Autowired
|
|
|
|
+ private BusinessFactory businessFactory;
|
|
|
|
+
|
|
|
|
+ @Operation(summary = "查询产品类别")
|
|
|
|
+ @PostMapping("/queryProductCategory")
|
|
|
|
+ public String queryProductCategory(StringRequest stringRequest) throws Exception {
|
|
|
|
+ Business business = businessFactory.getClass("productCategoryService");
|
|
|
|
+ business.queryMessage(stringRequest);
|
|
|
|
+ return "";
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Operation(summary = "添加产品类别")
|
|
|
|
+ @PostMapping("/addProductCategory")
|
|
|
|
+ public String addProductCategory(String productCategory, List<MultipartFile> files) throws Exception {
|
|
|
|
+ if (productCategory != null) {
|
|
|
|
+ ProductCategoryDTO productCategoryDTO = JSONObject.parseObject(productCategory, ProductCategoryDTO.class);
|
|
|
|
+ Business business = businessFactory.getClass("productCategoryService");
|
|
|
|
+ business.addMessage(productCategoryDTO,files);
|
|
|
|
+ return Response.success();
|
|
|
|
+ } else {
|
|
|
|
+ return Response.error("网络异常");
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Operation(summary = "更新产品类别")
|
|
|
|
+ @PostMapping("/updateProductCategory")
|
|
|
|
+ public String updateProductCategory(String event, List<MultipartFile> files) throws Exception {
|
|
|
|
+ if (event != null) {
|
|
|
|
+ ProductCategoryDTO productCategoryDTO = JSONObject.parseObject(event, ProductCategoryDTO.class);
|
|
|
|
+ Business business = businessFactory.getClass("productCategoryService");
|
|
|
|
+ business.updateMessage(productCategoryDTO,files);
|
|
|
|
+ return Response.success();
|
|
|
|
+ } else {
|
|
|
|
+ return Response.error("网络异常");
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ @Operation(summary = "删除产品类别")
|
|
|
|
+ @PostMapping("/deleteProductCategory")
|
|
|
|
+ public String deleteProductCategory(@RequestBody List<Integer> ids) throws Exception {
|
|
|
|
+ Business business = businessFactory.getClass("productCategoryService");
|
|
|
|
+ business.deleteMessage(ids);
|
|
|
|
+ return Response.success();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+}
|