整理异常

This commit is contained in:
maxf 2019-01-15 15:55:22 +08:00
parent 51f099d81b
commit 8d5120687d
23 changed files with 899 additions and 240 deletions

View File

@ -163,7 +163,7 @@ yexuejc.redis.db1=true
spring.redis.jedis.pool.max-active=100
spring.redis.jedis.pool.max-idle=10
spring.redis.jedis.pool.min-idle=3
spring.redis.host=121.42.165.89
spring.redis.host=103.45.101.109
spring.redis.password=
spring.redis.port=16379

11
pom.xml
View File

@ -5,7 +5,7 @@
<groupId>com.yexuejc.springboot</groupId>
<artifactId>yexuejc-springboot-parent</artifactId>
<version>2.0.5</version>
<version>2.0.6</version>
<packaging>pom</packaging>
<name>${project.artifactId}</name>
@ -20,7 +20,7 @@
</parent>
<properties>
<yexuejc.base.version>1.2.4</yexuejc.base.version>
<yexuejc.base.version>1.3.9</yexuejc.base.version>
<repos.yexuejc.url>https://nexus.yexuejc.club/repository/</repos.yexuejc.url>
<repos.aliyun.url>http://maven.aliyun.com/nexus/content/groups/public</repos.aliyun.url>
@ -63,13 +63,8 @@
<dependencyManagement>
<dependencies>
<!--基础包-->
<!--<dependency>-->
<!--<groupId>com.github.yexuejc</groupId>-->
<!--<artifactId>yexuejc-base</artifactId>-->
<!--<version>${yexuejc.base.version}</version>-->
<!--</dependency>-->
<dependency>
<groupId>com.yexuejc.base</groupId>
<groupId>top.yexuejc</groupId>
<artifactId>yexuejc-base</artifactId>
<version>${yexuejc.base.version}</version>
</dependency>

View File

@ -9,7 +9,7 @@
<parent>
<groupId>com.yexuejc.springboot</groupId>
<artifactId>yexuejc-springboot-parent</artifactId>
<version>2.0.5</version>
<version>2.0.6</version>
<!-- 本地打包:使用相对关联路径 -->
<!--<relativePath>../../yexuejc</relativePath>-->
</parent>
@ -23,13 +23,10 @@
<dependencies>
<!--基础包-->
<dependency>
<groupId>com.yexuejc.base</groupId>
<groupId>top.yexuejc</groupId>
<artifactId>yexuejc-base</artifactId>
</dependency>
<!--<dependency>-->
<!--<groupId>com.github.yexuejc</groupId>-->
<!--<artifactId>yexuejc-base</artifactId>-->
<!--</dependency>-->
<!-- 使用springMVC -->
<dependency>

View File

@ -54,7 +54,6 @@ import java.util.List;
@EnableConfigurationProperties(ValidationFilterProperties.class)
public class WebAutoConfiguration extends WebMvcConfigurerAdapter {
public WebAutoConfiguration(ValidationFilterProperties properties) {
this.properties = properties;
}
@ -95,7 +94,6 @@ public class WebAutoConfiguration extends WebMvcConfigurerAdapter {
/******************************************编码部分*****************************************************/
/**
* 添加拦截器
*/
@ -148,40 +146,14 @@ public class WebAutoConfiguration extends WebMvcConfigurerAdapter {
return registration;
}
@Bean
/**
* 是否开启HTTPSSSL请求证书验证忽略默认false
*/
@Bean
@ConditionalOnProperty(name = "yexuejc.enable.ssl-ignore", matchIfMissing = false)
public SSLUtil getSslUtil() {
return new SSLUtil();
}
/**
* 全局异常处理
*/
@ControllerAdvice
static class GlobalExceptionHandler {
private static final String ERROR_MSG = "系统错误,请联系管理员";
/**
* 出现异常时用于返回Json数据
*
* @param e
* @return
*/
@ExceptionHandler(value = Throwable.class)
@ResponseBody
@ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR)
public Resps<Object> jsonErrorHandler(Throwable e) {
LogUtil.exceptionLogger.error("", e);
if (e instanceof GatewayException) {
return Resps.error(StrUtil.setStr(e.getMessage(), ERROR_MSG));
} else if (e instanceof HttpRequestMethodNotSupportedException) {
return Resps.error("请求方式错误");
}
return Resps.error(ERROR_MSG);
}
}
}

View File

