Bläddra i källkod

1.增加异常处理.

guanzi 3 år sedan
förälder
incheckning
88128c98bb

+ 2 - 2
saas-backen/src/main/java/com/pavis/app/saasbacken/controller/CommonController.java

@@ -171,10 +171,10 @@ public class CommonController {
     }
 
 
-    @PostMapping("/province/get")
+    @GetMapping("/province/get/{pid}")
     @PreSaveLog("省市区联动")
     @ApiOperation(value = "获取省市区联动接口", notes = "获取省市区联动接口")
-    public ResultBody getPCD(Integer pid) throws IOException {
+    public ResultBody getPCD(@PathVariable("pid") Integer pid) throws IOException {
        HttpServletRequest request = HttpContextUtils.getHttpServletRequest();
         String uri = request.getRequestURI();
         try {

+ 7 - 5
saas-backen/src/main/java/com/pavis/app/saasbacken/controller/LabelController.java

@@ -8,6 +8,8 @@ import com.pavis.app.saasbacken.http.ResultBody;
 import com.pavis.app.saasbacken.service.CheckModuleService;
 import com.pavis.app.saasbacken.utils.HttpContextUtils;
 import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiImplicitParam;
+import io.swagger.annotations.ApiImplicitParams;
 import io.swagger.annotations.ApiOperation;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -38,8 +40,8 @@ public class LabelController {
     private CheckModuleService checkModuleService;
 
     @PostMapping("/category/mod")
-    @PreSaveLog("修改/删除/新增标签类目属性")
-    @ApiOperation(value = "修改/删除/新增标签类目属性接口", notes = "修改/删除/新增标签类目属性接口")
+    @PreSaveLog("修改/新增标签类目属性")
+    @ApiOperation(value = "修改/新增标签类目属性接口", notes = "修改/新增标签类目属性接口")
     public ResultBody modCategory(@RequestBody List<CategoryField> categoryFields){
         HttpServletRequest request = HttpContextUtils.getHttpServletRequest();
         String uri = request.getRequestURI();
@@ -53,7 +55,9 @@ public class LabelController {
 
     @PostMapping("/category/del")
     @PreSaveLog("删除标签类目属性")
-    @ApiOperation(value = "删除标签类目属性接口", notes = "删除标签类目属性接口")
+    @ApiOperation(value = "删除标签类目属性接口", notes = "删除标签类目属性接口")@ApiImplicitParams({
+            @ApiImplicitParam(name = "ids", value = "获取标签类目属性的唯一标识id", required = false, dataType = "array", paramType = "path")
+    })
     public ResultBody delCategory(@RequestBody List<String> ids){
         HttpServletRequest request = HttpContextUtils.getHttpServletRequest();
         String uri = request.getRequestURI();
@@ -94,6 +98,4 @@ public class LabelController {
         }
     }
 
-
-
 }

+ 2 - 0
saas-backen/src/main/java/com/pavis/app/saasbacken/exception/GlobalExceptionHandler.java

@@ -72,6 +72,8 @@ public class GlobalExceptionHandler {
             code = ErrorCode.FAIL;
         } else if (className.contains("NumberFormatException")) {
             code = ErrorCode.FAIL;
+        }else if (className.contains("IsRelationExistException")) {
+            code = ErrorCode.IS_RELATION_EXIST;
         }
         return buildBody(ex, code, path, httpStatus);
     }

+ 19 - 0
saas-backen/src/main/java/com/pavis/app/saasbacken/exception/IsRelationExistException.java

@@ -0,0 +1,19 @@
+package com.pavis.app.saasbacken.exception;
+
+
+import com.pavis.app.saasbacken.http.ErrorCode;
+
+public class IsRelationExistException extends BaseException {
+
+    public IsRelationExistException() {
+        this(ErrorCode.IS_RELATION_EXIST.getCode(), ErrorCode.IS_RELATION_EXIST.getMessage());
+    }
+
+    public IsRelationExistException(String msg) {
+        this(ErrorCode.IS_RELATION_EXIST.getCode(), msg);
+    }
+
+    public IsRelationExistException(int code, String msg) {
+        super(code, msg);
+    }
+}

+ 0 - 1
saas-backen/src/main/java/com/pavis/app/saasbacken/http/ErrorCode.java

@@ -40,7 +40,6 @@ public enum ErrorCode {
     REQUEST_ORG_FAILED(4030, "request_org_failed"),
     IS_RELATION_EXIST(4031, "is_relation_exist"),
 
-    QA_NO_RESPONSE(4032, "qa_no_response"),
     ILLEGAL_ARGUMENT(4034, "illegal_argument"),
     FILENAME_NULL(4035,"filename_null"),
 

+ 2 - 0
saas-backen/src/main/java/com/pavis/app/saasbacken/service/impl/base/CheckModuleServiceImpl.java

@@ -6,6 +6,7 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.pavis.app.saasbacken.dao.*;
 import com.pavis.app.saasbacken.entity.*;
 import com.pavis.app.saasbacken.exception.IllegalArgumentException;
+import com.pavis.app.saasbacken.exception.IsRelationExistException;
 import com.pavis.app.saasbacken.form.*;
 import com.pavis.app.saasbacken.http.ErrorCode;
 import com.pavis.app.saasbacken.service.CategoryService;
@@ -444,6 +445,7 @@ public class CheckModuleServiceImpl extends ServiceImpl<CheckModuleMapper, Check
                 System.err.println("> 0");
                 // 数据已存在,无需新增。
                 map = CommonUtils.resMap(ErrorCode.IS_RELATION_EXIST.getCode(), ErrorCode.IS_RELATION_EXIST.getMessage(), categories);
+                throw new IsRelationExistException(ErrorCode.IS_RELATION_EXIST.getCode(),ErrorCode.IS_RELATION_EXIST.getMessage());
             } else {
                 categoryLists.add(dealMod(categoryField));
             }