瀏覽代碼

4/23 工单修改

lwhhszx 1 年之前
父節點
當前提交
0a40c283d9

+ 19 - 15
src/main/java/com/example/xiaoshiweixinback/controller/ProductController.java

@@ -42,25 +42,24 @@ public class ProductController {
         try {
             Integer id = productService.addOrUpdateProduct(productAddDTO);
             records.setData(id);
+        } catch (BusinessException e) {
+            return Response.error(e.getErrorCode(), e.getMessage());
         }
-      catch (BusinessException e){
-            return Response.error(e.getErrorCode(),e.getMessage());
-      }
         return Response.success(records);
     }
 
     @checkLogin
     @Operation(summary = "关注产品")
     @PostMapping("/follow")
-    public Response follow(@RequestBody AssoPersonProductDTO assoPersonProductDTO){
+    public Response follow(@RequestBody AssoPersonProductDTO assoPersonProductDTO) {
         Records records = new Records();
         Integer id = assoPersonProductService.add(assoPersonProductDTO);
-    if(id ==null){
-        return Response.noPermissions("已超过可关注数量");
-    }
-    if(id.equals(-2)){
-        return Response.noPermissions("无关注产品的权益");
-    }
+        if (id == null) {
+            return Response.noPermissions("已超过可关注数量");
+        }
+        if (id.equals(-2)) {
+            return Response.noPermissions("无关注产品的权益");
+        }
         records.setData(id);
         return Response.success(records);
     }
@@ -68,7 +67,7 @@ public class ProductController {
 
     @Operation(summary = "取消关注产品")
     @GetMapping("/unFollow")
-    public Response unFollow(Integer productId){
+    public Response unFollow(Integer productId) {
         Records records = new Records();
         Integer id = assoPersonProductService.cancel(productId);
         if (id.equals(-1)) {
@@ -93,7 +92,12 @@ public class ProductController {
     @Operation(summary = "添加或更新爆款产品")
     @PostMapping("/addOrUpdateHotProduct")
     public Response addOrUpdateHotProduct(@RequestBody HotProductAddDTO hotProductAddDTO) {
-        Integer id = productService.addOrUpdateHotProduct(hotProductAddDTO);
+        Integer id =null;
+        try {
+             id = productService.addOrUpdateHotProduct(hotProductAddDTO);
+        } catch (BusinessException e) {
+            return Response.error(e.getErrorCode(),e.getMessage());
+        }
         return Response.success(id);
     }
 
@@ -102,7 +106,7 @@ public class ProductController {
     @PostMapping("/queryHotProductDetail")
     public Response queryHotProductDetail(Integer id) {
         ProductVO productVO = productService.queryHotProductDetail(id);
-        Records records =new Records();
+        Records records = new Records();
         records.setData(productVO);
         return Response.success(records);
     }
@@ -112,7 +116,7 @@ public class ProductController {
     @Operation(summary = "上下架产品")
     @PostMapping("/updateProductIfShow")
     public Response updateProductIfShow(UpdateProductShowDTO updateProductShowDTO) {
-        List<Integer> ids= productService.updateProductIfShow(updateProductShowDTO);
+        List<Integer> ids = productService.updateProductIfShow(updateProductShowDTO);
         return Response.success(ids);
     }
 
@@ -120,7 +124,7 @@ public class ProductController {
     @Operation(summary = "删除产品")
     @PostMapping("/deleteHotProduct")
     public Response deleteHotProduct(HotProductDeleteDTO hotProductDeleteDTO) {
-        List<Integer> ids= productService.deleteHotProduct(hotProductDeleteDTO);
+        List<Integer> ids = productService.deleteHotProduct(hotProductDeleteDTO);
         return Response.success(ids);
     }
 }

+ 12 - 2
src/main/java/com/example/xiaoshiweixinback/service/ProductService.java

@@ -149,7 +149,6 @@ public class ProductService extends ServiceImpl<ProductMapper, Product> {
     public Integer addOrUpdateProduct(ProductAddDTO productAddDTO) {
         Product product = new Product();
         if (productAddDTO.getId() == null) {
-            assoPersonProductService.checkAdmin();
             product = this.addProduct(productAddDTO);
             AssoPersonProductDTO assoPersonProductDTO = new AssoPersonProductDTO();
             assoPersonProductDTO.setProductId(product.getId());
@@ -223,8 +222,19 @@ public class ProductService extends ServiceImpl<ProductMapper, Product> {
     @Transactional(rollbackFor = Exception.class)
     public Integer addOrUpdateHotProduct(HotProductAddDTO hotProductAddDTO) {
         Product product = new Product();
+        String name =hotProductAddDTO.getName();
+        if(name==null){
+            throw new BusinessException("608","产品名称不可为空");
+        }
+        LambdaQueryWrapper<Product> queryWrapper =new LambdaQueryWrapper<>();
+        queryWrapper.eq(Product::getName,name)
+                    .eq(Product::getIfHot,true);
+        Product orgProject =this.getOne(queryWrapper,false);
+        if(product!=null){
+            throw new BusinessException("607","产品名称不可重复");
+        }
+
         if (hotProductAddDTO.getId() == null) {
-            assoPersonProductService.checkAdmin();
             product = this.addProduct(hotProductAddDTO);
         } else {
             product = this.updateProduct(hotProductAddDTO, hotProductAddDTO.getId());

+ 1 - 1
src/main/java/com/example/xiaoshiweixinback/service/common/OPSService.java

@@ -89,7 +89,7 @@ public class OPSService {
 
 
     public void getImages(ImagesInfoVO image, String publicNo) throws Exception {
-        String rootPath = "D:\\patentImage\\202205-1-500\\";
+        String rootPath = "D:\\patentImage\\202205-501-1000\\";
         if (image != null) {
             Integer num = image.getNumberOfPages();
             for (int i = 1; i < num + 1; i++) {