提交 3ab0a4ae authored 作者: 000516's avatar 000516 提交者: Coding

创建异常、异常编码等信息

创建异常、异常编码等信息
...@@ -4,6 +4,8 @@ package com.sfa.common.core.constant; ...@@ -4,6 +4,8 @@ package com.sfa.common.core.constant;
* 返回状态码 * 返回状态码
* *
* @author ruoyi * @author ruoyi
* 状态码200-699可在这里配置
* 700+则属于ECode编码,此处不可使用
*/ */
public class HttpStatus { public class HttpStatus {
/** /**
...@@ -90,32 +92,4 @@ public class HttpStatus { ...@@ -90,32 +92,4 @@ public class HttpStatus {
* 系统警告消息 * 系统警告消息
*/ */
public static final int WARN = 601; public static final int WARN = 601;
public enum RCode implements StatusCode {
/**
* 业务统一编码(不分模块)
* 2000+
*/
API_ERROR(2000, "业务异常");
private int code;
private String msg;
RCode(int code, String msg) {
this.code = code;
this.msg = msg;
}
@Override
public int getCode() {
return code;
}
@Override
public String getMsg() {
return msg;
}
}
} }
...@@ -26,12 +26,12 @@ public class R<T> implements Serializable ...@@ -26,12 +26,12 @@ public class R<T> implements Serializable
public static <T> R<T> ok() public static <T> R<T> ok()
{ {
return restResult(null, SUCCESS, null); return restResult(null, SUCCESS, "请求成功");
} }
public static <T> R<T> ok(T data) public static <T> R<T> ok(T data)
{ {
return restResult(data, SUCCESS, null); return restResult(data, SUCCESS, "请求成功");
} }
public static <T> R<T> ok(T data, String msg) public static <T> R<T> ok(T data, String msg)
...@@ -41,7 +41,7 @@ public class R<T> implements Serializable ...@@ -41,7 +41,7 @@ public class R<T> implements Serializable
public static <T> R<T> fail() public static <T> R<T> fail()
{ {
return restResult(null, FAIL, null); return restResult(null, FAIL, "请求失败");
} }
public static <T> R<T> fail(String msg) public static <T> R<T> fail(String msg)
...@@ -51,7 +51,7 @@ public class R<T> implements Serializable ...@@ -51,7 +51,7 @@ public class R<T> implements Serializable
public static <T> R<T> fail(T data) public static <T> R<T> fail(T data)
{ {
return restResult(data, FAIL, null); return restResult(data, FAIL, "请求失败");
} }
public static <T> R<T> fail(T data, String msg) public static <T> R<T> fail(T data, String msg)
......
package com.sfa.common.core.enums;
import com.sfa.common.core.constant.StatusCode;
/**
* @author : liqiulin
* @date : 2024-10-29 16
* @describe :
*/
public enum ECode implements StatusCode {
/**
* 700+ :SQL统一异常(不分模块)
*/
// 唯一键冲突
API_ERROR(700, "%s已存在,不可重复;");
private int code;
private String msg;
ECode(int code, String msg) {
this.code = code;
this.msg = msg;
}
@Override
public int getCode() {
return code;
}
@Override
public String getMsg() {
return msg;
}
}
\ No newline at end of file
package com.sfa.common.core.exception;
import com.sfa.common.core.constant.StatusCode;
/**
* @author : liqiulin
* @date : 2024-03-28 19
* @describe : 参数异常
*/
public class WXLSQLException extends RuntimeException {
private int code;
private String msg;
public WXLSQLException(StatusCode statusCode) {
this.code = statusCode.getCode();
this.msg = statusCode.getMsg();
}
public WXLSQLException(StatusCode statusCode, Object... strs) {
this.code = statusCode.getCode();
this.msg = String.format(statusCode.getMsg(), strs);
}
public int getCode() {
return code;
}
public String getMsg() {
return msg;
}
}
package com.sfa.common.core.web.domain;
import java.io.Serializable;
import java.util.Date;
/**
* Entity基类
*
* @author liqiulin
*/
public class BaseDo implements Serializable
{
private static final long serialVersionUID = 1L;
/** 创建者 */
private String createBy;
/** 创建时间 */
private Date createTime;
/** 更新者 */
private String updateBy;
/** 更新时间 */
private Date updateTime;
/** 备注 */
private String remark;
public String getCreateBy() {
return createBy;
}
public void setCreateBy(String createBy) {
this.createBy = createBy;
}
public Date getCreateTime() {
return createTime;
}
public void setCreateTime(Date createTime) {
this.createTime = createTime;
}
public String getUpdateBy() {
return updateBy;
}
public void setUpdateBy(String updateBy) {
this.updateBy = updateBy;
}
public Date getUpdateTime() {
return updateTime;
}
public void setUpdateTime(Date updateTime) {
this.updateTime = updateTime;
}
public String getRemark() {
return remark;
}
public void setRemark(String remark) {
this.remark = remark;
}
}
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论