@ -1,78 +1,12 @@
package com.yexuejc.springboot.base.constant;
/**
* <pre>
* 名称项目+业务code
* 业务code:项目编号+业务编号
* base:100
* api:101
* wap:102
* admin:103
* </pre>
* 常用字段
*
* @author: maxf
* @date: 2018/3/13 19:43
*/
public class BizConsts {
/**
* base_code:100
*/
public static String BASE_CODE = "100";
/**
* 100001:该账户已被禁用
*/
public static String BASE_IS_LOCK_CODE = BASE_CODE + "001";
public static String BASE_IS_LOCK_MSG = "该账户已被禁用";
/**
* 100002:该帐户已过期
*/
public static String BASE_IS_EXPIRE_CODE = BASE_CODE + "002";
public static String BASE_IS_EXPIRE_MSG = "该帐户已过期";
/**
* 100003:登陆凭证已经过期请重新登陆
*/
public static String BASE_LOGIN_IS_EXPIRE_CODE = BASE_CODE + "003";
public static String BASE_LOGIN_IS_EXPIRE_MSG = "登陆凭证已经过期,请重新登陆";
/**
* 100004:该账户被锁定
*/
public static String BASE_IS_LOCKED_CODE = BASE_CODE + "004";
public static String BASE_IS_LOCKED_MSG = "该账户被锁定";
/**
* 100005:身份验证凭证未找到
*/
public static String BASE_CREDENTIALS_NOT_FOUND_CODE = BASE_CODE + "005";
public static String BASE_CREDENTIALS_NOT_FOUND_MSG = "身份验证凭证未找到";
/**
* 100006:密码错误
*/
public static String BASE_PWD_IS_ERR_CODE = BASE_CODE + "006";
public static String BASE_PWD_IS_ERR_MSG = "密码错误";
/**
* 100007:该账户名不存在
*/
public static String BASE_ACCOUNT_NOT_FOUND_CODE = BASE_CODE + "007";
public static String BASE_ACCOUNT_NOT_FOUND_MSG = "该账户名不存在";
/**
* 100008:登录时发生错误请联系系统管理员
*/
public static String BASE_SYS_ERR_CODE = BASE_CODE + "008";
public static String BASE_SYS_ERR_MSG = "登录时发生错误,请联系系统管理员";
/**
* 100009:权限不足
*/
public static String BASE_NOT_ROLE_CODE = BASE_CODE + "009";
public static String BASE_NOT_ROLE_MSG = "您无权访问该资源";
/**
* 100010:尚未登陆
*/
public static String BASE_NOT_LOGIN_CODE = BASE_CODE + "010";
public static String BASE_NOT_LOGIN_MSG = "您尚未登陆";
/**
* 用户登录发送短信验证码
*/

View File

@ -0,0 +1,161 @@
package com.yexuejc.springboot.base.constant;
/**
* 返回参数code-msg已经sub_code-sub_msg
* <p>IA_xxxx:表示子业务CODE 并且网关code为INS_AUTH</p>
* <p>ACC.xxxx:表示账号相关</p>
* <p>SYS.xxxx:表示系统代码相关</p>
*
* @author maxf
* @version 1.0
* @ClassName RespsCode
* @Description
* @date 2019/1/15 10:34
*/
public enum RespsCode {
/**网关*******************************************************************************************/
/**
* 成功
*/
SUCCESS("10000", "请求成功"),
/**
* 服务不可用
*/
SRV_ERR("20000", "服务不可用"),
/**
* 授权权限不足有权限,但是有问题一般包括授权过期账号异常等
*/
INS_AUTH("20001", "授权权限不足"),
/**
* 缺少必选参数
*/
MIS_PARAM("40001", "缺少必选参数"),
/**
* 业务处理失败,对应业务错误码明细错误码
*/
BIZ_ERR("40004", "业务处理失败"),
/**
* 权限不足没有权限
*/
PERMISSION_DENIED("40006", "权限不足"),
/**
* 系统错误
*/
INTERIOR_BIZ_ERR("99999", "系统错误"),
/**INS_AUTH*******************************************************************************************/
/**
* <pre>
* 20001:INS_AUTH
* ACC.IS_LOCK:该账户已被禁用
* </pre>
*/
IA_IS_LOCK("ACC.IS_LOCK", "该账户已被禁用"),
/**
* <pre>
* 20001:INS_AUTH
* ACC.IS_EXPIRE:该帐户已过期
* </pre>
*/
IA_IS_EXPIRE("ACC.IS_EXPIRE", "该帐户已过期"),
/**
* <pre>
* 20001:INS_AUTH
* ACC.LOGIN_IS_EXPIRE:登陆凭证已经过期请重新登陆
* </pre>
*/
IA_LOGIN_IS_EXPIRE("ACC.LOGIN_IS_EXPIRE", "登陆凭证已经过期,请重新登陆"),
/**
* <pre>
* 20001:INS_AUTH
* ACC.IS_LOCKED:该账户被锁定
* </pre>
*/
IA_IS_LOCKED("ACC.IS_LOCKED", "该账户被锁定"),
/**
* <pre>
* 20001:INS_AUTH
* ACC.CREDENTIALS_NOT_FOUND:身份验证凭证未找到
* </pre>
*/
IA_CREDENTIALS_NOT_FOUND("ACC.CREDENTIALS_NOT_FOUND", "身份验证凭证未找到"),
/**BIZ_ERR*******************************************************************************************/
/**
* <pre>
* 40004:BIZ_ERR
* ACC.PWD_IS_ERR:密码错误
* </pre>
*/
BE_PWD_IS_ERR("ACC.PWD_IS_ERR", "密码错误"),
/**
* <pre>
* 40004:BIZ_ERR
* ACC.NOT_FOUND:该账户名不存在
* </pre>
*/
BE_NOT_FOUND("ACC.NOT_FOUND", "该账户名不存在"),
/**
* <pre>
* 40004:BIZ_ERR
* SYS.GATEWAY:网关异常
* </pre>
*/
BE_GATEWAY("SYS.GATEWAY", "网关异常"),
/**
* <pre>
* 40004:BIZ_ERR
* BIZ.IMG_FAIL:图片异常
* </pre>
*/
BE_IMG_FAIL("BIZ.IMG_FAIL", "图片异常"),
/**
* <pre>
* 40004:BIZ_ERR
* ACC.LOGIN_AUTH:登录授权异常
* </pre>
*/
BE_LOGIN_AUTH("ACC.LOGIN_AUTH", "登录授权异常"),
/**PERMISSION_DENIED*******************************************************************************************/
/**
* <pre>
* 40006:PERMISSION_DENIED
* ACC.NOT_LOGIN:未登录时访问需要权限的接口
* </pre>
*/
PD_NOT_LOGIN("ACC.NOT_LOGIN", "您尚未登陆"),
/**
* <pre>
* 40006:PERMISSION_DENIED
* ACC.NOT_AUTH:用户缺少权限
* </pre>
*/
PD_NOT_AUTH("ACC.NOT_AUTH", "用户缺少权限"),
/**INTERIOR_BIZ_ERR*******************************************************************************************/
/**
* <pre>
* 99999:INTERIOR_BIZ_ERR
* SYS.CONVERT_EXP:类转换异常
* </pre>
*/
IBE_CONVERT_EXP("SYS.CONVERT_EXP", "类转换异常");
/**
* code
*/
public String code;
/**
* 信息
*/
public String msg;
RespsCode(String code, String msg) {
this.code = code;
this.msg = msg;
}
}

View File

@ -0,0 +1,70 @@
package com.yexuejc.springboot.base.exception;
import com.yexuejc.springboot.base.constant.RespsCode;
/**
* 异常基类
*
* <p>1.里面必须实现网关异常消息</p>
* <p>2.业务消息先取subCode取不到会取respsSubCode</p>
* <p>3.设置message为消息自定义message优先获取取不到会取respsSubCode带的message</p>
* <p>4.respsSubCode和subCode都不存在即没有sub_code(如果有message会替换网关message)</p>
*
* @author maxf
* @version 1.0
* @ClassName BasicException
* @Description
* @date 2019/1/15 11:52
*/
public abstract class BasicException extends RuntimeException {
private static final long serialVersionUID = 8720020350158032819L;
/**
* 网关错误
*/
protected RespsCode code;
/**
* 业务错误
*/
protected RespsCode respsSubCode;
/**
* 自定义业务code
* <p>可以在respsSubCode中定义枚举也可以直接传入subCodemessage会获取异常message</p>
*/
protected String subCode;
public BasicException setSubCode(String subCode) {
this.subCode = subCode;
return this;
}
public BasicException() {
super();
}
public BasicException(String message) {
super(message);
}
public BasicException(String message, Throwable cause) {
super(message, cause);
}
public BasicException(String subCode, String message) {
super(message);
this.subCode = subCode;
}
public BasicException(String subCode, String message, Throwable cause) {
super(message, cause);
this.subCode = subCode;
}
public BasicException(Throwable cause) {
super(cause);
}
protected BasicException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) {
super(message, cause, enableSuppression, writableStackTrace);
}
}

