Преглед изворни кода

BusinessException 构造器

lyhzzz пре 3 година
родитељ
комит
0447ea3de1

+ 2 - 2
4dkankan-center-platform/src/main/java/com/fdkankan/agent/service/impl/AgentServiceImpl.java

@@ -8,7 +8,7 @@ import com.fdkankan.agent.mapper.IAgentMapper;
 import com.fdkankan.agent.request.RequestAgent;
 import com.fdkankan.agent.service.IAgentService;
 import com.fdkankan.common.constant.ErrorCode;
-import com.fdkankan.common.exception.BaseRuntimeException;
+import com.fdkankan.common.exception.BusinessException;
 import org.springframework.stereotype.Service;
 
 /**
@@ -28,7 +28,7 @@ public class AgentServiceImpl extends ServiceImpl<IAgentMapper, Agent> implement
         queryWrapper.eq("agent_id",requestAgent.getAgentId());
         Agent agent = this.getOne(queryWrapper);
         if(agent == null){
-            throw new BaseRuntimeException(ErrorCode.FAILURE_CODE_3011);
+            throw new BusinessException(ErrorCode.FAILURE_CODE_3011);
         }
         return null;
     }

+ 0 - 42
4dkankan-common/src/main/java/com/fdkankan/common/exception/BaseRuntimeException.java

@@ -1,42 +0,0 @@
-package com.fdkankan.common.exception;
-
-import com.fdkankan.common.constant.ErrorCode;
-
-public class BaseRuntimeException extends RuntimeException{
-
-    private static final long serialVersionUID = -1518945670203783450L;
-    private Integer code;
-    private String msg;
-
-    public BaseRuntimeException(ErrorCode errorCode){
-        super(errorCode.message());
-        this.code = errorCode.code();
-        this.msg = errorCode.message();
-    }
-    public BaseRuntimeException(String msg){
-        super(msg);
-        this.msg = msg;
-    }
-
-    public BaseRuntimeException(Integer code, String msg){
-        super(msg);
-        this.code = code;
-        this.msg = msg;
-    }
-
-    public Integer getCode() {
-        return code;
-    }
-
-    public void setCode(Integer code) {
-        this.code = code;
-    }
-
-    public String getMsg() {
-        return msg;
-    }
-
-    public void setMsg(String msg) {
-        this.msg = msg;
-    }
-}

+ 5 - 0
4dkankan-common/src/main/java/com/fdkankan/common/exception/BusinessException.java

@@ -1,5 +1,6 @@
 package com.fdkankan.common.exception;
 
+import com.fdkankan.common.constant.ErrorCode;
 import lombok.AllArgsConstructor;
 import lombok.Data;
 
@@ -12,4 +13,8 @@ public class BusinessException extends RuntimeException {
     private int code;
     private String message;
 
+    public BusinessException (ErrorCode errorCode){
+        this.code = errorCode.code();
+        this.message = errorCode.message();
+    }
 }