提交 5c02545d authored 作者: 李秋林's avatar 李秋林

自定义异常、返回异常信息

上级 830b0739
...@@ -13,7 +13,10 @@ public enum ECode implements StatusCode { ...@@ -13,7 +13,10 @@ public enum ECode implements StatusCode {
* 700+ :SQL统一异常(不分模块) * 700+ :SQL统一异常(不分模块)
*/ */
// 唯一键冲突 // 唯一键冲突
API_ERROR(700, "%s已存在,不可重复;"); DB_TABLE_UNIQUE_EXIST(700, "%s已存在,不可重复;"),
DB_TABLE_FLAG_NOTEXIST(701, "当前数据异常或已被他人修改,请刷新重试;"),
DB_TABLE_UPDATE_ERROR(702, "数据保存异常,请刷新重试;"),
;
private int code; private int code;
......
package com.sfa.common.core.exception; package com.sfa.common.core.exception;
import com.sfa.common.core.constant.StatusCode;
/** /**
* 检查异常 * 检查异常
* *
* @author ruoyi * @author ruoyi
*/ */
public class CheckedException extends RuntimeException public class CheckedException extends RuntimeException {
{
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
public CheckedException(String message) private int code;
{ private String msg;
super(message);
}
public CheckedException(Throwable cause) public CheckedException(StatusCode statusCode, Object... strs) {
{ this.code = statusCode.getCode();
super(cause); this.msg = String.format(statusCode.getMsg(), strs);
} }
public CheckedException(String message, Throwable cause) public int getCode() {
{ return code;
super(message, cause);
} }
public CheckedException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) public String getMsg() {
{ return msg;
super(message, cause, enableSuppression, writableStackTrace);
} }
// public CheckedException(String message) {
// super(message);
// }
//
// public CheckedException(Throwable cause) {
// super(cause);
// }
//
// public CheckedException(String message, Throwable cause) {
// super(message, cause);
// }
//
// public CheckedException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) {
// super(message, cause, enableSuppression, writableStackTrace);
// }
} }
...@@ -15,12 +15,18 @@ public class BaseDo implements Serializable ...@@ -15,12 +15,18 @@ public class BaseDo implements Serializable
/** 创建者 */ /** 创建者 */
private String createBy; private String createBy;
/** 创建者 */
private Long createUserId;
/** 创建时间 */ /** 创建时间 */
private Date createTime; private Date createTime;
/** 更新者 */ /** 更新者 */
private String updateBy; private String updateBy;
/** 更新者 */
private Long updateUserId;
/** 更新时间 */ /** 更新时间 */
private Date updateTime; private Date updateTime;
...@@ -66,4 +72,20 @@ public class BaseDo implements Serializable ...@@ -66,4 +72,20 @@ public class BaseDo implements Serializable
public void setRemark(String remark) { public void setRemark(String remark) {
this.remark = remark; this.remark = remark;
} }
public Long getCreateUserId() {
return createUserId;
}
public void setCreateUserId(Long createUserId) {
this.createUserId = createUserId;
}
public Long getUpdateUserId() {
return updateUserId;
}
public void setUpdateUserId(Long updateUserId) {
this.updateUserId = updateUserId;
}
} }
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论