View File

@ -0,0 +1,49 @@
package com.yexuejc.springboot.base.exception;
import com.yexuejc.springboot.base.constant.RespsCode;
/**
* 类型转换异常
* <p>INTERIOR_BIZ_ERR("99999", "系统错误")</p>
* <p>IBE_CONVERT_EXP("SYS.CONVERT_EXP", "类转换异常")</p>
*
* @author: maxf
* @date: 2018/5/12 18:36
*/
public class ClassConvertException extends BasicException {
private static final long serialVersionUID = -2390195902982826130L;
{
this.code = RespsCode.INTERIOR_BIZ_ERR;
this.respsSubCode = RespsCode.IBE_CONVERT_EXP;
}
public ClassConvertException() {
super();
}
public ClassConvertException(String message) {
super(message);
}
public ClassConvertException(String message, Throwable cause) {
super(message, cause);
}
public ClassConvertException(String subCode, String message) {
super(subCode, message);
}
public ClassConvertException(String subCode, String message, Throwable cause) {
super(subCode, message, cause);
}
public ClassConvertException(Throwable cause) {
super(cause);
}
protected ClassConvertException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) {
super(message, cause, enableSuppression, writableStackTrace);
}
}

View File

@ -1,24 +0,0 @@
package com.yexuejc.springboot.base.exception;
/**
* 类型转换异常
*
* @author: maxf
* @date: 2018/5/12 18:36
*/
public class ClassConvertExeption extends RuntimeException {
private static final long serialVersionUID = -2390195902982826130L;
/**
* 错误码
*/
private String code = "E";
public ClassConvertExeption() {
super("类型转换异常");
}
public ClassConvertExeption(String message) {
super(message);
}
}

View File

@ -1,24 +1,49 @@
package com.yexuejc.springboot.base.exception;
import com.yexuejc.springboot.base.constant.RespsCode;
/**
* 网关异常
* 网关异常 : 包含网关加解密校验等
* <p>BIZ_ERR("40004", "业务处理失败")</p>
* <p>BE_GATEWAY("SYS.GATEWAY", "网关异常")</p>
*
* @author: maxf
* @date: 2018/5/12 18:36
*/
public class GatewayException extends RuntimeException {
public class GatewayException extends BasicException {
private static final long serialVersionUID = -2390195902982826130L;
/**
* 错误码
*/
private String code = "E";
{
this.code = RespsCode.BIZ_ERR;
this.respsSubCode = RespsCode.BE_GATEWAY;
}
public GatewayException() {
super("数据错误");
super();
}
public GatewayException(String message) {
super(message);
}
public GatewayException(String message, Throwable cause) {
super(message, cause);
}
public GatewayException(String subCode, String message) {
super(subCode, message);
}
public GatewayException(String subCode, String message, Throwable cause) {
super(subCode, message, cause);
}
public GatewayException(Throwable cause) {
super(cause);
}
protected GatewayException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) {
super(message, cause, enableSuppression, writableStackTrace);
}
}

View File

@ -0,0 +1,95 @@
package com.yexuejc.springboot.base.exception;
import com.yexuejc.base.util.StrUtil;
import com.yexuejc.springboot.base.constant.RespsCode;
import com.yexuejc.springboot.base.http.ResponseParams;
import com.yexuejc.springboot.base.util.LogUtil;
import org.springframework.beans.ConversionNotSupportedException;
import org.springframework.beans.TypeMismatchException;
import org.springframework.http.HttpStatus;
import org.springframework.http.converter.HttpMessageNotReadableException;
import org.springframework.http.converter.HttpMessageNotWritableException;
import org.springframework.security.core.AuthenticationException;
import org.springframework.validation.BindException;
import org.springframework.web.HttpMediaTypeNotAcceptableException;
import org.springframework.web.HttpMediaTypeNotSupportedException;
import org.springframework.web.HttpRequestMethodNotSupportedException;
import org.springframework.web.bind.MethodArgumentNotValidException;
import org.springframework.web.bind.MissingPathVariableException;
import org.springframework.web.bind.MissingServletRequestParameterException;
import org.springframework.web.bind.ServletRequestBindingException;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.ResponseStatus;
import org.springframework.web.context.request.async.AsyncRequestTimeoutException;
import org.springframework.web.multipart.support.MissingServletRequestPartException;
import org.springframework.web.servlet.NoHandlerFoundException;
/**
* 全局异常处理
* <p>处理成 response:200 返回</p>
*
* @author maxf
* @version 1.0
* @ClassName GlobalExceptionHandler
* @date 2018/12/26 17:49
*/
@ControllerAdvice
public class GlobalExceptionHandler {
/**
* 出现异常时用于返回Json数据
*
* @param e
* @return
*/
@ExceptionHandler({
Throwable.class,
HttpRequestMethodNotSupportedException.class,
HttpMediaTypeNotSupportedException.class,
HttpMediaTypeNotAcceptableException.class,
MissingPathVariableException.class,
MissingServletRequestParameterException.class,
ServletRequestBindingException.class,
ConversionNotSupportedException.class,
TypeMismatchException.class,
HttpMessageNotReadableException.class,
HttpMessageNotWritableException.class,
MethodArgumentNotValidException.class,
MissingServletRequestPartException.class,
BindException.class,
NoHandlerFoundException.class,
AsyncRequestTimeoutException.class,
NullPointerException.class,
AuthenticationException.class
})
@ResponseBody
@ResponseStatus(HttpStatus.OK)
public ResponseParams jsonErrorHandler(Throwable e) {
LogUtil.exceptionLogger.error("", e);
if (e instanceof BasicException) {
//自定义异常
BasicException exp = (BasicException) e;
String msg = StrUtil.isNotEmpty(exp.getMessage()) ? exp.getMessage() :
exp.respsSubCode != null ? exp.respsSubCode.msg : exp.code.msg;
ResponseParams responseParams = new ResponseParams();
responseParams.setCode(exp.code);
responseParams.setSubCode(StrUtil.isNotEmpty(exp.subCode) ? exp.subCode :
exp.respsSubCode != null ? exp.respsSubCode.code : null);
if (StrUtil.isEmpty(responseParams.getSubCode())) {
responseParams.setMsg(msg);
} else {
responseParams.setSubMsg(msg);
}
return responseParams;
} else if (e instanceof HttpRequestMethodNotSupportedException) {
return ResponseParams.resps(RespsCode.INTERIOR_BIZ_ERR);
} else if (e instanceof HttpMessageNotReadableException) {
return ResponseParams.resps(RespsCode.MIS_PARAM);
}
return ResponseParams.resps(RespsCode.INTERIOR_BIZ_ERR);
}
}

