mirror of
https://github.com/chillzhuang/blade-tool
synced 2024-11-05 10:09:32 +08:00
🎉 RC4
This commit is contained in:
parent
884007a2e4
commit
99cd987b8c
@ -133,8 +133,8 @@ public class BladeController {
|
||||
* @param msg 消息
|
||||
* @return R
|
||||
*/
|
||||
public R failure(String msg) {
|
||||
return R.failure(msg);
|
||||
public R fail(String 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;
|
||||
if (error == null) {
|
||||
log.error("URL:{} error status:{}", requestUri, status);
|
||||
result = R.failure(ResultCode.FAILURE, "系统未知异常[HttpStatus]:" + status);
|
||||
result = R.fail(ResultCode.FAILURE, "系统未知异常[HttpStatus]:" + status);
|
||||
} else {
|
||||
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);
|
||||
|
@ -66,7 +66,7 @@ public class BladeRestExceptionTranslator {
|
||||
public R handleError(MissingServletRequestParameterException e) {
|
||||
log.warn("缺少请求参数", e.getMessage());
|
||||
String message = String.format("缺少必要的请求参数: %s", e.getParameterName());
|
||||
return R.failure(ResultCode.PARAM_MISS, message);
|
||||
return R.fail(ResultCode.PARAM_MISS, message);
|
||||
}
|
||||
|
||||
@ExceptionHandler(MethodArgumentTypeMismatchException.class)
|
||||
@ -74,7 +74,7 @@ public class BladeRestExceptionTranslator {
|
||||
public R handleError(MethodArgumentTypeMismatchException e) {
|
||||
log.warn("请求参数格式错误", e.getMessage());
|
||||
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)
|
||||
@ -94,7 +94,7 @@ public class BladeRestExceptionTranslator {
|
||||
private R handleError(BindingResult result) {
|
||||
FieldError error = result.getFieldError();
|
||||
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)
|
||||
@ -105,49 +105,49 @@ public class BladeRestExceptionTranslator {
|
||||
ConstraintViolation<?> violation = violations.iterator().next();
|
||||
String path = ((PathImpl) violation.getPropertyPath()).getLeafNode().getName();
|
||||
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)
|
||||
@ResponseStatus(HttpStatus.NOT_FOUND)
|
||||
public R handleError(NoHandlerFoundException e) {
|
||||
log.error("404没找到请求:{}", e.getMessage());
|
||||
return R.failure(ResultCode.NOT_FOUND, e.getMessage());
|
||||
return R.fail(ResultCode.NOT_FOUND, e.getMessage());
|
||||
}
|
||||
|
||||
@ExceptionHandler(HttpMessageNotReadableException.class)
|
||||
@ResponseStatus(HttpStatus.BAD_REQUEST)
|
||||
public R handleError(HttpMessageNotReadableException e) {
|
||||
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)
|
||||
@ResponseStatus(HttpStatus.METHOD_NOT_ALLOWED)
|
||||
public R handleError(HttpRequestMethodNotSupportedException e) {
|
||||
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)
|
||||
@ResponseStatus(HttpStatus.UNSUPPORTED_MEDIA_TYPE)
|
||||
public R handleError(HttpMediaTypeNotSupportedException e) {
|
||||
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)
|
||||
@ResponseStatus(HttpStatus.BAD_REQUEST)
|
||||
public R handleError(ServiceException e) {
|
||||
log.error("业务异常", e);
|
||||
return R.failure(e.getResultCode(), e.getMessage());
|
||||
return R.fail(e.getResultCode(), e.getMessage());
|
||||
}
|
||||
|
||||
@ExceptionHandler(SecureException.class)
|
||||
@ResponseStatus(HttpStatus.UNAUTHORIZED)
|
||||
public R handleError(SecureException e) {
|
||||
log.error("认证异常", e);
|
||||
return R.failure(e.getResultCode(), e.getMessage());
|
||||
return R.fail(e.getResultCode(), e.getMessage());
|
||||
}
|
||||
|
||||
@ExceptionHandler(Throwable.class)
|
||||
@ -156,7 +156,7 @@ public class BladeRestExceptionTranslator {
|
||||
log.error("服务器异常", e);
|
||||
//发送服务异常事件
|
||||
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;
|
||||
} else {
|
||||
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.setHeader("Content-type", MediaType.APPLICATION_JSON_UTF8_VALUE);
|
||||
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 泛型标记
|
||||
* @return R
|
||||
*/
|
||||
public static <T> R<T> failure(String msg) {
|
||||
public static <T> R<T> fail(String msg) {
|
||||
return new R<>(ResultCode.FAILURE, msg);
|
||||
}
|
||||
|
||||
@ -184,7 +184,7 @@ public class R<T> implements Serializable {
|
||||
* @param <T> T 泛型标记
|
||||
* @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);
|
||||
}
|
||||
|
||||
@ -195,7 +195,7 @@ public class R<T> implements Serializable {
|
||||
* @param <T> T 泛型标记
|
||||
* @return R
|
||||
*/
|
||||
public static <T> R<T> failure(IResultCode resultCode) {
|
||||
public static <T> R<T> fail(IResultCode resultCode) {
|
||||
return new R<>(resultCode);
|
||||
}
|
||||
|
||||
@ -207,7 +207,7 @@ public class R<T> implements Serializable {
|
||||
* @param <T> T 泛型标记
|
||||
* @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);
|
||||
}
|
||||
|
||||
@ -218,7 +218,7 @@ public class R<T> implements Serializable {
|
||||
* @return R
|
||||
*/
|
||||
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>
|
||||
|
||||
<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>
|
||||
<maven.plugin.version>3.8.0</maven.plugin.version>
|
||||
@ -143,6 +143,11 @@
|
||||
<artifactId>spring-boot-devtools</artifactId>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>net.dreamlu</groupId>
|
||||
<artifactId>mica-auto</artifactId>
|
||||
<version>0.0.1</version>
|
||||
</dependency>
|
||||
<!--<dependency>
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>spring-context-indexer</artifactId>
|
||||
|
Loading…
Reference in New Issue
Block a user