1
0
mirror of https://gitee.com/bookshelfplus/bookshelfplus synced 2025-09-21 01:10:39 +08:00
Code Issues Projects Releases Wiki Activity GitHub Gitee

添加查询书籍;BookDO映射文件更新;DOMapper添加@Repository注解;添加自定义业务异常处理;添加Validation验证

This commit is contained in:
2022-03-15 17:31:12 +08:00
parent e93b52df9b
commit c2079f9064
22 changed files with 1269 additions and 41 deletions

View File

@@ -0,0 +1,38 @@
package plus.bookshelf.Common.Error;
public enum BusinessErrorCode implements CommonError {
// 通用错误类型 10001
PARAMETER_VALIDATION_ERROR(10001, "参数不合法"),
UNKNOWN_ERROR(10002, "未知错误"),
// 20000开头为用户信息相关错误定义
USER_NOT_EXIST(20001, "用户不存在"),
USER_LOGIN_FAILED(20002, "用户手机号或密码不正确"),
USER_NOT_LOGIN(20003, "用户还未登录");
private BusinessErrorCode(int errCode, String errMsg) {
this.errCode = errCode;
this.errMsg = errMsg;
}
private int errCode;
private String errMsg;
@Override
public int getErrCode() {
return this.errCode;
}
@Override
public String getErrMsg() {
return this.errMsg;
}
@Override
public CommonError setErrMsg(String errMsg) {
this.errCode = errCode;
this.errMsg = errMsg;
return this;
}
}

View File

@@ -0,0 +1,37 @@
package plus.bookshelf.Common.Error;
/**
* 包装器业务异常类实现
*/
public class BusinessException extends Exception implements CommonError {
private CommonError commonError;
public BusinessException(CommonError commonError) {
super();
this.commonError = commonError;
}
// 接收自定义errMsg的方式构造业务异常
public BusinessException(CommonError commonError,String errMsg){
super();
this.commonError=commonError;
this.commonError.setErrMsg(errMsg);
}
@Override
public int getErrCode() {
return this.commonError.getErrCode();
}
@Override
public String getErrMsg() {
return this.commonError.getErrMsg();
}
@Override
public CommonError setErrMsg(String errMsg) {
this.commonError.setErrMsg(errMsg);
return this;
}
}

View File

@@ -0,0 +1,7 @@
package plus.bookshelf.Common.Error;
public interface CommonError {
public int getErrCode();
public String getErrMsg();
public CommonError setErrMsg(String errMsg);
}