mirror of
https://github.com/chillzhuang/blade-tool
synced 2025-01-11 15:35:38 +08:00
🎉 2.3.0.RELEASE
This commit is contained in:
parent
33473b7356
commit
e08a94f934
@ -5,7 +5,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>org.springblade</groupId>
|
<groupId>org.springblade</groupId>
|
||||||
<artifactId>blade-tool</artifactId>
|
<artifactId>blade-tool</artifactId>
|
||||||
<version>2.2.3</version>
|
<version>2.3.0</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
@ -115,7 +115,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>mysql</groupId>
|
<groupId>mysql</groupId>
|
||||||
<artifactId>mysql-connector-java</artifactId>
|
<artifactId>mysql-connector-java</artifactId>
|
||||||
<scope>runtime</scope>
|
<version>8.0.15</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<!-- PostgreSql -->
|
<!-- PostgreSql -->
|
||||||
<!--<dependency>
|
<!--<dependency>
|
||||||
|
@ -15,13 +15,11 @@
|
|||||||
*/
|
*/
|
||||||
package org.springblade.core.boot.config;
|
package org.springblade.core.boot.config;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
|
|
||||||
import com.baomidou.mybatisplus.extension.injector.LogicSqlInjector;
|
import com.baomidou.mybatisplus.extension.injector.LogicSqlInjector;
|
||||||
import com.baomidou.mybatisplus.extension.plugins.PaginationInterceptor;
|
import com.baomidou.mybatisplus.extension.plugins.PaginationInterceptor;
|
||||||
import com.baomidou.mybatisplus.extension.plugins.PerformanceInterceptor;
|
import com.baomidou.mybatisplus.extension.plugins.PerformanceInterceptor;
|
||||||
import org.mybatis.spring.annotation.MapperScan;
|
import org.mybatis.spring.annotation.MapperScan;
|
||||||
import org.springblade.core.launch.constant.AppConstant;
|
import org.springblade.core.launch.constant.AppConstant;
|
||||||
import org.springblade.core.mp.BladeMetaObjectHandler;
|
|
||||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
@ -42,11 +40,6 @@ public class MybatisPlusConfiguration {
|
|||||||
return new PaginationInterceptor();
|
return new PaginationInterceptor();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Bean
|
|
||||||
public MetaObjectHandler metaObjectHandler() {
|
|
||||||
return new BladeMetaObjectHandler();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
public LogicSqlInjector logicSqlInjector() {
|
public LogicSqlInjector logicSqlInjector() {
|
||||||
return new LogicSqlInjector();
|
return new LogicSqlInjector();
|
||||||
@ -58,7 +51,7 @@ public class MybatisPlusConfiguration {
|
|||||||
* @return PerformanceInterceptor
|
* @return PerformanceInterceptor
|
||||||
*/
|
*/
|
||||||
@Bean
|
@Bean
|
||||||
@Profile({AppConstant.DEV_CDOE, AppConstant.TEST_CODE})
|
@Profile({AppConstant.DEV_CODE, AppConstant.TEST_CODE})
|
||||||
public PerformanceInterceptor performanceInterceptor() {
|
public PerformanceInterceptor performanceInterceptor() {
|
||||||
return new PerformanceInterceptor();
|
return new PerformanceInterceptor();
|
||||||
}
|
}
|
||||||
|
@ -5,6 +5,7 @@ import org.aspectj.lang.ProceedingJoinPoint;
|
|||||||
import org.aspectj.lang.annotation.Around;
|
import org.aspectj.lang.annotation.Around;
|
||||||
import org.aspectj.lang.annotation.Aspect;
|
import org.aspectj.lang.annotation.Aspect;
|
||||||
import org.aspectj.lang.reflect.MethodSignature;
|
import org.aspectj.lang.reflect.MethodSignature;
|
||||||
|
import org.springblade.core.launch.constant.AppConstant;
|
||||||
import org.springblade.core.tool.jackson.JsonUtil;
|
import org.springblade.core.tool.jackson.JsonUtil;
|
||||||
import org.springblade.core.tool.utils.BeanUtil;
|
import org.springblade.core.tool.utils.BeanUtil;
|
||||||
import org.springblade.core.tool.utils.ClassUtil;
|
import org.springblade.core.tool.utils.ClassUtil;
|
||||||
@ -35,7 +36,7 @@ import java.util.concurrent.TimeUnit;
|
|||||||
@Slf4j
|
@Slf4j
|
||||||
@Aspect
|
@Aspect
|
||||||
@Configuration
|
@Configuration
|
||||||
@Profile({"dev", "test"})
|
@Profile({AppConstant.DEV_CODE, AppConstant.TEST_CODE})
|
||||||
public class RequestLogAspect {
|
public class RequestLogAspect {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -54,19 +55,42 @@ public class RequestLogAspect {
|
|||||||
MethodSignature ms = (MethodSignature) point.getSignature();
|
MethodSignature ms = (MethodSignature) point.getSignature();
|
||||||
Method method = ms.getMethod();
|
Method method = ms.getMethod();
|
||||||
Object[] args = point.getArgs();
|
Object[] args = point.getArgs();
|
||||||
|
// 请求参数处理
|
||||||
final Map<String, Object> paraMap = new HashMap<>(16);
|
final Map<String, Object> paraMap = new HashMap<>(16);
|
||||||
for (int i = 0; i < args.length; i++) {
|
for (int i = 0; i < args.length; i++) {
|
||||||
|
// 读取方法参数
|
||||||
MethodParameter methodParam = ClassUtil.getMethodParameter(method, i);
|
MethodParameter methodParam = ClassUtil.getMethodParameter(method, i);
|
||||||
|
// PathVariable 参数跳过
|
||||||
PathVariable pathVariable = methodParam.getParameterAnnotation(PathVariable.class);
|
PathVariable pathVariable = methodParam.getParameterAnnotation(PathVariable.class);
|
||||||
if (pathVariable != null) {
|
if (pathVariable != null) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
RequestBody requestBody = methodParam.getParameterAnnotation(RequestBody.class);
|
RequestBody requestBody = methodParam.getParameterAnnotation(RequestBody.class);
|
||||||
Object object = args[i];
|
Object value = args[i];
|
||||||
// 如果是body的json则是对象
|
// 如果是body的json则是对象
|
||||||
if (requestBody != null && object != null) {
|
if (requestBody != null && value != null) {
|
||||||
paraMap.putAll(BeanUtil.toMap(object));
|
paraMap.putAll(BeanUtil.toMap(value));
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
// 处理 List
|
||||||
|
if (value instanceof List) {
|
||||||
|
value = ((List) value).get(0);
|
||||||
|
}
|
||||||
|
// 处理 参数
|
||||||
|
if (value instanceof HttpServletRequest) {
|
||||||
|
paraMap.putAll(((HttpServletRequest) value).getParameterMap());
|
||||||
|
} else if (value instanceof WebRequest) {
|
||||||
|
paraMap.putAll(((WebRequest) value).getParameterMap());
|
||||||
|
} else if (value instanceof MultipartFile) {
|
||||||
|
MultipartFile multipartFile = (MultipartFile) value;
|
||||||
|
String name = multipartFile.getName();
|
||||||
|
String fileName = multipartFile.getOriginalFilename();
|
||||||
|
paraMap.put(name, fileName);
|
||||||
|
} else if (value instanceof HttpServletResponse) {
|
||||||
|
} else if (value instanceof InputStream) {
|
||||||
|
} else if (value instanceof InputStreamSource) {
|
||||||
} else {
|
} else {
|
||||||
|
// 参数名
|
||||||
RequestParam requestParam = methodParam.getParameterAnnotation(RequestParam.class);
|
RequestParam requestParam = methodParam.getParameterAnnotation(RequestParam.class);
|
||||||
String paraName;
|
String paraName;
|
||||||
if (requestParam != null && StringUtil.isNotBlank(requestParam.value())) {
|
if (requestParam != null && StringUtil.isNotBlank(requestParam.value())) {
|
||||||
@ -74,74 +98,61 @@ public class RequestLogAspect {
|
|||||||
} else {
|
} else {
|
||||||
paraName = methodParam.getParameterName();
|
paraName = methodParam.getParameterName();
|
||||||
}
|
}
|
||||||
paraMap.put(paraName, object);
|
paraMap.put(paraName, value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
HttpServletRequest request = WebUtil.getRequest();
|
HttpServletRequest request = WebUtil.getRequest();
|
||||||
String requestURI = request.getRequestURI();
|
String requestURI = Objects.requireNonNull(request).getRequestURI();
|
||||||
String requestMethod = request.getMethod();
|
String requestMethod = request.getMethod();
|
||||||
// 处理 参数
|
|
||||||
List<String> needRemoveKeys = new ArrayList<>(paraMap.size());
|
|
||||||
paraMap.forEach((key, value) -> {
|
|
||||||
if (value instanceof HttpServletRequest) {
|
|
||||||
needRemoveKeys.add(key);
|
|
||||||
paraMap.putAll(((HttpServletRequest) value).getParameterMap());
|
|
||||||
} else if (value instanceof HttpServletResponse) {
|
|
||||||
needRemoveKeys.add(key);
|
|
||||||
} else if (value instanceof InputStream) {
|
|
||||||
needRemoveKeys.add(key);
|
|
||||||
} else if (value instanceof MultipartFile) {
|
|
||||||
String fileName = ((MultipartFile) value).getOriginalFilename();
|
|
||||||
paraMap.put(key, fileName);
|
|
||||||
} else if (value instanceof InputStreamSource) {
|
|
||||||
needRemoveKeys.add(key);
|
|
||||||
} else if (value instanceof WebRequest) {
|
|
||||||
needRemoveKeys.add(key);
|
|
||||||
paraMap.putAll(((WebRequest) value).getParameterMap());
|
|
||||||
}
|
|
||||||
});
|
|
||||||
needRemoveKeys.forEach(paraMap::remove);
|
|
||||||
|
|
||||||
// 构建成一条长 日志,避免并发下日志错乱
|
// 构建成一条长 日志,避免并发下日志错乱
|
||||||
StringBuilder logBuilder = new StringBuilder(500);
|
StringBuilder beforeReqLog = new StringBuilder(300);
|
||||||
// 日志参数
|
// 日志参数
|
||||||
List<Object> logArgs = new ArrayList<>();
|
List<Object> beforeReqArgs = new ArrayList<>();
|
||||||
logBuilder.append("\n\n================ Request Start ================\n");
|
beforeReqLog.append("\n\n================ Request Start ================\n");
|
||||||
// 打印请求
|
// 打印路由
|
||||||
|
beforeReqLog.append("===> {}: {}");
|
||||||
|
beforeReqArgs.add(requestMethod);
|
||||||
|
beforeReqArgs.add(requestURI);
|
||||||
|
// 请求参数
|
||||||
if (paraMap.isEmpty()) {
|
if (paraMap.isEmpty()) {
|
||||||
logBuilder.append("===> {}: {}\n");
|
beforeReqLog.append("\n");
|
||||||
logArgs.add(requestMethod);
|
|
||||||
logArgs.add(requestURI);
|
|
||||||
} else {
|
} else {
|
||||||
logBuilder.append("===> {}: {} Parameters: {}\n");
|
beforeReqLog.append(" Parameters: {}\n");
|
||||||
logArgs.add(requestMethod);
|
beforeReqArgs.add(JsonUtil.toJson(paraMap));
|
||||||
logArgs.add(requestURI);
|
|
||||||
logArgs.add(JsonUtil.toJson(paraMap));
|
|
||||||
}
|
}
|
||||||
// 打印请求头
|
// 打印请求头
|
||||||
Enumeration<String> headers = request.getHeaderNames();
|
Enumeration<String> headers = request.getHeaderNames();
|
||||||
while (headers.hasMoreElements()) {
|
while (headers.hasMoreElements()) {
|
||||||
String headerName = headers.nextElement();
|
String headerName = headers.nextElement();
|
||||||
String headerValue = request.getHeader(headerName);
|
String headerValue = request.getHeader(headerName);
|
||||||
logBuilder.append("===headers=== {} : {}\n");
|
beforeReqLog.append("===Headers=== {} : {}\n");
|
||||||
logArgs.add(headerName);
|
beforeReqArgs.add(headerName);
|
||||||
logArgs.add(headerValue);
|
beforeReqArgs.add(headerValue);
|
||||||
}
|
}
|
||||||
|
beforeReqLog.append("================ Request End ================\n");
|
||||||
// 打印执行时间
|
// 打印执行时间
|
||||||
long startNs = System.nanoTime();
|
long startNs = System.nanoTime();
|
||||||
|
log.info(beforeReqLog.toString(), beforeReqArgs.toArray());
|
||||||
|
// aop 执行后的日志
|
||||||
|
StringBuilder afterReqLog = new StringBuilder(200);
|
||||||
|
// 日志参数
|
||||||
|
List<Object> afterReqArgs = new ArrayList<>();
|
||||||
|
afterReqLog.append("\n\n================ Response Start ================\n");
|
||||||
try {
|
try {
|
||||||
Object result = point.proceed();
|
Object result = point.proceed();
|
||||||
logBuilder.append("===Result=== {}\n");
|
// 打印返回结构体
|
||||||
logArgs.add(JsonUtil.toJson(result));
|
afterReqLog.append("===Result=== {}\n");
|
||||||
|
afterReqArgs.add(JsonUtil.toJson(result));
|
||||||
return result;
|
return result;
|
||||||
} finally {
|
} finally {
|
||||||
long tookMs = TimeUnit.NANOSECONDS.toMillis(System.nanoTime() - startNs);
|
long tookMs = TimeUnit.NANOSECONDS.toMillis(System.nanoTime() - startNs);
|
||||||
logBuilder.append("<=== {}: {} ({} ms)");
|
afterReqLog.append("<=== {}: {} ({} ms)\n");
|
||||||
logArgs.add(requestMethod);
|
afterReqArgs.add(requestMethod);
|
||||||
logArgs.add(requestURI);
|
afterReqArgs.add(requestURI);
|
||||||
logArgs.add(tookMs);
|
afterReqArgs.add(tookMs);
|
||||||
logBuilder.append("\n================ Request End ================\n");
|
afterReqLog.append("================ Response End ================\n");
|
||||||
log.info(logBuilder.toString(), logArgs.toArray());
|
log.info(afterReqLog.toString(), afterReqArgs.toArray());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -62,6 +62,12 @@ public class BladeTenantHandler implements TenantHandler {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public boolean doTableFilter(String tableName) {
|
public boolean doTableFilter(String tableName) {
|
||||||
return (properties.getTables().size() > 0 && !properties.getTables().contains(tableName)) || !properties.getBladeTables().contains(tableName) || StringUtil.isBlank(SecureUtil.getTenantCode());
|
return !(
|
||||||
|
(
|
||||||
|
(properties.getTables().size() > 0 && properties.getTables().contains(tableName))
|
||||||
|
|| properties.getBladeTables().contains(tableName)
|
||||||
|
)
|
||||||
|
&& StringUtil.isNotBlank(SecureUtil.getTenantCode())
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -28,7 +28,7 @@ spring:
|
|||||||
resources:
|
resources:
|
||||||
add-mappings: false
|
add-mappings: false
|
||||||
datasource:
|
datasource:
|
||||||
driver-class-name: com.mysql.jdbc.Driver
|
driver-class-name: com.mysql.cj.jdbc.Driver
|
||||||
hikari:
|
hikari:
|
||||||
connection-test-query: SELECT 1 FROM DUAL
|
connection-test-query: SELECT 1 FROM DUAL
|
||||||
connection-timeout: 30000
|
connection-timeout: 30000
|
||||||
@ -75,7 +75,7 @@ mybatis-plus:
|
|||||||
swagger:
|
swagger:
|
||||||
title: SpringBlade 接口文档系统
|
title: SpringBlade 接口文档系统
|
||||||
description: SpringBlade 接口文档系统
|
description: SpringBlade 接口文档系统
|
||||||
version: 2.0.0
|
version: 2.3.0
|
||||||
license: Powered By SpringBlade
|
license: Powered By SpringBlade
|
||||||
licenseUrl: https://bladex.vip
|
licenseUrl: https://bladex.vip
|
||||||
terms-of-service-url: https://bladex.vip
|
terms-of-service-url: https://bladex.vip
|
||||||
|
@ -77,5 +77,8 @@
|
|||||||
<Logger name="org.springblade" level="DEBUG" />
|
<Logger name="org.springblade" level="DEBUG" />
|
||||||
<Logger name="org.springblade.core.version" level="INFO"/>
|
<Logger name="org.springblade.core.version" level="INFO"/>
|
||||||
|
|
||||||
|
<!-- 减少nacos日志 -->
|
||||||
|
<logger name="com.alibaba.nacos" level="ERROR"/>
|
||||||
|
|
||||||
|
|
||||||
</configuration>
|
</configuration>
|
||||||
|
@ -86,4 +86,7 @@
|
|||||||
<logger name="net.sf.ehcache" level="INFO"/>
|
<logger name="net.sf.ehcache" level="INFO"/>
|
||||||
<logger name="druid.sql" level="INFO"/>
|
<logger name="druid.sql" level="INFO"/>
|
||||||
|
|
||||||
|
<!-- 减少nacos日志 -->
|
||||||
|
<logger name="com.alibaba.nacos" level="ERROR"/>
|
||||||
|
|
||||||
</configuration>
|
</configuration>
|
||||||
|
@ -86,4 +86,7 @@
|
|||||||
<logger name="net.sf.ehcache" level="INFO"/>
|
<logger name="net.sf.ehcache" level="INFO"/>
|
||||||
<logger name="druid.sql" level="INFO"/>
|
<logger name="druid.sql" level="INFO"/>
|
||||||
|
|
||||||
|
<!-- 减少nacos日志 -->
|
||||||
|
<logger name="com.alibaba.nacos" level="ERROR"/>
|
||||||
|
|
||||||
</configuration>
|
</configuration>
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>blade-tool</artifactId>
|
<artifactId>blade-tool</artifactId>
|
||||||
<groupId>org.springblade</groupId>
|
<groupId>org.springblade</groupId>
|
||||||
<version>2.2.3</version>
|
<version>2.3.0</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>blade-tool</artifactId>
|
<artifactId>blade-tool</artifactId>
|
||||||
<groupId>org.springblade</groupId>
|
<groupId>org.springblade</groupId>
|
||||||
<version>2.2.3</version>
|
<version>2.3.0</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
spring.datasource.driver-class-name=com.mysql.jdbc.Driver
|
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
|
||||||
spring.datasource.url=jdbc:mysql://localhost:3306/blade?useSSL=false&useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull&transformedBitIsBoolean=true&tinyInt1isBit=false&serverTimezone=GMT%2B8
|
spring.datasource.url=jdbc:mysql://localhost:3306/blade?useSSL=false&useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull&transformedBitIsBoolean=true&tinyInt1isBit=false&serverTimezone=GMT%2B8
|
||||||
spring.datasource.username=root
|
spring.datasource.username=root
|
||||||
spring.datasource.password=root
|
spring.datasource.password=root
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>blade-tool</artifactId>
|
<artifactId>blade-tool</artifactId>
|
||||||
<groupId>org.springblade</groupId>
|
<groupId>org.springblade</groupId>
|
||||||
<version>2.2.3</version>
|
<version>2.3.0</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
@ -61,7 +61,7 @@ public class BladeApplication {
|
|||||||
// 判断环境:dev、test、prod
|
// 判断环境:dev、test、prod
|
||||||
List<String> profiles = Arrays.asList(activeProfiles);
|
List<String> profiles = Arrays.asList(activeProfiles);
|
||||||
// 预设的环境
|
// 预设的环境
|
||||||
List<String> presetProfiles = new ArrayList<>(Arrays.asList(AppConstant.DEV_CDOE, AppConstant.TEST_CODE, AppConstant.PROD_CODE));
|
List<String> presetProfiles = new ArrayList<>(Arrays.asList(AppConstant.DEV_CODE, AppConstant.TEST_CODE, AppConstant.PROD_CODE));
|
||||||
// 交集
|
// 交集
|
||||||
presetProfiles.retainAll(profiles);
|
presetProfiles.retainAll(profiles);
|
||||||
// 当前使用
|
// 当前使用
|
||||||
@ -71,7 +71,7 @@ public class BladeApplication {
|
|||||||
String profile;
|
String profile;
|
||||||
if (activeProfileList.isEmpty()) {
|
if (activeProfileList.isEmpty()) {
|
||||||
// 默认dev开发
|
// 默认dev开发
|
||||||
profile = AppConstant.DEV_CDOE;
|
profile = AppConstant.DEV_CODE;
|
||||||
activeProfileList.add(profile);
|
activeProfileList.add(profile);
|
||||||
builder.profiles(profile);
|
builder.profiles(profile);
|
||||||
} else if (activeProfileList.size() == 1) {
|
} else if (activeProfileList.size() == 1) {
|
||||||
|
@ -25,7 +25,7 @@ public interface AppConstant {
|
|||||||
/**
|
/**
|
||||||
* 应用版本
|
* 应用版本
|
||||||
*/
|
*/
|
||||||
String APPLICATION_VERSION = "2.0.0";
|
String APPLICATION_VERSION = "2.3.0";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 基础包
|
* 基础包
|
||||||
@ -76,7 +76,7 @@ public interface AppConstant {
|
|||||||
/**
|
/**
|
||||||
* 开发环境
|
* 开发环境
|
||||||
*/
|
*/
|
||||||
String DEV_CDOE = "dev";
|
String DEV_CODE = "dev";
|
||||||
/**
|
/**
|
||||||
* 生产环境
|
* 生产环境
|
||||||
*/
|
*/
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>blade-tool</artifactId>
|
<artifactId>blade-tool</artifactId>
|
||||||
<groupId>org.springblade</groupId>
|
<groupId>org.springblade</groupId>
|
||||||
<version>2.2.3</version>
|
<version>2.3.0</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
@ -33,7 +33,7 @@ public class ServiceException extends RuntimeException {
|
|||||||
|
|
||||||
public ServiceException(String message) {
|
public ServiceException(String message) {
|
||||||
super(message);
|
super(message);
|
||||||
this.resultCode = ResultCode.INTERNAL_SERVER_ERROR;
|
this.resultCode = ResultCode.FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ServiceException(IResultCode resultCode) {
|
public ServiceException(IResultCode resultCode) {
|
||||||
|
@ -16,7 +16,6 @@
|
|||||||
package org.springblade.core.log.feign;
|
package org.springblade.core.log.feign;
|
||||||
|
|
||||||
import org.springblade.core.launch.constant.AppConstant;
|
import org.springblade.core.launch.constant.AppConstant;
|
||||||
import org.springblade.core.log.feign.fallback.ILogClientHystric;
|
|
||||||
import org.springblade.core.log.model.LogApi;
|
import org.springblade.core.log.model.LogApi;
|
||||||
import org.springblade.core.log.model.LogUsual;
|
import org.springblade.core.log.model.LogUsual;
|
||||||
import org.springblade.core.log.model.LogError;
|
import org.springblade.core.log.model.LogError;
|
||||||
@ -32,7 +31,7 @@ import org.springframework.web.bind.annotation.RequestBody;
|
|||||||
*/
|
*/
|
||||||
@FeignClient(
|
@FeignClient(
|
||||||
value = AppConstant.APPLICATION_LOG_NAME,
|
value = AppConstant.APPLICATION_LOG_NAME,
|
||||||
fallback = ILogClientHystric.class
|
fallback = LogClientFallback.class
|
||||||
)
|
)
|
||||||
public interface ILogClient {
|
public interface ILogClient {
|
||||||
|
|
||||||
@ -41,8 +40,8 @@ public interface ILogClient {
|
|||||||
/**
|
/**
|
||||||
* 保存错误日志
|
* 保存错误日志
|
||||||
*
|
*
|
||||||
* @param log
|
* @param log 日志实体
|
||||||
* @return
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
@PostMapping(API_PREFIX + "/saveUsualLog")
|
@PostMapping(API_PREFIX + "/saveUsualLog")
|
||||||
R<Boolean> saveUsualLog(@RequestBody LogUsual log);
|
R<Boolean> saveUsualLog(@RequestBody LogUsual log);
|
||||||
@ -50,8 +49,8 @@ public interface ILogClient {
|
|||||||
/**
|
/**
|
||||||
* 保存操作日志
|
* 保存操作日志
|
||||||
*
|
*
|
||||||
* @param log
|
* @param log 日志实体
|
||||||
* @return
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
@PostMapping(API_PREFIX + "/saveApiLog")
|
@PostMapping(API_PREFIX + "/saveApiLog")
|
||||||
R<Boolean> saveApiLog(@RequestBody LogApi log);
|
R<Boolean> saveApiLog(@RequestBody LogApi log);
|
||||||
@ -59,8 +58,8 @@ public interface ILogClient {
|
|||||||
/**
|
/**
|
||||||
* 保存错误日志
|
* 保存错误日志
|
||||||
*
|
*
|
||||||
* @param log
|
* @param log 日志实体
|
||||||
* @return
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
@PostMapping(API_PREFIX + "/saveErrorLog")
|
@PostMapping(API_PREFIX + "/saveErrorLog")
|
||||||
R<Boolean> saveErrorLog(@RequestBody LogError log);
|
R<Boolean> saveErrorLog(@RequestBody LogError log);
|
||||||
|
@ -1,8 +1,6 @@
|
|||||||
package org.springblade.core.log.feign.fallback;
|
package org.springblade.core.log.feign;
|
||||||
|
|
||||||
import com.alibaba.fastjson.JSON;
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springblade.core.log.feign.ILogClient;
|
|
||||||
import org.springblade.core.log.model.LogApi;
|
import org.springblade.core.log.model.LogApi;
|
||||||
import org.springblade.core.log.model.LogError;
|
import org.springblade.core.log.model.LogError;
|
||||||
import org.springblade.core.log.model.LogUsual;
|
import org.springblade.core.log.model.LogUsual;
|
||||||
@ -10,29 +8,26 @@ import org.springblade.core.tool.api.R;
|
|||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @Auther: jiang
|
* 日志fallback
|
||||||
* @Date: 2019/04/26 23:04
|
*
|
||||||
|
* @author jiang
|
||||||
*/
|
*/
|
||||||
@Component
|
|
||||||
@Slf4j
|
@Slf4j
|
||||||
public class ILogClientHystric implements ILogClient {
|
@Component
|
||||||
|
public class LogClientFallback implements ILogClient {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public R<Boolean> saveUsualLog(LogUsual log) {
|
public R<Boolean> saveUsualLog(LogUsual log) {
|
||||||
//注:这里如果使用log.toString()来打印日志的话,只能打印出该对象自身的属性值,无法输出父类的属性值
|
|
||||||
this.log.error("usual log send fail:{}", JSON.toJSONString(log));
|
|
||||||
return R.fail("usual log send fail");
|
return R.fail("usual log send fail");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public R<Boolean> saveApiLog(LogApi log) {
|
public R<Boolean> saveApiLog(LogApi log) {
|
||||||
this.log.error("api log send fail:{}", JSON.toJSONString(log));
|
|
||||||
return R.fail("api log send fail");
|
return R.fail("api log send fail");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public R<Boolean> saveErrorLog(LogError log) {
|
public R<Boolean> saveErrorLog(LogError log) {
|
||||||
this.log.error("error log send fail:{}", JSON.toJSONString(log));
|
|
||||||
return R.fail("error log send fail");
|
return R.fail("error log send fail");
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -20,23 +20,16 @@ import com.baomidou.mybatisplus.annotation.IdType;
|
|||||||
import com.baomidou.mybatisplus.annotation.TableId;
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import org.springblade.core.launch.props.BladeProperties;
|
|
||||||
import org.springblade.core.launch.server.ServerInfo;
|
|
||||||
import org.springblade.core.secure.utils.SecureUtil;
|
|
||||||
import org.springblade.core.tool.utils.DateUtil;
|
import org.springblade.core.tool.utils.DateUtil;
|
||||||
import org.springblade.core.tool.utils.StringPool;
|
|
||||||
import org.springblade.core.tool.utils.UrlUtil;
|
|
||||||
import org.springblade.core.tool.utils.WebUtil;
|
|
||||||
import org.springframework.format.annotation.DateTimeFormat;
|
import org.springframework.format.annotation.DateTimeFormat;
|
||||||
|
|
||||||
import javax.servlet.http.HttpServletRequest;
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* logApi、logError、logUsual的父类,拥有相同的属性值
|
* logApi、logError、logUsual的父类,拥有相同的属性值
|
||||||
* @Auther: jiang
|
*
|
||||||
* @Date: 2019/04/26 23:00
|
* @author jiang
|
||||||
*/
|
*/
|
||||||
@Data
|
@Data
|
||||||
public class LogAbstract implements Serializable {
|
public class LogAbstract implements Serializable {
|
||||||
|
@ -25,12 +25,7 @@ import org.springblade.core.tool.utils.UrlUtil;
|
|||||||
import org.springblade.core.tool.utils.WebUtil;
|
import org.springblade.core.tool.utils.WebUtil;
|
||||||
|
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import java.net.InetAddress;
|
|
||||||
import java.net.NetworkInterface;
|
|
||||||
import java.net.ServerSocket;
|
|
||||||
import java.net.UnknownHostException;
|
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import java.util.Enumeration;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* INet 相关工具
|
* INet 相关工具
|
||||||
@ -41,8 +36,9 @@ public class LogAbstractUtil {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 向log中添加补齐request的信息
|
* 向log中添加补齐request的信息
|
||||||
* @param request
|
*
|
||||||
* @param logAbstract
|
* @param request 请求
|
||||||
|
* @param logAbstract 日志基础类
|
||||||
*/
|
*/
|
||||||
public static void addRequestInfoToLog(HttpServletRequest request, LogAbstract logAbstract) {
|
public static void addRequestInfoToLog(HttpServletRequest request, LogAbstract logAbstract) {
|
||||||
logAbstract.setRemoteIp(WebUtil.getIP(request));
|
logAbstract.setRemoteIp(WebUtil.getIP(request));
|
||||||
@ -55,9 +51,10 @@ public class LogAbstractUtil {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 向log中添加补齐其他的信息(eg:blade、server等)
|
* 向log中添加补齐其他的信息(eg:blade、server等)
|
||||||
* @param logAbstract
|
*
|
||||||
* @param bladeProperties
|
* @param logAbstract 日志基础类
|
||||||
* @param serverInfo
|
* @param bladeProperties 配置信息
|
||||||
|
* @param serverInfo 服务信息
|
||||||
*/
|
*/
|
||||||
public static void addOtherInfoToLog(LogAbstract logAbstract, BladeProperties bladeProperties, ServerInfo serverInfo) {
|
public static void addOtherInfoToLog(LogAbstract logAbstract, BladeProperties bladeProperties, ServerInfo serverInfo) {
|
||||||
logAbstract.setServiceId(bladeProperties.getName());
|
logAbstract.setServiceId(bladeProperties.getName());
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>blade-tool</artifactId>
|
<artifactId>blade-tool</artifactId>
|
||||||
<groupId>org.springblade</groupId>
|
<groupId>org.springblade</groupId>
|
||||||
<version>2.2.3</version>
|
<version>2.3.0</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>blade-tool</artifactId>
|
<artifactId>blade-tool</artifactId>
|
||||||
<groupId>org.springblade</groupId>
|
<groupId>org.springblade</groupId>
|
||||||
<version>2.2.3</version>
|
<version>2.3.0</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>blade-tool</artifactId>
|
<artifactId>blade-tool</artifactId>
|
||||||
<groupId>org.springblade</groupId>
|
<groupId>org.springblade</groupId>
|
||||||
<version>2.2.3</version>
|
<version>2.3.0</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
@ -53,7 +53,7 @@ public class SwaggerProperties {
|
|||||||
/**
|
/**
|
||||||
* 版本
|
* 版本
|
||||||
**/
|
**/
|
||||||
private String version = "2.0.0";
|
private String version = "2.3.0";
|
||||||
/**
|
/**
|
||||||
* 许可证
|
* 许可证
|
||||||
**/
|
**/
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>org.springblade</groupId>
|
<groupId>org.springblade</groupId>
|
||||||
<artifactId>blade-tool</artifactId>
|
<artifactId>blade-tool</artifactId>
|
||||||
<version>2.2.3</version>
|
<version>2.3.0</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
14
pom.xml
14
pom.xml
@ -5,7 +5,7 @@
|
|||||||
|
|
||||||
<groupId>org.springblade</groupId>
|
<groupId>org.springblade</groupId>
|
||||||
<artifactId>blade-tool</artifactId>
|
<artifactId>blade-tool</artifactId>
|
||||||
<version>2.2.3</version>
|
<version>2.3.0</version>
|
||||||
<packaging>pom</packaging>
|
<packaging>pom</packaging>
|
||||||
<name>blade-tool</name>
|
<name>blade-tool</name>
|
||||||
<description>
|
<description>
|
||||||
@ -36,23 +36,23 @@
|
|||||||
</scm>
|
</scm>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<blade.tool.version>2.2.3</blade.tool.version>
|
<blade.tool.version>2.3.0</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>
|
||||||
<swagger.version>2.9.2</swagger.version>
|
<swagger.version>2.9.2</swagger.version>
|
||||||
<swagger.models.version>1.5.21</swagger.models.version>
|
<swagger.models.version>1.5.21</swagger.models.version>
|
||||||
<swagger.bootstrapui.version>1.9.2</swagger.bootstrapui.version>
|
<swagger.bootstrapui.version>1.9.3</swagger.bootstrapui.version>
|
||||||
<mybatis.plus.version>3.1.0</mybatis.plus.version>
|
<mybatis.plus.version>3.1.0</mybatis.plus.version>
|
||||||
<curator.framework.version>4.0.1</curator.framework.version>
|
<curator.framework.version>4.0.1</curator.framework.version>
|
||||||
<protostuff.version>1.6.0</protostuff.version>
|
<protostuff.version>1.6.0</protostuff.version>
|
||||||
<disruptor.version>3.4.2</disruptor.version>
|
<disruptor.version>3.4.2</disruptor.version>
|
||||||
<spring.boot.admin.version>2.0.2</spring.boot.admin.version>
|
<spring.boot.admin.version>2.1.4</spring.boot.admin.version>
|
||||||
<mica.auto.version>1.0.1</mica.auto.version>
|
<mica.auto.version>1.0.1</mica.auto.version>
|
||||||
<alibaba.cloud.version>0.2.1.RELEASE</alibaba.cloud.version>
|
<alibaba.cloud.version>0.9.0.RELEASE</alibaba.cloud.version>
|
||||||
|
|
||||||
<spring.boot.version>2.0.8.RELEASE</spring.boot.version>
|
<spring.boot.version>2.1.4.RELEASE</spring.boot.version>
|
||||||
<spring.cloud.version>Finchley.SR2</spring.cloud.version>
|
<spring.cloud.version>Greenwich.SR1</spring.cloud.version>
|
||||||
<spring.platform.version>Cairo-SR7</spring.platform.version>
|
<spring.platform.version>Cairo-SR7</spring.platform.version>
|
||||||
|
|
||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
|
Loading…
Reference in New Issue
Block a user