chenxiaofei пре 3 месеци
родитељ
комит
b491928657

+ 3 - 0
iot-platform-common/src/main/java/com/platform/enums/ErrorCodeEnum.java

@@ -1,11 +1,14 @@
 package com.platform.enums;
 
+import lombok.Getter;
+
 /**
  *Author: donglang
  *Time: 2025-10-09
  *Description: IoT平台异常编码枚举,统一管理系统中的错误码和描述
  *Version: 1.0
  */
+@Getter
 public enum ErrorCodeEnum {
 
     // ====================== 通用错误(10000~19999)======================

+ 10 - 6
iot-platform-common/src/main/java/com/platform/exception/BusinessException.java

@@ -1,31 +1,35 @@
 package com.platform.exception;
 
+import com.platform.enums.ErrorCodeEnum;
 import lombok.Getter;
 
+import static com.platform.enums.ErrorCodeEnum.SYSTEM_ERROR;
+
 /**
  * 业务异常类
+ * @author PC
  */
 @Getter
 public class BusinessException extends RuntimeException {
     
-    private final Integer code;
+    private final String code;
     private final String message;
     
     public BusinessException(String message) {
         super(message);
-        this.code = 500;
+        this.code = SYSTEM_ERROR.getCode();
         this.message = message;
     }
     
-    public BusinessException(Integer code, String message) {
+    public BusinessException(String code, String message) {
         super(message);
         this.code = code;
         this.message = message;
     }
     
-    public BusinessException(ErrorCode errorCode) {
-        super(errorCode.getMessage());
+    public BusinessException(ErrorCodeEnum errorCode) {
+        super(errorCode.getDesc());
         this.code = errorCode.getCode();
-        this.message = errorCode.getMessage();
+        this.message = errorCode.getDesc();
     }
 }

+ 0 - 42
iot-platform-common/src/main/java/com/platform/exception/CommonErrorCode.java

@@ -1,42 +0,0 @@
-package com.platform.exception;
-
-
-
-/**
- * 常见错误码枚举
- */
-public enum CommonErrorCode implements ErrorCode {
-    
-    /**
-     * 参数校验异常
-     */
-    PARAM_VALIDATE_FAILED(1001, "参数校验失败"),
-    
-    /**
-     * 数据不存在
-     */
-    DATA_NOT_FOUND(1002, "数据不存在"),
-    
-    /**
-     * 系统异常
-     */
-    SYSTEM_ERROR(9999, "系统异常");
-    
-    private final Integer code;
-    private final String message;
-    
-    CommonErrorCode(Integer code, String message) {
-        this.code = code;
-        this.message = message;
-    }
-    
-    @Override
-    public Integer getCode() {
-        return code;
-    }
-    
-    @Override
-    public String getMessage() {
-        return message;
-    }
-}

+ 7 - 7
iot-platform-common/src/main/java/com/platform/result/HttpResult.java

@@ -13,7 +13,7 @@ import java.io.Serializable;
 @Data
 public class HttpResult<T> implements Serializable {
 
-	private int code = HttpStatus.SUCCESS_CODE;
+	private String code = HttpStatus.SUCCESS_CODE;
 	private String message = HttpStatus.SUCCESS_MESSAGE;
 	private T data;
     /**
@@ -27,7 +27,7 @@ public class HttpResult<T> implements Serializable {
      */
     public static <T> HttpResult<T> success(T data) {
         HttpResult<T> result = new HttpResult<>();
-        result.setCode(200);
+        result.setCode("000000");
         result.setMessage("success");
         result.setData(data);
         return result;
@@ -38,7 +38,7 @@ public class HttpResult<T> implements Serializable {
      */
     public static <T> HttpResult<T> failed(String message) {
         HttpResult<T> result = new HttpResult<>();
-        result.setCode(500);
+        result.setCode("500");
         result.setMessage(message);
         return result;
     }
@@ -46,7 +46,7 @@ public class HttpResult<T> implements Serializable {
     /**
      * 失败响应 - 自定义码值和消息
      */
-    public static <T> HttpResult<T> failed(Integer code, String message) {
+    public static <T> HttpResult<T> failed(String code, String message) {
         HttpResult<T> result = new HttpResult<>();
         result.setCode(code);
         result.setMessage(message);
@@ -58,7 +58,7 @@ public class HttpResult<T> implements Serializable {
      */
     public static <T> HttpResult<T> validateFailed(String message) {
         HttpResult<T> result = new HttpResult<>();
-        result.setCode(400);
+        result.setCode("400");
         result.setMessage(message);
         return result;
     }
@@ -68,7 +68,7 @@ public class HttpResult<T> implements Serializable {
      */
     public static <T> HttpResult<T> unauthorized(T data) {
         HttpResult<T> result = new HttpResult<>();
-        result.setCode(401);
+        result.setCode("401");
         result.setMessage("Unauthorized");
         result.setData(data);
         return result;
@@ -79,7 +79,7 @@ public class HttpResult<T> implements Serializable {
      */
     public static <T> HttpResult<T> forbidden(T data) {
         HttpResult<T> result = new HttpResult<>();
-        result.setCode(403);
+        result.setCode("403");
         result.setMessage("Forbidden");
         result.setData(data);
         return result;

+ 1 - 183
iot-platform-common/src/main/java/com/platform/result/HttpStatus.java

@@ -8,191 +8,9 @@ package com.platform.result;
 public class HttpStatus {
 
     /**成功状态码*/
-    public static final int SUCCESS_CODE = 200;
+    public static final String SUCCESS_CODE = "000000";
 
     /**成功提示信息*/
     public static final String SUCCESS_MESSAGE = "success";
 
-    /**未登录状态码*/
-    public static final int UN_LOGIN_CODE = 60300;
-    /**未登录提示信息*/
-    public static final String UN_LOGIN_MESSAGE = "您尚未登录,请先登录!";
-
-    /**访问权限状态码*/
-    public static final int AUTHORITY_NO_CODE = 60403;
-    public static final String ACCESS_FIAL = "暂无该功能权限!";
-
-    /**全局异常状态码*/
-    public static final int GLOBAL_EXCEPTION_CODE = 60500;
-
-    /**完结贸易订单失败异常码*/
-    public static final int COMPLETE_TORDER_FAIL_CODE = 60666;
-
-    /** 商品上架失败异常码*/
-    public static final int GOODS_PUT_ON_SHELVES_FAIL_CODE = 60667;
-
-    /**全局异常提示信息*/
-    public static final String GLOBAL_EXCEPTION_MESSAGE = "攻城狮正在拼命优化,请您稍候再试!";
-
-    /**参数缺失状态码*/
-    public static final int PARAMETERS_MISSING_CODE = 60600;
-    public static final String ID_MISSING = "id不能为空!";
-    public static final String ACCOUNT_MISSING = "用户账号必填!";
-    public static final String ACCOUNT_FREEZE = "用户账号不能重复冻结!";
-    public static final String ACCOUNT_UNFREEZE = "用户账号不能重复解冻!";
-    public static final String PWD_MISSING = "密码不能为空!";
-    public static final String TOKEN_MISSING = "token不能为空!";
-    public static final String TOKEN_ERROR = "非法token!";
-    public static final String CAPCHA_ERROR = "验证码无效!";
-    public static final String ADDRESS_EXISTS = "地点已存在,不可重复!";
-    public static final String INVALID_REQUEST = "无效的接口请求!";
-
-    /**其他自定义状态码*/
-    public static final int CODE_60603 = 60603;
-    public static final String ENTCERTIFICATES_INVAILD = "您的企业资质已失效,暂没有权限访问,请尽快更新资质";
-    public static final String ENTCERTIFICATES_NOT_REGISTER = "您未做企业资质认证,暂没有权限访问";
-    public static final String ENTCERTIFICATES_NOT_PASS = "您的企业资质认证还在审核中,暂没有权限访问";
-
-
-
-    public static final int CODE_60604 = 60604;
-    public static final int CODE_60605 = 60605;
-    public static final int CODE_60606 = 60606;
-    public static final int CODE_60607 = 60607;
-    public static final int CODE_60608 = 60608;
-    public static final int CODE_60609 = 60609;
-    /**sentinel异常code定义*/
-    public static final int CODE_60701 = 60701;
-    public static final int CODE_60801 = 60801;
-    public static final int CODE_60901 = 60901;
-    public static final int CODE_601001 = 601001;
-    public static final int CODE_601101 = 601101;
-    public static final int CODE_601201 = 601201;
-
-    public static final String FLOW_EXCEPTION_ERROR_MESSAGE = "您的访问过于频繁,请稍后重试";
-    public static final String DEGRADE_EXCEPTION_ERROR_MESSAGE = "调用服务响应异常,请稍后重试";
-    public static final String PARAM_FLOW_EXCEPTION_ERROR_MESSAGE = "您对热点参数访问过于频繁,请稍后重试";
-    public static final String SYSTEM_BLOCK_EXCEPTION_ERROR_MESSAGE = "已触碰系统的红线规则,请检查访问参数";
-    public static final String AUTHORITY_EXCEPTION_ERROR_MESSAGE = "授权规则检测不同,请检查访问参数";
-    public static final String OTHER_EXCEPTION_ERROR_MESSAGE = "非法访问,请稍后重试";
-
-    /**版本号和接口版本不对称状态码*/
-    public static final int VERSION_NOT_NEWEST_CODE = 60700;
-    /**版本号和接口版本不对称提示信息*/
-    public static final String VERSION_NOT_NEWEST_MESSAGE = "当前版本较低,请更新升级后再试!";
-
-
-    /**参数格式不正确状态码*/
-    public static final int PARAMETERS_PATTERN_ERROR_CODE = 60800;
-    /**参数格式不正确提示信息*/
-    public static final String PARAMETERS_PATTERN_ERROR_MESSAGE = "参数格式不正确";
-    public static final String CONTACTS_ERROR = "联系人格式不正确";
-    public static final String CONTACTS_PHONE_ERROR = "联系人手机号格式不正确";
-    public static final String LEGAL_NAME_ERROR = "法人格式不正确";
-    public static final String LEGAL_PHONE_ERROR = "法人手机号格式不正确";
-    public static final String LEGAL_ID_CARD_ERROR = "法人身份证号格式不正确";
-    public static final String ENT_CODE_ERROR = "营业执照编号格式不正确";
-
-    /**账号在别处登录状态码*/
-    public static final int ACCOUNT_OTHER_LOGIN_CODE = 60900;
-    /**账号在别处登录提示信息*/
-    public static final String ACCOUNT_OTHER_LOGIN_MESSAGE = "您的账号已在其他设备登录,如非本人操作,请及时修改密码!";
-
-
-    /**token无效状态码*/
-    public static final int TOKEN_INVALID_CODE = 60901;
-    /**token无效提示信息*/
-    public static final String TOKEN_INVALID_MESSAGE = "由于您一段时间未操作,为了您的账户安全,请重新登录!";
-
-    /**请求超过次数*/
-    public static final int FREQUENCY_OUT = 60902;
-    /**请求超过次数提示信息*/
-    public static final String FREQUENCY_OUT_MESSAGE = "您的操作过于频繁,请刷新浏览器或稍候重试!";
-
-    /**审核状态状态码*/
-    public static final int ACCOUNT_AUDIT_CODE = 60903;
-    /**审核状态状提示信息*/
-    public static final String ACCOUNT_AUDIT_MESSAGE = "您所属企业企业资质审批未通过,请核实确认!";
-
-    /**微信账号未绑定态码*/
-    public static final int WECHAR_BIND_CODE = 60904;
-    /**微信账号未绑定提示信息*/
-    public static final String WECHAR_BIND_MESSAGE = "您的微信还未绑定危品汇账号!";
-
-    /**
-     * 自定义状态码,该状态码没有特殊含义,只是提供一个状态标识(目前提供9个,可自行扩展)
-     * 现作为校验失败的一类异常码
-     */
-    public static final int CODE_10301 = 10301;
-
-    /**数据库的操作失败*/
-    public static final int CRUD_FAIL_CODE = 60601;
-    public static final String UPDATE_FAIL = "更新失败";
-    public static final String INSERT_FAIL = "新增失败";
-    public static final String DELETE_FAIL = "删除失败";
-
-    /**未查询到相关信息*/
-    public static final int QUERY_FAIL_CODE = 60602;
-    public static final String ACCOUNT_NOT_EXISTS = "用户信息不存在或已失效";
-    public static final String ENT_NOT_EXISTS = "企业信息不存在或已失效";
-    public static final String DEPT_NOT_EXISTS = "机构信息不存在或已失效";
-    public static final String ENTCERTIFICATES_NOT_EXISTS = "未查询到企业资质信息";
-    public static final String ROLE_NOT_EXISTS = "未查询到关联的角色";
-    public static final String USER_DEPT_NOT_EXISTS = "未查询到用户-机构关联信息";
-    public static final String MENU_NOT_EXISTS = "未查询到菜单信息";
-    public static final String PARENT_MENU_NOT_EXISTS = "未查询到父菜单信息";
-    public static final String PARENT_UNIT_NOT_EXISTS = "未查询到父级单位信息";
-    public static final String COOPERATE_ATTRIBUTE_NOT_EXISTS = "未查询到已有的合作属性";
-    public static final String COOPERATE_NOT_EXISTS = "未查询到合作记录或已失效";
-    public static final String COOPERATE_CANCEL_EXISTS = "未查询到可撤销的记录";
-    public static final String ADDRESS_NOT_EXISTS = "未查询到地址记录或已失效";
-    public static final String CONTRACT_NOT_EXISTS = "未查询到合同或已失效";
-    public static final String BANNER_NOT_EXISTS = "未查询到banner数据或已失效";
-
-    /**自定义提示消息*/
-    public static final String PASSWD_ERROR = "密码不正确";
-    public static final String PASSWD_REPEAT = "新密码与旧密码不能一样!";
-    public static final String CAPTCHA_ERROR = "验证码输入错误";
-    public static final String MSG_001 = "密码重置成功";
-    public static final String MSG_002 = "密码修改成功";
-    public static final String MSG_003 = "新增成功";
-    public static final String MSG_004 = "审批完成";
-    public static final String MSG_005 = "更新成功";
-    public static final String MSG_006 = "当前系统不允许绑定多个岗位!";
-    public static final String MSG_007 = "注册成功!";
-    public static final String MSG_008 = "删除成功!";
-    public static final String MSG_009 = "认证提交成功!";
-    public static final String MSG_010 = "绑定成功!";
-    public static final String MSG_011 = "当前企业还存在员工数据,不能删除!";
-    public static final String MSG_012 = "只能解除状态为合作中的记录!";
-    public static final String MSG_013 = "只能删除状态为已解除的记录!";
-    public static final String MSG_014 = "导出失败";
-    public static final String MSG_015 = "与对方企业存在待审核的合作关系,请撤销或者完成审核再申请!";
-    public static final String MSG_016 = "与对方企业已存在相同属性的合作关系!";
-    public static final String MSG_017 = "发起申请成功!";
-    public static final String MSG_018 = "撤销成功!";
-    public static final String MSG_019 = "只能操作正在审核中的记录!";
-    public static final String MSG_020 = "当前机构还存在员工数据,不能删除!";
-    public static final String MSG_021 = "不能重复设置默认地址!";
-    public static final String MSG_022 = "只能对草稿进行删除!";
-    public static final String MSG_023 = "解除成功!";
-    public static final String MSG_024 = "名称不能重复!";
-    public static final String MSG_025 = "禁止删除本人信息!";
-    public static final String MSG_026 = "资质认证审核中,请等待审核后再提交!";
-    public static final String MSG_027 = "一级机构不能删除!";
-    public static final String MSG_028 = "合同未签约,不能手动完结!";
-    public static final String MSG_029 = "合同编号超长!";
-    public static final String MSG_030 = "合同名称超长!";
-    public static final String MSG_031 = "您与所选企业存在未完结销售订单,当前无法删除!";
-    public static final String MSG_032 = "您与所选企业存在未完结托运承运订单,当前无法删除!";
-    public static final String MSG_033 = "当前企业资质在审核中,无法删除!";
-    public static final String MSG_034 = "您与所选企业存在未完结对账单,当前无法删除!";
-    public static final String MSG_035 = "地址信息已存在";
-
-    public static final String ENT_EXISTS = "企业已存在,不可重复!";
-    public static final String ACCOUNT_EXISTS = "用户账号已存在!";
-    public static final String DICTTYPE_EXISTS = "字典类型已存在,不可重复!";
-    public static final String DICT_EXISTS = "字典键值已存在,不可重复!";
-    public static final String PL34 = "3PL和4PL不能同时注册!";
-
 }