View File

@ -1,24 +1,52 @@
package com.yexuejc.springboot.base.exception;
public class ImageException extends RuntimeException {
import com.yexuejc.springboot.base.constant.RespsCode;
/**
* 图片异常
* <p>BIZ_ERR("40004", "业务处理失败")</p>
* <p>BE_IMG_FAIL("BIZ.IMG_FAIL", "图片异常")</p>
*
* @author maxf
* @version 1.0
* @ClassName ImageException
* @Description
* @date 2019/1/15 13:54
*/
public class ImageException extends BasicException {
private static final long serialVersionUID = -2390195902982826130L;
private String code = "E";
{
this.code = RespsCode.BIZ_ERR;
this.respsSubCode = RespsCode.BE_IMG_FAIL;
}
public ImageException() {
super("图片异常");
super();
}
public ImageException(String message) {
super(message);
}
public ImageException(String msg, Throwable t) {
super(msg, t);
public ImageException(String message, Throwable cause) {
super(message, cause);
}
public ImageException(String code, String msg, Throwable t) {
super(msg, t);
this.code = code;
public ImageException(String subCode, String message) {
super(subCode, message);
}
public ImageException(String subCode, String message, Throwable cause) {
super(subCode, message, cause);
}
public ImageException(Throwable cause) {
super(cause);
}
protected ImageException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) {
super(message, cause, enableSuppression, writableStackTrace);
}
}

View File

@ -0,0 +1,48 @@
package com.yexuejc.springboot.base.exception;
import static com.yexuejc.springboot.base.constant.RespsCode.MIS_PARAM;
/**
* 参数错误
*
* @author maxf
* @version 1.0
* @ClassName ParamsException
* @Description
* @date 2019/1/15 15:44
*/
public class ParamsException extends BasicException {
private static final long serialVersionUID = 4645399726493530751L;
{
this.code = MIS_PARAM;
}
public ParamsException() {
super();
}
public ParamsException(String message) {
super(message);
}
public ParamsException(String message, Throwable cause) {
super(message, cause);
}
public ParamsException(String subCode, String message) {
super(subCode, message);
}
public ParamsException(String subCode, String message, Throwable cause) {
super(subCode, message, cause);
}
public ParamsException(Throwable cause) {
super(cause);
}
protected ParamsException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) {
super(message, cause, enableSuppression, writableStackTrace);
}
}

View File

@ -1,42 +1,46 @@
package com.yexuejc.springboot.base.exception;
import org.springframework.security.core.AuthenticationException;
import com.yexuejc.springboot.base.constant.RespsCode;
/**
* 第三方授权异常
* <p>BIZ_ERR("40004", "业务处理失败")</p>
* <p>BE_LOGIN_AUTH("ACC.LOGIN_AUTH", "登录授权异常")</p>
*
* @author: maxf
* @date: 2018/5/27 19:20
*/
public class ThirdPartyAuthorizationException extends AuthenticationException {
/**
* 错误码
*/
private String code = "E";
public ThirdPartyAuthorizationException(String msg, Throwable t) {
super(msg, t);
}
public ThirdPartyAuthorizationException(String msg) {
super(msg);
public class ThirdPartyAuthorizationException extends BasicException {
{
this.code = RespsCode.BIZ_ERR;
this.respsSubCode = RespsCode.BE_LOGIN_AUTH;
}
public ThirdPartyAuthorizationException() {
super("授权异常");
super();
}
public ThirdPartyAuthorizationException(Throwable t) {
super("授权异常", t);
}
public ThirdPartyAuthorizationException(String code, String message) {
public ThirdPartyAuthorizationException(String message) {
super(message);
this.code = code;
}
public ThirdPartyAuthorizationException(String code, String msg, Throwable t) {
super(msg, t);
this.code = code;
public ThirdPartyAuthorizationException(String message, Throwable cause) {
super(message, cause);
}
public ThirdPartyAuthorizationException(String subCode, String message) {
super(subCode, message);
}
public ThirdPartyAuthorizationException(String subCode, String message, Throwable cause) {
super(subCode, message, cause);
}
public ThirdPartyAuthorizationException(Throwable cause) {
super(cause);
}
protected ThirdPartyAuthorizationException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) {
super(message, cause, enableSuppression, writableStackTrace);
}
}

View File

@ -1,9 +1,10 @@
package com.yexuejc.springboot.base.exception;
import org.springframework.security.core.AuthenticationException;
import com.yexuejc.springboot.base.constant.RespsCode;
/**
* 用户无权限
* <p>PERMISSION_DENIED("40006", "权限不足")</p>
*
* @author maxf
* @version 1.0
@ -11,18 +12,39 @@ import org.springframework.security.core.AuthenticationException;
* @Description
* @date 2018/11/20 20:13
*/
public class UserNotAuthoriayException extends AuthenticationException {
public class UserNotAuthoriayException extends BasicException {
private static final long serialVersionUID = 7752594158082817319L;
{
this.code = RespsCode.PERMISSION_DENIED;
this.respsSubCode = RespsCode.PD_NOT_AUTH;
}
public UserNotAuthoriayException() {
super("用户缺少权限");
super();
}
public UserNotAuthoriayException(String msg, Throwable t) {
super(msg, t);
public UserNotAuthoriayException(String message) {
super(message);
}
public UserNotAuthoriayException(String msg) {
super(msg);
public UserNotAuthoriayException(String message, Throwable cause) {
super(message, cause);
}
public UserNotAuthoriayException(String subCode, String message) {
super(subCode, message);
}
public UserNotAuthoriayException(String subCode, String message, Throwable cause) {
super(subCode, message, cause);
}
public UserNotAuthoriayException(Throwable cause) {
super(cause);
}
protected UserNotAuthoriayException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) {
super(message, cause, enableSuppression, writableStackTrace);
}
}

View File

@ -0,0 +1,260 @@
package com.yexuejc.springboot.base.http;
import com.yexuejc.base.util.JsonUtil;
import com.yexuejc.springboot.base.constant.RespsCode;
/**
* 输出加密结果
*
* @author maxf
* @version 1.0
* @ClassName ResponseParams
* @Description
* @date 2018/12/20 16:05
*/
public class ResponseParams {
/**
* 消息
*/
private String msg;
/**
* 业务code
*/
private String code;
/**
* 详细业务code
*/
private String subCode;
/**
* 详细业务msg
*/
private String subMsg;
/**
* 加密业务内容
*/
private Object content;
/**
* 签名
*/
private String sign;
/**
* 秒级时间戳
*/
private Long timestemp;
public ResponseParams() {
}
public ResponseParams(RespsCode respsCode) {
this.code = respsCode.code;
this.msg = respsCode.msg;
}
/**
* 直接new 一个 网关code msg
*
* @param code 网关code
* @param msg 网关msg
* @return
*/
public ResponseParams(String code, String msg) {
this.code = code;
this.msg = msg;
}
/**
* 网关code,msg content
*
* @param respsCode 网关code,msg
* @param content 网关返回内容
*/
public ResponseParams(RespsCode respsCode, Object content) {
this.code = respsCode.code;
this.msg = respsCode.msg;
this.content = content;
}
/**
* 直接new 一个 网关code msg
*
* @param code 网关code
* @param msg 网关msg
* @return
*/
public static ResponseParams resps(String code, String msg) {
return new ResponseParams(code, msg);
}
/**
* 直接new 一个 网关code msg
*
* @param respsCode 网关code,msg
* @return
*/
public static ResponseParams resps(RespsCode respsCode) {
return new ResponseParams(respsCode);
}
/**
* 网关code,msg content
*
* @param respsCode 网关code,msg
* @param content 网关返回内容
*/
public static ResponseParams resps(RespsCode respsCode, Object content) {
return new ResponseParams(respsCode, content);
}
/**
* 网关code,msg+ 业务sub_code,sub_msg
*
* @param respsCode 网关code,msg
* @param subCode 业务sub_code,sub_msg
* @return
*/
public static ResponseParams resps(RespsCode respsCode, RespsCode subCode) {
ResponseParams responseParams = new ResponseParams(respsCode);
responseParams.setSub(subCode);
return responseParams;
}
/**
* 网关code,msg+ 业务sub_code,sub_msg+ content
*
* @param respsCode 网关code,msg
* @param subCode 业务sub_code,sub_msg
* @param content 网关返回内容
* @return
*/
public static ResponseParams resps(RespsCode respsCode, RespsCode subCode, Object content) {
ResponseParams responseParams = new ResponseParams(respsCode, content);
responseParams.setSub(subCode);
return responseParams;
}
/**
* 操作成功
* <p>code: SUCCESS("10000", "请求成功")</p>
*
* @return
*/
public static ResponseParams succ() {
ResponseParams responseParams = new ResponseParams(RespsCode.SUCCESS);
return responseParams;
}
/**
* 业务错误
* <p>code: BIZ_ERR("40004", "业务处理失败")</p>
*
* @param subCode 业务 sub_code
* @param subMsg 业务 sub_msg
* @return
*/
public static ResponseParams fail(String subCode, String subMsg) {
ResponseParams responseParams = new ResponseParams(RespsCode.BIZ_ERR);
responseParams.setSub(subCode, subMsg);
return responseParams;
}
/**
* 系统错误
* <p>code: INTERIOR_BIZ_ERR("99999", "系统错误")</p>
*
* @param subCode 业务 sub_code
* @param subMsg 业务 sub_msg
* @return
*/
public static ResponseParams err(String subCode, String subMsg) {
ResponseParams responseParams = new ResponseParams(RespsCode.INTERIOR_BIZ_ERR);
responseParams.setSub(subCode, subMsg);
return responseParams;
}
public ResponseParams setSub(RespsCode respsCode) {
this.subCode = respsCode.code;
this.subMsg = respsCode.msg;
return this;
}
public ResponseParams setSub(String subCode, String subMsg) {
this.subCode = subCode;
this.subMsg = subMsg;
return this;
}
@Override
public String toString() {
return JsonUtil.obj2Json(this);
}
public String getSubCode() {
return subCode;
}
public ResponseParams setSubCode(String subCode) {
this.subCode = subCode;
return this;
}
public String getSubMsg() {
return subMsg;
}
public ResponseParams setSubMsg(String subMsg) {
this.subMsg = subMsg;
return this;
}
public String getMsg() {
return msg;
}
public ResponseParams setMsg(String msg) {
this.msg = msg;
return this;
}
public String getCode() {
return code;
}
public ResponseParams setCode(String code) {
this.code = code;
return this;
}
public ResponseParams setCode(RespsCode code) {
this.code = code.code;
this.msg = code.msg;
return this;
}
public Object getContent() {
return content;
}
public ResponseParams setContent(Object content) {
this.content = content;
return this;
}
public Long getTimestemp() {
return timestemp;
}
public ResponseParams setTimestemp(Long timestemp) {
this.timestemp = timestemp;
return this;
}
public String getSign() {
return sign;
}
public ResponseParams setSign(String sign) {
this.sign = sign;
return this;
}
}

View File

@ -1,6 +1,7 @@
package com.yexuejc.springboot.base.security;
import com.yexuejc.springboot.base.constant.LogTypeConsts;
import com.yexuejc.springboot.base.exception.ParamsException;
import org.springframework.security.authentication.AuthenticationManager;
import org.springframework.security.authentication.AuthenticationServiceException;
import org.springframework.security.authentication.ProviderManager;
@ -42,15 +43,15 @@ public class ConsumerAuthenticationProcessingFilter extends AbstractAuthenticati
protected static final String SPRING_SECURITY_FORM_SEX_KEY = "sex";
/********************************** 第三方登录时附带信息*************************************/
protected String usernameParameter = SPRING_SECURITY_FORM_USERNAME_KEY;
protected String passwordParameter = SPRING_SECURITY_FORM_PASSWORD_KEY;
protected String logtypeParameter = SPRING_SECURITY_FORM_LOGTYPE_KEY;
protected String openidParameter = SPRING_SECURITY_FORM_OPENID_KEY;
protected String headParameter = SPRING_SECURITY_FORM_HEAD_KEY;
protected String nicknameParameter = SPRING_SECURITY_FORM_NICKNAME_KEY;
protected String sexParameter = SPRING_SECURITY_FORM_SEX_KEY;
protected boolean postOnly = true;
protected boolean reverse = true;
protected String usernameParameter = SPRING_SECURITY_FORM_USERNAME_KEY;
protected String passwordParameter = SPRING_SECURITY_FORM_PASSWORD_KEY;
protected String logtypeParameter = SPRING_SECURITY_FORM_LOGTYPE_KEY;
protected String openidParameter = SPRING_SECURITY_FORM_OPENID_KEY;
protected String headParameter = SPRING_SECURITY_FORM_HEAD_KEY;
protected String nicknameParameter = SPRING_SECURITY_FORM_NICKNAME_KEY;
protected String sexParameter = SPRING_SECURITY_FORM_SEX_KEY;
protected boolean postOnly = true;
protected boolean reverse = true;
// ~ Constructors
// ===================================================================================================
@ -125,7 +126,11 @@ public class ConsumerAuthenticationProcessingFilter extends AbstractAuthenticati
switch (logtype) {
case LogTypeConsts.SMS:
//短信登录
username = obtainUsername(request);
try {
username = obtainUsername(request);
} catch (Exception e) {
throw new ParamsException();
}
smscode = obtainPassword(request);
break;
case LogTypeConsts.QQ:
@ -151,7 +156,11 @@ public class ConsumerAuthenticationProcessingFilter extends AbstractAuthenticati
break;
default:
//默认账号+密码登录
username = obtainUsername(request).trim();
try {
username = obtainUsername(request).trim();
} catch (Exception e) {
throw new ParamsException();
}
password = obtainPassword(request);
break;
}

View File

@ -4,10 +4,11 @@ import com.yexuejc.base.pojo.ApiVO;
import com.yexuejc.base.util.StrUtil;
import com.yexuejc.springboot.base.constant.BizConsts;
import com.yexuejc.springboot.base.constant.LogTypeConsts;
import com.yexuejc.springboot.base.exception.ClassConvertExeption;
import com.yexuejc.springboot.base.exception.ClassConvertException;
import com.yexuejc.springboot.base.exception.ThirdPartyAuthorizationException;
import com.yexuejc.springboot.base.security.inte.User;
import com.yexuejc.springboot.base.security.inte.UserService;
import org.springframework.security.authentication.BadCredentialsException;
import org.springframework.security.authentication.InternalAuthenticationServiceException;
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
import org.springframework.security.authentication.dao.AbstractUserDetailsAuthenticationProvider;
@ -70,7 +71,6 @@ public class ConsumerAuthenticationProvider extends AbstractUserDetailsAuthentic
protected UserDetailsService userDetailsService;
protected final UserService accountView;
public ConsumerAuthenticationProvider(UserDetailsService userDetailsService, UserService accountView) {
// super();
super.setHideUserNotFoundExceptions(false);
@ -104,11 +104,15 @@ public class ConsumerAuthenticationProvider extends AbstractUserDetailsAuthentic
@Override
protected void additionalAuthenticationChecks(UserDetails userDetails, UsernamePasswordAuthenticationToken authentication) throws AuthenticationException {
String requestPwd = authentication.getCredentials().toString();
String requestPwd = null;
try {
requestPwd = authentication.getCredentials().toString();
} catch (Exception e) {
throw new BadCredentialsException("密码错误");
}
if (authentication instanceof ConsumerToken) {
ConsumerToken consumerToken = (ConsumerToken) authentication;
displyAuthenticationChecks(consumerToken, requestPwd, userDetails.getPassword());
}
}
@ -231,7 +235,7 @@ public class ConsumerAuthenticationProvider extends AbstractUserDetailsAuthentic
loadedUser = (UserDetails) obj;
return loadedUser;
} else {
throw new ClassConvertExeption("获取登录用户信息返回结果类型必须是com.yexuejc.springboot.base.security.inte.User实现类" +
throw new ClassConvertException("获取登录用户信息返回结果类型必须是com.yexuejc.springboot.base.security.inte.User实现类" +
"或者org.springframework.security.core.userdetails.UserDetails实现类" +
"或者com.yexuejc.springboot.base.security.ConsumerUser继承类");
}
@ -251,7 +255,7 @@ public class ConsumerAuthenticationProvider extends AbstractUserDetailsAuthentic
loadedUser = (UserDetails) obj;
return loadedUser;
} else {
throw new ClassConvertExeption("获取登录用户信息返回结果类型必须是com.yexuejc.springboot.base.security.inte.User实现类" +
throw new ClassConvertException("获取登录用户信息返回结果类型必须是com.yexuejc.springboot.base.security.inte.User实现类" +
"或者org.springframework.security.core.userdetails.UserDetails实现类" +
"或者com.yexuejc.springboot.base.security.ConsumerUser继承类");
}

View File

@ -1,7 +1,7 @@
package com.yexuejc.springboot.base.security;
import com.yexuejc.base.util.StrUtil;
import com.yexuejc.springboot.base.exception.ClassConvertExeption;
import com.yexuejc.springboot.base.exception.ClassConvertException;
import com.yexuejc.springboot.base.exception.UserNotAuthoriayException;
import com.yexuejc.springboot.base.security.inte.User;
import com.yexuejc.springboot.base.security.inte.UserService;
@ -35,7 +35,7 @@ public class UserDetailsManager extends InMemoryUserDetailsManager {
return loadUser(username);
}
protected ConsumerUser loadUser(String username) throws UsernameNotFoundException{
protected ConsumerUser loadUser(String username) throws UsernameNotFoundException {
Object user = userService.getConsumerByUserName(username);
if (user instanceof User) {
User consumer = (User) user;
@ -57,7 +57,7 @@ public class UserDetailsManager extends InMemoryUserDetailsManager {
} else if (user instanceof ConsumerUser) {
return (ConsumerUser) user;
} else {
throw new ClassConvertExeption("获取登录用户信息返回结果类型必须是com.yexuejc.springboot.base.security.inte.User实现类" +
throw new ClassConvertException("获取登录用户信息返回结果类型必须是com.yexuejc.springboot.base.security.inte.User实现类" +
"或者com.yexuejc.springboot.base.security.ConsumerUser继承类");
}
}

View File

@ -2,6 +2,8 @@ package com.yexuejc.springboot.base.util;
import com.yexuejc.base.constant.RespsConsts;
import com.yexuejc.base.http.Resps;
import com.yexuejc.springboot.base.constant.RespsCode;
import com.yexuejc.springboot.base.http.ResponseParams;
import org.springframework.http.HttpStatus;
import org.springframework.validation.Errors;
import org.springframework.validation.ObjectError;
@ -28,6 +30,7 @@ public class ValidUtil {
* @param errors
* @return
* @throws IOException
* @since 1.0
*/
public static Resps<Object> errResps(HttpServletResponse response, Errors errors) throws IOException {
List<ObjectError> objectErrorList = errors.getAllErrors();
@ -39,4 +42,21 @@ public class ValidUtil {
return Resps.error(RespsConsts.CODE_VALIDATION, err);
}
/**
* 参数加密使用 检查SpringMVC提交是否有数据校验错误如果有错则直接response错误信息
*
* @param errors
* @return
* @throws IOException
* @since 2.0
*/
public static ResponseParams errResps2( Errors errors) {
List<ObjectError> objectErrorList = errors.getAllErrors();
StringBuffer sb = new StringBuffer();
for (int i = 0; i < objectErrorList.size(); i++) {
sb.append(i + 1 + ":" + objectErrorList.get(i).getDefaultMessage() + ";");
}
return ResponseParams.resps(RespsCode.MIS_PARAM.code, sb.toString().substring(0, sb.length() - 1));
}
}

View File

@ -4,5 +4,6 @@ com.yexuejc.springboot.base.autoconfigure.OssAutoConfiguration,\
com.yexuejc.springboot.base.autoconfigure.MutiRedisAutoConfiguration,\
com.yexuejc.springboot.base.filter.ParamsRequestBodyAdvice,\
com.yexuejc.springboot.base.filter.ParamsResponseBodyAdvice,\
com.yexuejc.springboot.base.autoconfigure.MnsAutoConfiguration
com.yexuejc.springboot.base.autoconfigure.MnsAutoConfiguration,\
com.yexuejc.springboot.base.exception.GlobalExceptionHandler

View File

@ -1,6 +1,5 @@
package com.yexuejc.springboot.base.security;
import com.yexuejc.base.constant.RespsConsts;
import com.yexuejc.base.http.Resps;
import com.yexuejc.base.util.JsonUtil;
import com.yexuejc.base.util.JwtUtil;
@ -8,8 +7,8 @@ import com.yexuejc.base.util.RegexUtil;
import com.yexuejc.base.util.StrUtil;
import com.yexuejc.springboot.base.autoconfigure.MutiRedisAutoConfiguration;
import com.yexuejc.springboot.base.constant.BizConsts;
import com.yexuejc.springboot.base.exception.ThirdPartyAuthorizationException;
import com.yexuejc.springboot.base.exception.UserNotAuthoriayException;
import com.yexuejc.springboot.base.constant.RespsCode;
import com.yexuejc.springboot.base.http.ResponseParams;
import com.yexuejc.springboot.base.security.inte.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
@ -112,27 +111,23 @@ public class MySecurityConfig extends SecurityConfig {
filter.setAuthenticationFailureHandler((request, response, exception) -> {
response.setContentType("application/json;charset=UTF-8");
response.setStatus(HttpStatus.UNAUTHORIZED.value());
Resps resps = new Resps();
ResponseParams resps;
if (exception instanceof DisabledException) {
resps.setErr(RespsConsts.CODE_FAIL, new String[]{BizConsts.BASE_IS_LOCK_MSG});
resps = ResponseParams.resps(RespsCode.INS_AUTH).setSub(RespsCode.IA_IS_LOCK);
} else if (exception instanceof AccountExpiredException) {
resps.setErr(RespsConsts.CODE_FAIL, new String[]{BizConsts.BASE_IS_EXPIRE_MSG});
resps = ResponseParams.resps(RespsCode.INS_AUTH).setSub(RespsCode.IA_IS_EXPIRE);
} else if (exception instanceof CredentialsExpiredException) {
resps.setErr(BizConsts.BASE_LOGIN_IS_EXPIRE_CODE, new String[]{BizConsts.BASE_LOGIN_IS_EXPIRE_MSG});
resps = ResponseParams.resps(RespsCode.INS_AUTH).setSub(RespsCode.IA_LOGIN_IS_EXPIRE);
} else if (exception instanceof LockedException) {
resps.setErr(RespsConsts.CODE_FAIL, new String[]{BizConsts.BASE_IS_LOCKED_MSG});
resps = ResponseParams.resps(RespsCode.INS_AUTH).setSub(RespsCode.IA_IS_LOCKED);
} else if (exception instanceof AuthenticationCredentialsNotFoundException) {
resps.setErr(RespsConsts.CODE_FAIL, new String[]{BizConsts.BASE_CREDENTIALS_NOT_FOUND_MSG});
} else if (exception instanceof ThirdPartyAuthorizationException) {
resps.setErr(RespsConsts.CODE_FAIL, new String[]{exception.getMessage()});
resps = ResponseParams.resps(RespsCode.INS_AUTH).setSub(RespsCode.IA_CREDENTIALS_NOT_FOUND);
} else if (exception instanceof BadCredentialsException) {
resps.setErr(RespsConsts.CODE_FAIL, new String[]{BizConsts.BASE_PWD_IS_ERR_MSG});
resps = ResponseParams.resps(RespsCode.BIZ_ERR).setSub(RespsCode.BE_PWD_IS_ERR);
} else if (exception instanceof UsernameNotFoundException) {
resps.setErr(RespsConsts.CODE_FAIL, new String[]{BizConsts.BASE_ACCOUNT_NOT_FOUND_MSG});
} else if (exception instanceof UserNotAuthoriayException) {
resps.setErr(RespsConsts.CODE_FAIL, new String[]{exception.getMessage()});
resps = ResponseParams.resps(RespsCode.BIZ_ERR).setSub(RespsCode.BE_NOT_FOUND);
} else {
resps.setErr(RespsConsts.CODE_FAIL, new String[]{BizConsts.BASE_SYS_ERR_MSG});
resps = ResponseParams.resps(RespsCode.INS_AUTH);
}
response.getWriter().write(JsonUtil.obj2Json(resps));
response.getWriter().close();
@ -171,10 +166,7 @@ public class MySecurityConfig extends SecurityConfig {
response.setContentType("application/json;charset=UTF-8");
response.setStatus(401);
response.getWriter().write(
JsonUtil.obj2Json(
Resps.error(RespsConsts.CODE_FAIL, new String[]{BizConsts.BASE_NOT_LOGIN_MSG})
)
);
ResponseParams.resps(RespsCode.PERMISSION_DENIED, RespsCode.PD_NOT_LOGIN).toString());
response.getWriter().close();
});
// 已登录但当前用户没有访问的某个接口的权限时的处理
@ -182,10 +174,7 @@ public class MySecurityConfig extends SecurityConfig {
response.setContentType("application/json;charset=UTF-8");
response.setStatus(401);
response.getWriter().write(
JsonUtil.obj2Json(
Resps.error(RespsConsts.CODE_FAIL, new String[]{BizConsts.BASE_NOT_ROLE_MSG})
)
);
ResponseParams.resps(RespsCode.PERMISSION_DENIED, RespsCode.PD_NOT_LOGIN).toString());
response.getWriter().close();
});
}

View File

@ -1,5 +1,5 @@
server.port=8888
spring.application.name=@pom.artifactId@
spring.application.name=yexuejc-springboot-parent
#log
logging.level.root=info
@ -11,22 +11,22 @@ yexuejc.http.filter.type=1
yexuejc.http.encrypt.encrypt=true
yexuejc.http.encrypt.decrypt=true
#配置密钥方式
#<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Կ<EFBFBD><EFBFBD>ʽ
#yexuejc.http.encrypt.private-key=MIIBVAIBADANBgkqhkiG9w0BAQEFAASCAT4wggE6AgEAAkEAiSo5blJ9-QJ0_QElcy5AaRTq-3oO4lJ8PvIOIt-Xr5SUFODVj3DUbiy6_0bxQYO3NiYHlXPb37UVV3jjlXJsXwIDAQABAkBE0WOJH2hGs93gRl_0vwLf9ffDfkTTdlER_73p70aad3QZRslEkinQH7G5aE_DgBm5m72TCeH-PD2FZ2lwtavBAiEAvnRown5Lpqbl0tN_OUxr_e1u9d_-8dNL_JEETO7BZCECIQC4XtY-18j0bVVLxaXPjKQ00D59yntwObihDNyRK0nAfwIgHPHEGgrnpGQo-Wl7JFIg925mNqfcLxRVsAS6CpcefQECIQCUsLdsmy6QIhTmNRJSXoSXq1KatE_05DhIekzwLs8eFQIgfMawMiu52ZxBI5_pZ7ancQZ6Dsxl45utFqJShzV1pio
#yexuejc.http.encrypt.public-key=MFwwDQYJKoZIhvcNAQEBBQADSwAwSAJBAIkqOW5SffkCdP0BJXMuQGkU6vt6DuJSfD7yDiLfl6-UlBTg1Y9w1G4suv9G8UGDtzYmB5Vz29-1FVd445VybF8CAwEAAQ
#配置证书方式
#<EFBFBD><EFBFBD><EFBFBD><EFBFBD>֤<EFBFBD>ʽ
yexuejc.http.encrypt.private-key-path=/lgfishing.keystore
yexuejc.http.encrypt.private-alias=lgfishing
yexuejc.http.encrypt.private-pwd=lgfishing2018
#编码
#<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
spring.http.encoding.force=true
spring.http.encoding.charset=UTF-8
spring.http.encoding.enabled=true
server.tomcat.uri-encoding=UTF-8
#是否开启HTTPSSSL请求证书验证忽略默认false
#<EFBFBD>Ƿ<EFBFBD><EFBFBD><EFBFBD>HTTPS<EFBFBD><EFBFBD>SSL<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>֤<EFBFBD><EFBFBD><EFBFBD><EFBFBD>֤<EFBFBD><EFBFBD><EFBFBD>ԣ<EFBFBD>Ĭ<EFBFBD><EFBFBD>false
yexuejc.enable.ssl-ignore=true
@ -48,14 +48,14 @@ yexuejc.alibaba.oss.bucket=guansichou
#========================================================================================================================
# security相关
# security<EFBFBD><EFBFBD><EFBFBD>
#reids
#开启指定redis库db0默认开启
#<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ָ<EFBFBD><EFBFBD>redis<EFBFBD><EFBFBD>db0Ĭ<EFBFBD>Ͽ<EFBFBD><EFBFBD><EFBFBD>
yexuejc.redis.db1=true
spring.redis.jedis.pool.max-active=100
spring.redis.jedis.pool.max-idle=10
spring.redis.jedis.pool.min-idle=3
spring.redis.host=121.42.165.89
spring.redis.host=103.45.101.109
spring.redis.password=
spring.redis.port=16379
@ -75,19 +75,19 @@ spring.datasource.data=classpath:db/data.sql
#========================================================================================================================
#mybatis-plus
mybatis-plus.mapper-locations=classpath*:mapper/*.xml
#实体扫描多个package用逗号或者分号分隔
#ʵ<EFBFBD><EFBFBD>ɨ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>package<EFBFBD>ö<EFBFBD><EFBFBD>Ż<EFBFBD><EFBFBD>߷ֺŷָ<EFBFBD>
mybatis-plus.type-aliases-package=com.yexuejc.springboot.base.security.domain
#主键类型0:"数据库ID自增", 1:"用户输入ID",2:"该类型为未设置主键类型", 3:"全局唯一ID UUID",4:全局唯一ID (UUID),5:字符串全局唯一ID (idWorker 的字符串表示);
#<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>0:"<22><><EFBFBD>ݿ<EFBFBD>ID<49><44><EFBFBD><EFBFBD>", 1:"<22>û<EFBFBD><C3BB><EFBFBD><EFBFBD><EFBFBD>ID",2:"<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊδ<CEAA><CEB4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>", 3:"ȫ<><C8AB>ΨһID UUID",4:ȫ<><C8AB>ΨһID (UUID),5:<3A>ַ<EFBFBD><D6B7><EFBFBD>ȫ<EFBFBD><C8AB>ΨһID (idWorker <20><><EFBFBD>ַ<EFBFBD><D6B7><EFBFBD><EFBFBD><EFBFBD>ʾ);
mybatis-plus.global-config.db-config.id-type=uuid
mybatis-plus.global-config.db-config.db-type=POSTGRE_SQL
#字段策略 0:"忽略判断",1:"非 NULL 判断"),2:"非空判断"
#<EFBFBD>ֶβ<EFBFBD><EFBFBD><EFBFBD> 0:"<22><><EFBFBD><EFBFBD><EFBFBD>ж<EFBFBD>",1:"<22><> NULL <20>ж<EFBFBD>"),2:"<22>ǿ<EFBFBD><C7BF>ж<EFBFBD>"
mybatis-plus.global-config.db-config.field-strategy=not_empty
#驼峰下划线转换
#<EFBFBD>շ<EFBFBD><EFBFBD>»<EFBFBD><EFBFBD><EFBFBD>ת<EFBFBD><EFBFBD>
mybatis-plus.global-config.db-config.column-underline=true
#逻辑删除配置下面3个配置
#<EFBFBD>߼<EFBFBD>ɾ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ã<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>3<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ã<EFBFBD>
mybatis-plus.global-config.db-config.logic-delete-value=true
mybatis-plus.global-config.db-config.logic-not-delete-value=false
#配置返回数据库(column下划线命名&&返回java实体是驼峰命名)自动匹配无需as没开启这个SQL需要写as select user_id as userId
#<EFBFBD><EFBFBD><EFBFBD>÷<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݿ<EFBFBD>(column<6D>»<EFBFBD><C2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>&&<26><><EFBFBD><EFBFBD>javaʵ<61><CAB5><EFBFBD><EFBFBD><EFBFBD>շ<EFBFBD><D5B7><EFBFBD><EFBFBD><EFBFBD>)<29><><EFBFBD>Զ<EFBFBD>ƥ<EFBFBD><C6A5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>as<61><73>û<EFBFBD><C3BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>SQL<51><4C>Ҫдas<61><73> select user_id as userId<49><64>
mybatis-plus.configuration.map-underscore-to-camel-case=true
mybatis-plus.configuration.cache-enabled=false
#========================================================================================================================