mirror of
https://github.com/chillzhuang/blade-tool
synced 2024-12-12 20:29:27 +08:00
🎉 RC4
This commit is contained in:
parent
884007a2e4
commit
99cd987b8c
@ -133,8 +133,8 @@ public class BladeController {
|
|||||||
* @param msg 消息
|
* @param msg 消息
|
||||||
* @return R
|
* @return R
|
||||||
*/
|
*/
|
||||||
public R failure(String msg) {
|
public R fail(String msg) {
|
||||||
return R.failure(msg);
|
return R.fail(msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1 +0,0 @@
|
|||||||
restart.include.blade-core-boot=/blade-core-boot[\\w-]+\.jar
|
|
@ -1,7 +0,0 @@
|
|||||||
org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
|
|
||||||
org.springblade.core.boot.config.MybatisPlusConfiguration,\
|
|
||||||
org.springblade.core.boot.logger.RequestLogAspect,\
|
|
||||||
org.springblade.core.boot.config.RetryConfiguration,\
|
|
||||||
org.springblade.core.boot.config.BladeWebMvcConfiguration,\
|
|
||||||
org.springblade.core.boot.config.BladeBootAutoConfiguration,\
|
|
||||||
org.springblade.core.boot.config.RedisTemplateConfiguration
|
|
@ -1 +0,0 @@
|
|||||||
restart.include.blade-core-launch=/blade-core-launch[\\w-]+\.jar
|
|
@ -1,4 +0,0 @@
|
|||||||
org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
|
|
||||||
org.springblade.core.launch.config.BladeLaunchConfiguration,\
|
|
||||||
org.springblade.core.launch.StartEventListener,\
|
|
||||||
org.springblade.core.launch.config.BladeConsulServiceRegistryConfiguration
|
|
@ -43,10 +43,10 @@ public class BladeErrorAttributes extends DefaultErrorAttributes {
|
|||||||
R result;
|
R result;
|
||||||
if (error == null) {
|
if (error == null) {
|
||||||
log.error("URL:{} error status:{}", requestUri, status);
|
log.error("URL:{} error status:{}", requestUri, status);
|
||||||
result = R.failure(ResultCode.FAILURE, "系统未知异常[HttpStatus]:" + status);
|
result = R.fail(ResultCode.FAILURE, "系统未知异常[HttpStatus]:" + status);
|
||||||
} else {
|
} else {
|
||||||
log.error(String.format("URL:%s error status:%d", requestUri, status), error);
|
log.error(String.format("URL:%s error status:%d", requestUri, status), error);
|
||||||
result = R.failure(status, error.getMessage());
|
result = R.fail(status, error.getMessage());
|
||||||
}
|
}
|
||||||
//发送服务异常事件
|
//发送服务异常事件
|
||||||
ErrorLogPublisher.publishEvent(error, requestUri);
|
ErrorLogPublisher.publishEvent(error, requestUri);
|
||||||
|
@ -66,7 +66,7 @@ public class BladeRestExceptionTranslator {
|
|||||||
public R handleError(MissingServletRequestParameterException e) {
|
public R handleError(MissingServletRequestParameterException e) {
|
||||||
log.warn("缺少请求参数", e.getMessage());
|
log.warn("缺少请求参数", e.getMessage());
|
||||||
String message = String.format("缺少必要的请求参数: %s", e.getParameterName());
|
String message = String.format("缺少必要的请求参数: %s", e.getParameterName());
|
||||||
return R.failure(ResultCode.PARAM_MISS, message);
|
return R.fail(ResultCode.PARAM_MISS, message);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ExceptionHandler(MethodArgumentTypeMismatchException.class)
|
@ExceptionHandler(MethodArgumentTypeMismatchException.class)
|
||||||
@ -74,7 +74,7 @@ public class BladeRestExceptionTranslator {
|
|||||||
public R handleError(MethodArgumentTypeMismatchException e) {
|
public R handleError(MethodArgumentTypeMismatchException e) {
|
||||||
log.warn("请求参数格式错误", e.getMessage());
|
log.warn("请求参数格式错误", e.getMessage());
|
||||||
String message = String.format("请求参数格式错误: %s", e.getName());
|
String message = String.format("请求参数格式错误: %s", e.getName());
|
||||||
return R.failure(ResultCode.PARAM_TYPE_ERROR, message);
|
return R.fail(ResultCode.PARAM_TYPE_ERROR, message);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ExceptionHandler(MethodArgumentNotValidException.class)
|
@ExceptionHandler(MethodArgumentNotValidException.class)
|
||||||
@ -94,7 +94,7 @@ public class BladeRestExceptionTranslator {
|
|||||||
private R handleError(BindingResult result) {
|
private R handleError(BindingResult result) {
|
||||||
FieldError error = result.getFieldError();
|
FieldError error = result.getFieldError();
|
||||||
String message = String.format("%s:%s", error.getField(), error.getDefaultMessage());
|
String message = String.format("%s:%s", error.getField(), error.getDefaultMessage());
|
||||||
return R.failure(ResultCode.PARAM_BIND_ERROR, message);
|
return R.fail(ResultCode.PARAM_BIND_ERROR, message);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ExceptionHandler(ConstraintViolationException.class)
|
@ExceptionHandler(ConstraintViolationException.class)
|
||||||
@ -105,49 +105,49 @@ public class BladeRestExceptionTranslator {
|
|||||||
ConstraintViolation<?> violation = violations.iterator().next();
|
ConstraintViolation<?> violation = violations.iterator().next();
|
||||||
String path = ((PathImpl) violation.getPropertyPath()).getLeafNode().getName();
|
String path = ((PathImpl) violation.getPropertyPath()).getLeafNode().getName();
|
||||||
String message = String.format("%s:%s", path, violation.getMessage());
|
String message = String.format("%s:%s", path, violation.getMessage());
|
||||||
return R.failure(ResultCode.PARAM_VALID_ERROR, message);
|
return R.fail(ResultCode.PARAM_VALID_ERROR, message);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ExceptionHandler(NoHandlerFoundException.class)
|
@ExceptionHandler(NoHandlerFoundException.class)
|
||||||
@ResponseStatus(HttpStatus.NOT_FOUND)
|
@ResponseStatus(HttpStatus.NOT_FOUND)
|
||||||
public R handleError(NoHandlerFoundException e) {
|
public R handleError(NoHandlerFoundException e) {
|
||||||
log.error("404没找到请求:{}", e.getMessage());
|
log.error("404没找到请求:{}", e.getMessage());
|
||||||
return R.failure(ResultCode.NOT_FOUND, e.getMessage());
|
return R.fail(ResultCode.NOT_FOUND, e.getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ExceptionHandler(HttpMessageNotReadableException.class)
|
@ExceptionHandler(HttpMessageNotReadableException.class)
|
||||||
@ResponseStatus(HttpStatus.BAD_REQUEST)
|
@ResponseStatus(HttpStatus.BAD_REQUEST)
|
||||||
public R handleError(HttpMessageNotReadableException e) {
|
public R handleError(HttpMessageNotReadableException e) {
|
||||||
log.error("消息不能读取:{}", e.getMessage());
|
log.error("消息不能读取:{}", e.getMessage());
|
||||||
return R.failure(ResultCode.MSG_NOT_READABLE, e.getMessage());
|
return R.fail(ResultCode.MSG_NOT_READABLE, e.getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ExceptionHandler(HttpRequestMethodNotSupportedException.class)
|
@ExceptionHandler(HttpRequestMethodNotSupportedException.class)
|
||||||
@ResponseStatus(HttpStatus.METHOD_NOT_ALLOWED)
|
@ResponseStatus(HttpStatus.METHOD_NOT_ALLOWED)
|
||||||
public R handleError(HttpRequestMethodNotSupportedException e) {
|
public R handleError(HttpRequestMethodNotSupportedException e) {
|
||||||
log.error("不支持当前请求方法:{}", e.getMessage());
|
log.error("不支持当前请求方法:{}", e.getMessage());
|
||||||
return R.failure(ResultCode.METHOD_NOT_SUPPORTED, e.getMessage());
|
return R.fail(ResultCode.METHOD_NOT_SUPPORTED, e.getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ExceptionHandler(HttpMediaTypeNotSupportedException.class)
|
@ExceptionHandler(HttpMediaTypeNotSupportedException.class)
|
||||||
@ResponseStatus(HttpStatus.UNSUPPORTED_MEDIA_TYPE)
|
@ResponseStatus(HttpStatus.UNSUPPORTED_MEDIA_TYPE)
|
||||||
public R handleError(HttpMediaTypeNotSupportedException e) {
|
public R handleError(HttpMediaTypeNotSupportedException e) {
|
||||||
log.error("不支持当前媒体类型:{}", e.getMessage());
|
log.error("不支持当前媒体类型:{}", e.getMessage());
|
||||||
return R.failure(ResultCode.MEDIA_TYPE_NOT_SUPPORTED, e.getMessage());
|
return R.fail(ResultCode.MEDIA_TYPE_NOT_SUPPORTED, e.getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ExceptionHandler(ServiceException.class)
|
@ExceptionHandler(ServiceException.class)
|
||||||
@ResponseStatus(HttpStatus.BAD_REQUEST)
|
@ResponseStatus(HttpStatus.BAD_REQUEST)
|
||||||
public R handleError(ServiceException e) {
|
public R handleError(ServiceException e) {
|
||||||
log.error("业务异常", e);
|
log.error("业务异常", e);
|
||||||
return R.failure(e.getResultCode(), e.getMessage());
|
return R.fail(e.getResultCode(), e.getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ExceptionHandler(SecureException.class)
|
@ExceptionHandler(SecureException.class)
|
||||||
@ResponseStatus(HttpStatus.UNAUTHORIZED)
|
@ResponseStatus(HttpStatus.UNAUTHORIZED)
|
||||||
public R handleError(SecureException e) {
|
public R handleError(SecureException e) {
|
||||||
log.error("认证异常", e);
|
log.error("认证异常", e);
|
||||||
return R.failure(e.getResultCode(), e.getMessage());
|
return R.fail(e.getResultCode(), e.getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ExceptionHandler(Throwable.class)
|
@ExceptionHandler(Throwable.class)
|
||||||
@ -156,7 +156,7 @@ public class BladeRestExceptionTranslator {
|
|||||||
log.error("服务器异常", e);
|
log.error("服务器异常", e);
|
||||||
//发送服务异常事件
|
//发送服务异常事件
|
||||||
ErrorLogPublisher.publishEvent(e, UrlUtil.getPath(WebUtil.getRequest().getRequestURI()));
|
ErrorLogPublisher.publishEvent(e, UrlUtil.getPath(WebUtil.getRequest().getRequestURI()));
|
||||||
return R.failure(ResultCode.INTERNAL_SERVER_ERROR, (Func.isEmpty(e.getMessage()) ? ResultCode.INTERNAL_SERVER_ERROR.getMessage() : e.getMessage()));
|
return R.fail(ResultCode.INTERNAL_SERVER_ERROR, (Func.isEmpty(e.getMessage()) ? ResultCode.INTERNAL_SERVER_ERROR.getMessage() : e.getMessage()));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1 +0,0 @@
|
|||||||
restart.include.blade-core-log=/blade-core-log[\\w-]+\.jar
|
|
@ -1,4 +0,0 @@
|
|||||||
org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
|
|
||||||
org.springblade.core.log.config.BladeLogToolAutoConfiguration,\
|
|
||||||
org.springblade.core.log.config.BladeErrorMvcAutoConfiguration,\
|
|
||||||
org.springblade.core.log.error.BladeRestExceptionTranslator
|
|
@ -44,7 +44,7 @@ public class SecureInterceptor extends HandlerInterceptorAdapter {
|
|||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
log.warn("签名认证失败,请求接口:{},请求IP:{},请求参数:{}", request.getRequestURI(), WebUtil.getIP(request), JsonUtil.toJson(request.getParameterMap()));
|
log.warn("签名认证失败,请求接口:{},请求IP:{},请求参数:{}", request.getRequestURI(), WebUtil.getIP(request), JsonUtil.toJson(request.getParameterMap()));
|
||||||
R result = R.failure(ResultCode.UN_AUTHORIZED);
|
R result = R.fail(ResultCode.UN_AUTHORIZED);
|
||||||
response.setCharacterEncoding(StringPool.UTF_8);
|
response.setCharacterEncoding(StringPool.UTF_8);
|
||||||
response.setHeader("Content-type", MediaType.APPLICATION_JSON_UTF8_VALUE);
|
response.setHeader("Content-type", MediaType.APPLICATION_JSON_UTF8_VALUE);
|
||||||
response.setStatus(HttpServletResponse.SC_OK);
|
response.setStatus(HttpServletResponse.SC_OK);
|
||||||
|
@ -1 +0,0 @@
|
|||||||
restart.include.blade-core-secure=/blade-core-secure[\\w-]+\.jar
|
|
@ -1,3 +0,0 @@
|
|||||||
org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
|
|
||||||
org.springblade.core.secure.config.RegistryConfiguration,\
|
|
||||||
org.springblade.core.secure.config.SecureConfiguration
|
|
@ -1,2 +0,0 @@
|
|||||||
org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
|
|
||||||
org.springblade.core.swagger.SwaggerAutoConfiguration
|
|
@ -171,7 +171,7 @@ public class R<T> implements Serializable {
|
|||||||
* @param <T> T 泛型标记
|
* @param <T> T 泛型标记
|
||||||
* @return R
|
* @return R
|
||||||
*/
|
*/
|
||||||
public static <T> R<T> failure(String msg) {
|
public static <T> R<T> fail(String msg) {
|
||||||
return new R<>(ResultCode.FAILURE, msg);
|
return new R<>(ResultCode.FAILURE, msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -184,7 +184,7 @@ public class R<T> implements Serializable {
|
|||||||
* @param <T> T 泛型标记
|
* @param <T> T 泛型标记
|
||||||
* @return R
|
* @return R
|
||||||
*/
|
*/
|
||||||
public static <T> R<T> failure(int code, String msg) {
|
public static <T> R<T> fail(int code, String msg) {
|
||||||
return new R<>(code, null, msg);
|
return new R<>(code, null, msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -195,7 +195,7 @@ public class R<T> implements Serializable {
|
|||||||
* @param <T> T 泛型标记
|
* @param <T> T 泛型标记
|
||||||
* @return R
|
* @return R
|
||||||
*/
|
*/
|
||||||
public static <T> R<T> failure(IResultCode resultCode) {
|
public static <T> R<T> fail(IResultCode resultCode) {
|
||||||
return new R<>(resultCode);
|
return new R<>(resultCode);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -207,7 +207,7 @@ public class R<T> implements Serializable {
|
|||||||
* @param <T> T 泛型标记
|
* @param <T> T 泛型标记
|
||||||
* @return R
|
* @return R
|
||||||
*/
|
*/
|
||||||
public static <T> R<T> failure(IResultCode resultCode, String msg) {
|
public static <T> R<T> fail(IResultCode resultCode, String msg) {
|
||||||
return new R<>(resultCode, msg);
|
return new R<>(resultCode, msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -218,7 +218,7 @@ public class R<T> implements Serializable {
|
|||||||
* @return R
|
* @return R
|
||||||
*/
|
*/
|
||||||
public static R status(boolean flag) {
|
public static R status(boolean flag) {
|
||||||
return flag ? success(BladeConstant.DEFAULT_SUCCESS_MESSAGE) : failure(BladeConstant.DEFAULT_FAILURE_MESSAGE);
|
return flag ? success(BladeConstant.DEFAULT_SUCCESS_MESSAGE) : fail(BladeConstant.DEFAULT_FAILURE_MESSAGE);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1 +0,0 @@
|
|||||||
restart.include.blade-core-tool=/blade-core-tool[\\w-]+\.jar
|
|
@ -1,4 +0,0 @@
|
|||||||
org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
|
|
||||||
org.springblade.core.tool.config.ToolConfiguration,\
|
|
||||||
org.springblade.core.tool.config.JacksonConfiguration,\
|
|
||||||
org.springblade.core.tool.config.MessageConfiguration
|
|
7
pom.xml
7
pom.xml
@ -36,7 +36,7 @@
|
|||||||
</scm>
|
</scm>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<blade.tool.version>1.0.0-RC3</blade.tool.version>
|
<blade.tool.version>1.0.0-RC4</blade.tool.version>
|
||||||
|
|
||||||
<java.version>1.8</java.version>
|
<java.version>1.8</java.version>
|
||||||
<maven.plugin.version>3.8.0</maven.plugin.version>
|
<maven.plugin.version>3.8.0</maven.plugin.version>
|
||||||
@ -143,6 +143,11 @@
|
|||||||
<artifactId>spring-boot-devtools</artifactId>
|
<artifactId>spring-boot-devtools</artifactId>
|
||||||
<optional>true</optional>
|
<optional>true</optional>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>net.dreamlu</groupId>
|
||||||
|
<artifactId>mica-auto</artifactId>
|
||||||
|
<version>0.0.1</version>
|
||||||
|
</dependency>
|
||||||
<!--<dependency>
|
<!--<dependency>
|
||||||
<groupId>org.springframework</groupId>
|
<groupId>org.springframework</groupId>
|
||||||
<artifactId>spring-context-indexer</artifactId>
|
<artifactId>spring-context-indexer</artifactId>
|
||||||
|
Loading…
Reference in New Issue
Block a user