@@ -133,14 +133,14 @@ central-platform -- 父项目,公共依赖
|
||||
<tr>
|
||||
<td><img alt="首页" src="https://gitee.com/zlt2000/images/raw/master/%E9%A6%96%E9%A1%B5.png"/></td>
|
||||
<td><img alt="用户搜索" src="https://gitee.com/zlt2000/images/raw/master/%E7%94%A8%E6%88%B7%E6%90%9C%E7%B4%A2.png"/></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><img alt="日志系统" src="https://gitee.com/zlt2000/images/raw/master/%E6%97%A5%E5%BF%97%E7%B3%BB%E7%BB%9F.png"/></td>
|
||||
<td><img alt="日志链路" src="https://gitee.com/zlt2000/images/raw/master/%E6%97%A5%E5%BF%97%E9%93%BE%E8%B7%AF.png"/></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><img alt="server_metrics" src="https://gitee.com/zlt2000/images/raw/master/server_metrics.png"/></td>
|
||||
<td><img alt="application_metrics" src="https://gitee.com/zlt2000/images/raw/master/application_metrics.png"/></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><img alt="持续集成2" src="https://gitee.com/zlt2000/images/raw/master/%E6%8C%81%E7%BB%AD%E9%9B%86%E6%88%902.png"/></td>
|
||||
<td><img alt="sonar结果" src="https://gitee.com/zlt2000/images/raw/master/sonar%E7%BB%93%E6%9E%9C.png"/></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><img alt="skywalking首页.png" src="https://gitee.com/zlt2000/images/raw/master/skywalking%E9%A6%96%E9%A1%B5.png"/></td>
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>com.zlt</groupId>
|
||||
<artifactId>central-platform</artifactId>
|
||||
<version>5.1.0</version>
|
||||
<version>5.2.0</version>
|
||||
<packaging>pom</packaging>
|
||||
|
||||
<properties>
|
||||
@@ -14,12 +14,9 @@
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<java.version>8</java.version>
|
||||
<spring-cloud-alibaba-dependencies.version>2021.1</spring-cloud-alibaba-dependencies.version>
|
||||
<spring-boot-dependencies.version>2.5.7</spring-boot-dependencies.version>
|
||||
<spring-boot-dependencies.version>2.5.9</spring-boot-dependencies.version>
|
||||
<spring-cloud-dependencies.version>2020.0.4</spring-cloud-dependencies.version>
|
||||
<commons-collections4.version>4.4</commons-collections4.version>
|
||||
<swagger.version>2.9.2</swagger.version>
|
||||
<swagger.ui.version>1.8.7</swagger.ui.version>
|
||||
<swagger.mg.ui.version>1.0.6</swagger.mg.ui.version>
|
||||
<swagger.butler.version>2.0.1</swagger.butler.version>
|
||||
<jjwt.version>0.9.1</jjwt.version>
|
||||
<druid-starter>1.2.6</druid-starter>
|
||||
@@ -29,13 +26,13 @@
|
||||
<security-jwt.version>1.1.0.RELEASE</security-jwt.version>
|
||||
<redisson-starter.version>3.16.1</redisson-starter.version>
|
||||
<easyCaptcha.version>1.6.2</easyCaptcha.version>
|
||||
<hutool.version>5.1.4</hutool.version>
|
||||
<hutool.version>5.7.20</hutool.version>
|
||||
<mybatis-plus-boot-starter.version>3.4.0</mybatis-plus-boot-starter.version>
|
||||
<aliyun-sdk-oss>3.8.1</aliyun-sdk-oss>
|
||||
<qiniu-java-sdk>7.2.28</qiniu-java-sdk>
|
||||
<easypoi.version>4.1.3</easypoi.version>
|
||||
<poi.version>4.1.1</poi.version>
|
||||
<spring-boot-admin.version>2.5.1</spring-boot-admin.version>
|
||||
<spring-boot-admin.version>2.5.5</spring-boot-admin.version>
|
||||
<velocity.version>1.7</velocity.version>
|
||||
<commons-configuration2.version>2.7</commons-configuration2.version>
|
||||
<txlcn.version>5.0.2.RELEASE</txlcn.version>
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<parent>
|
||||
<groupId>com.zlt</groupId>
|
||||
<artifactId>zlt-business</artifactId>
|
||||
<version>5.1.0</version>
|
||||
<version>5.2.0</version>
|
||||
</parent>
|
||||
<artifactId>code-generator</artifactId>
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<parent>
|
||||
<groupId>com.zlt</groupId>
|
||||
<artifactId>zlt-business</artifactId>
|
||||
<version>5.1.0</version>
|
||||
<version>5.2.0</version>
|
||||
</parent>
|
||||
<artifactId>file-center</artifactId>
|
||||
<description>文件中心</description>
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<parent>
|
||||
<groupId>com.zlt</groupId>
|
||||
<artifactId>central-platform</artifactId>
|
||||
<version>5.1.0</version>
|
||||
<version>5.2.0</version>
|
||||
</parent>
|
||||
<artifactId>zlt-business</artifactId>
|
||||
<description>业务中心</description>
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<parent>
|
||||
<groupId>com.zlt</groupId>
|
||||
<artifactId>zlt-business</artifactId>
|
||||
<version>5.1.0</version>
|
||||
<version>5.2.0</version>
|
||||
</parent>
|
||||
<artifactId>search-center</artifactId>
|
||||
<description>搜索中心</description>
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<parent>
|
||||
<groupId>com.zlt</groupId>
|
||||
<artifactId>search-center</artifactId>
|
||||
<version>5.1.0</version>
|
||||
<version>5.2.0</version>
|
||||
</parent>
|
||||
<artifactId>search-client</artifactId>
|
||||
<description>搜索中心客户端</description>
|
||||
|
||||
+4
-2
@@ -2,8 +2,6 @@ package com.central.search.model;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
@@ -31,6 +29,10 @@ public class SearchDto implements Serializable {
|
||||
* 排序字段
|
||||
*/
|
||||
private String sortCol;
|
||||
/**
|
||||
* 排序顺序
|
||||
*/
|
||||
private String sortOrder = "DESC";
|
||||
/**
|
||||
* 是否显示高亮
|
||||
*/
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<parent>
|
||||
<groupId>com.zlt</groupId>
|
||||
<artifactId>search-center</artifactId>
|
||||
<version>5.1.0</version>
|
||||
<version>5.2.0</version>
|
||||
</parent>
|
||||
<artifactId>search-server</artifactId>
|
||||
<description>搜索中心服务端</description>
|
||||
|
||||
+1
-1
@@ -35,7 +35,7 @@ public class SearchServiceImpl implements ISearchService {
|
||||
public PageResult<JsonNode> strQuery(String indexName, SearchDto searchDto) throws IOException {
|
||||
return SearchBuilder.builder(client, indexName)
|
||||
.setStringQuery(searchDto.getQueryStr())
|
||||
.addSort(searchDto.getSortCol(), SortOrder.DESC)
|
||||
.addSort(searchDto.getSortCol(), searchDto.getSortOrder())
|
||||
.setIsHighlight(searchDto.getIsHighlighter())
|
||||
.getPage(searchDto.getPage(), searchDto.getLimit());
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<parent>
|
||||
<groupId>com.zlt</groupId>
|
||||
<artifactId>zlt-business</artifactId>
|
||||
<version>5.1.0</version>
|
||||
<version>5.2.0</version>
|
||||
</parent>
|
||||
<artifactId>user-center</artifactId>
|
||||
<description>用户中心</description>
|
||||
|
||||
+1
-1
@@ -167,7 +167,7 @@ public class SysMenuController {
|
||||
if (CollectionUtil.isEmpty(roles)) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
List<SysMenu> menus = menuService.findByRoleCodes(roles.parallelStream().map(SysRole::getCode).collect(Collectors.toSet()), CommonConstant.MENU);
|
||||
List<SysMenu> menus = menuService.findByRoleCodes(roles.stream().map(SysRole::getCode).collect(Collectors.toSet()), CommonConstant.MENU);
|
||||
return treeBuilder(menus);
|
||||
}
|
||||
}
|
||||
|
||||
+2
-2
@@ -80,10 +80,10 @@ public class SysUserServiceImpl extends SuperServiceImpl<SysUserMapper, SysUser>
|
||||
loginAppUser.setRoles(sysRoles);
|
||||
|
||||
if (!CollectionUtils.isEmpty(sysRoles)) {
|
||||
Set<Long> roleIds = sysRoles.parallelStream().map(SuperEntity::getId).collect(Collectors.toSet());
|
||||
Set<Long> roleIds = sysRoles.stream().map(SuperEntity::getId).collect(Collectors.toSet());
|
||||
List<SysMenu> menus = roleMenuMapper.findMenusByRoleIds(roleIds, CommonConstant.PERMISSION);
|
||||
if (!CollectionUtils.isEmpty(menus)) {
|
||||
Set<String> permissions = menus.parallelStream().map(p -> p.getPath())
|
||||
Set<String> permissions = menus.stream().map(p -> p.getPath())
|
||||
.collect(Collectors.toSet());
|
||||
// 设置权限集合
|
||||
loginAppUser.setPermissions(permissions);
|
||||
|
||||
+1
-1
@@ -4,7 +4,7 @@
|
||||
<parent>
|
||||
<groupId>com.zlt</groupId>
|
||||
<artifactId>central-platform</artifactId>
|
||||
<version>5.1.0</version>
|
||||
<version>5.2.0</version>
|
||||
</parent>
|
||||
<artifactId>zlt-commons</artifactId>
|
||||
<description>通用组件</description>
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<groupId>com.zlt</groupId>
|
||||
<artifactId>zlt-commons</artifactId>
|
||||
<version>5.1.0</version>
|
||||
<version>5.2.0</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
+12
@@ -35,4 +35,16 @@ public class AuthProperties {
|
||||
* 2. 登出信息通知所有单点登录系统
|
||||
*/
|
||||
private Boolean unifiedLogout = false;
|
||||
|
||||
/**
|
||||
* 是否同应用同账号登录互踢
|
||||
*/
|
||||
private Boolean isSingleLogin = false;
|
||||
|
||||
/**
|
||||
* 是否同应用同账号登录时共用token
|
||||
* true: 多个用户使用同一账号登录时共用一个token
|
||||
* false: 就算使用同一账号登录时都会新建一个token
|
||||
*/
|
||||
private Boolean isShareToken = true;
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<parent>
|
||||
<groupId>com.zlt</groupId>
|
||||
<artifactId>zlt-commons</artifactId>
|
||||
<version>5.1.0</version>
|
||||
<version>5.2.0</version>
|
||||
</parent>
|
||||
<artifactId>zlt-common-core</artifactId>
|
||||
<description>公共通用组件</description>
|
||||
|
||||
+1
-1
@@ -10,7 +10,7 @@ public interface CommonConstant {
|
||||
/**
|
||||
* 项目版本号(banner使用)
|
||||
*/
|
||||
String PROJECT_VERSION = "5.1.0";
|
||||
String PROJECT_VERSION = "5.2.0";
|
||||
|
||||
/**
|
||||
* token请求头名称
|
||||
|
||||
+1
-1
@@ -33,7 +33,7 @@ public class LoginAppUser extends SysUser implements SocialUserDetails {
|
||||
public Collection<? extends GrantedAuthority> getAuthorities() {
|
||||
Collection<GrantedAuthority> collection = new HashSet<>();
|
||||
if (!CollectionUtils.isEmpty(super.getRoles())) {
|
||||
super.getRoles().parallelStream().forEach(role -> collection.add(new SimpleGrantedAuthority(role.getCode())));
|
||||
super.getRoles().forEach(role -> collection.add(new SimpleGrantedAuthority(role.getCode())));
|
||||
}
|
||||
return collection;
|
||||
}
|
||||
|
||||
@@ -88,15 +88,11 @@ public class JsonUtil {
|
||||
* @param json json字符串
|
||||
* @param cls 目标对象
|
||||
*/
|
||||
public static <T> T toObject(String json, Class<T> cls) {
|
||||
if(StringUtils.isBlank(json) || cls == null){
|
||||
public static <T> T toObject(JsonNode json, Class<T> cls) {
|
||||
if(json == null || cls == null){
|
||||
return null;
|
||||
}
|
||||
try {
|
||||
return MAPPER.readValue(json, cls);
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
return MAPPER.convertValue(json, cls);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -134,6 +130,22 @@ public class JsonUtil {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 字符串转换为指定对象
|
||||
* @param json json字符串
|
||||
* @param cls 目标对象
|
||||
*/
|
||||
public static <T> T toObject(String json, Class<T> cls) {
|
||||
if(StringUtils.isBlank(json) || cls == null){
|
||||
return null;
|
||||
}
|
||||
try {
|
||||
return MAPPER.readValue(json, cls);
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 字符串转换为JsonNode对象
|
||||
* @param json json字符串
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<parent>
|
||||
<groupId>com.zlt</groupId>
|
||||
<artifactId>zlt-commons</artifactId>
|
||||
<version>5.1.0</version>
|
||||
<version>5.2.0</version>
|
||||
</parent>
|
||||
<artifactId>zlt-common-spring-boot-starter</artifactId>
|
||||
<description>公共通用组件</description>
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<groupId>com.zlt</groupId>
|
||||
<artifactId>zlt-commons</artifactId>
|
||||
<version>5.1.0</version>
|
||||
<version>5.2.0</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<groupId>com.zlt</groupId>
|
||||
<artifactId>zlt-commons</artifactId>
|
||||
<version>5.1.0</version>
|
||||
<version>5.2.0</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
+12
-2
@@ -51,6 +51,10 @@ public class SearchBuilder {
|
||||
* 高亮后缀
|
||||
*/
|
||||
private static final String HIGHLIGHTER_POST_TAGS = "</mark>";
|
||||
/**
|
||||
* 排序顺序
|
||||
*/
|
||||
private static final String SORT_ORDER_ASC = "ASC";
|
||||
|
||||
private SearchRequest searchRequest;
|
||||
private SearchSourceBuilder searchBuilder;
|
||||
@@ -144,9 +148,15 @@ public class SearchBuilder {
|
||||
* @param field 排序字段
|
||||
* @param order 顺序方向
|
||||
*/
|
||||
public SearchBuilder addSort(String field, SortOrder order) {
|
||||
public SearchBuilder addSort(String field, String order) {
|
||||
if (StrUtil.isNotEmpty(field) && order != null) {
|
||||
searchBuilder.sort(field, order);
|
||||
SortOrder so;
|
||||
if (SORT_ORDER_ASC.equals(order)) {
|
||||
so = SortOrder.ASC;
|
||||
} else {
|
||||
so = SortOrder.DESC;
|
||||
}
|
||||
searchBuilder.sort(field, so);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<groupId>com.zlt</groupId>
|
||||
<artifactId>zlt-commons</artifactId>
|
||||
<version>5.1.0</version>
|
||||
<version>5.2.0</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<groupId>com.zlt</groupId>
|
||||
<artifactId>zlt-commons</artifactId>
|
||||
<version>5.1.0</version>
|
||||
<version>5.2.0</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
+1
-2
@@ -34,9 +34,8 @@ public class DubboTraceFilter implements Filter {
|
||||
} else { //服务消费者逻辑
|
||||
String traceId = MDCTraceUtils.getTraceId();
|
||||
if (StrUtil.isNotEmpty(traceId)) {
|
||||
String spanId = MDCTraceUtils.getSpanId();
|
||||
invocation.setAttachment(MDCTraceUtils.KEY_TRACE_ID, traceId);
|
||||
invocation.setAttachment(MDCTraceUtils.KEY_SPAN_ID, spanId);
|
||||
invocation.setAttachment(MDCTraceUtils.KEY_SPAN_ID, MDCTraceUtils.getNextSpanId());
|
||||
}
|
||||
}
|
||||
try {
|
||||
|
||||
+3
-4
@@ -1,11 +1,11 @@
|
||||
package com.central.log.trace;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.central.log.properties.TraceProperties;
|
||||
import feign.RequestInterceptor;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
@@ -30,10 +30,9 @@ public class FeignTraceConfig {
|
||||
if (traceProperties.getEnable()) {
|
||||
//传递日志traceId
|
||||
String traceId = MDCTraceUtils.getTraceId();
|
||||
if (!StringUtils.isEmpty(traceId)) {
|
||||
String spanId = MDCTraceUtils.getSpanId();
|
||||
if (StrUtil.isNotEmpty(traceId)) {
|
||||
template.header(MDCTraceUtils.TRACE_ID_HEADER, traceId);
|
||||
template.header(MDCTraceUtils.SPAN_ID_HEADER, spanId);
|
||||
template.header(MDCTraceUtils.SPAN_ID_HEADER, MDCTraceUtils.getNextSpanId());
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
+19
-15
@@ -1,10 +1,11 @@
|
||||
package com.central.log.trace;
|
||||
|
||||
import cn.hutool.core.util.IdUtil;
|
||||
import cn.hutool.core.util.RandomUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.alibaba.ttl.TransmittableThreadLocal;
|
||||
import org.slf4j.MDC;
|
||||
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
/**
|
||||
* 日志追踪工具类
|
||||
@@ -24,10 +25,6 @@ public class MDCTraceUtils {
|
||||
* 块id的名称
|
||||
*/
|
||||
public static final String KEY_SPAN_ID = "spanId";
|
||||
/**
|
||||
* 父块id的名称
|
||||
*/
|
||||
public static final String KEY_PARENT_ID = "parentId";
|
||||
|
||||
/**
|
||||
* 日志链路追踪id信息头
|
||||
@@ -37,23 +34,22 @@ public class MDCTraceUtils {
|
||||
* 日志链路块id信息头
|
||||
*/
|
||||
public static final String SPAN_ID_HEADER = "x-spanId-header";
|
||||
/**
|
||||
* 日志链路父块id信息头
|
||||
*/
|
||||
public static final String PARENT_ID_HEADER = "x-parentId-header";
|
||||
|
||||
/**
|
||||
* filter的优先级,值越低越优先
|
||||
*/
|
||||
public static final int FILTER_ORDER = -1;
|
||||
|
||||
private static final TransmittableThreadLocal<AtomicInteger> spanNumber = new TransmittableThreadLocal<>();
|
||||
|
||||
/**
|
||||
* 创建traceId并赋值MDC
|
||||
*/
|
||||
public static void addTrace() {
|
||||
String traceId = createTraceId();
|
||||
MDC.put(KEY_TRACE_ID, traceId);
|
||||
MDC.put(KEY_SPAN_ID, traceId);
|
||||
MDC.put(KEY_SPAN_ID, "0");
|
||||
initSpanNumber();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -61,8 +57,8 @@ public class MDCTraceUtils {
|
||||
*/
|
||||
public static void putTrace(String traceId, String spanId) {
|
||||
MDC.put(KEY_TRACE_ID, traceId);
|
||||
MDC.put(KEY_PARENT_ID, spanId);
|
||||
MDC.put(KEY_SPAN_ID, createTraceId());
|
||||
MDC.put(KEY_SPAN_ID, spanId);
|
||||
initSpanNumber();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -84,13 +80,21 @@ public class MDCTraceUtils {
|
||||
public static void removeTrace() {
|
||||
MDC.remove(KEY_TRACE_ID);
|
||||
MDC.remove(KEY_SPAN_ID);
|
||||
MDC.remove(KEY_PARENT_ID);
|
||||
spanNumber.remove();
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建traceId
|
||||
*/
|
||||
public static String createTraceId() {
|
||||
return RandomUtil.randomString(16);
|
||||
return IdUtil.getSnowflake().nextIdStr();
|
||||
}
|
||||
|
||||
public static String getNextSpanId() {
|
||||
return StrUtil.format("{}.{}", getSpanId(), spanNumber.get().incrementAndGet());
|
||||
}
|
||||
|
||||
private static void initSpanNumber() {
|
||||
spanNumber.set(new AtomicInteger(0));
|
||||
}
|
||||
}
|
||||
|
||||
+2
-2
@@ -1,10 +1,10 @@
|
||||
package com.central.log.trace;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.central.log.properties.TraceProperties;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
|
||||
import org.springframework.core.annotation.Order;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.util.StringUtils;
|
||||
import org.springframework.web.filter.OncePerRequestFilter;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
@@ -41,7 +41,7 @@ public class WebTraceFilter extends OncePerRequestFilter {
|
||||
try {
|
||||
String traceId = request.getHeader(MDCTraceUtils.TRACE_ID_HEADER);
|
||||
String spanId = request.getHeader(MDCTraceUtils.SPAN_ID_HEADER);
|
||||
if (StringUtils.isEmpty(traceId)) {
|
||||
if (StrUtil.isEmpty(traceId)) {
|
||||
MDCTraceUtils.addTrace();
|
||||
} else {
|
||||
MDCTraceUtils.putTrace(traceId, spanId);
|
||||
|
||||
@@ -18,8 +18,8 @@
|
||||
|
||||
<!-- 彩色日志格式 -->
|
||||
<property name="CONSOLE_LOG_PATTERN"
|
||||
value="[${APP_NAME}:${ServerIP}:${ServerPort}] %clr(%d{yyyy-MM-dd HH:mm:ss.SSS}){faint} %clr(%level){blue} %clr(${PID}){magenta} %clr([%X{traceId},%X{spanId},%X{parentId}]){yellow} %clr([%thread]){orange} %clr(%-40.40logger{39}){cyan} %m%n${LOG_EXCEPTION_CONVERSION_WORD:-%wEx}" />
|
||||
<property name="CONSOLE_LOG_PATTERN_NO_COLOR" value="[${APP_NAME}:${ServerIP}:${ServerPort}] %d{yyyy-MM-dd HH:mm:ss.SSS} %level ${PID} [%X{traceId},%X{spanId},%X{parentId}] [%thread] %-40.40logger{39} %m%n${LOG_EXCEPTION_CONVERSION_WORD:-%wEx}" />
|
||||
value="[${APP_NAME}:${ServerIP}:${ServerPort}] %clr(%d{yyyy-MM-dd HH:mm:ss.SSS}){faint} %clr(%level){blue} %clr(${PID}){magenta} %clr([%X{traceId}-%X{spanId}]){yellow} %clr([%thread]){orange} %clr(%-40.40logger{39}){cyan} %m%n${LOG_EXCEPTION_CONVERSION_WORD:-%wEx}" />
|
||||
<property name="CONSOLE_LOG_PATTERN_NO_COLOR" value="[${APP_NAME}:${ServerIP}:${ServerPort}] %d{yyyy-MM-dd HH:mm:ss.SSS} %level ${PID} [%X{traceId}-%X{spanId}] [%thread] %-40.40logger{39} %m%n${LOG_EXCEPTION_CONVERSION_WORD:-%wEx}" />
|
||||
|
||||
<!-- 控制台日志 -->
|
||||
<appender name="StdoutAppender" class="ch.qos.logback.core.ConsoleAppender">
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<groupId>com.zlt</groupId>
|
||||
<artifactId>zlt-commons</artifactId>
|
||||
<version>5.1.0</version>
|
||||
<version>5.2.0</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<groupId>com.zlt</groupId>
|
||||
<artifactId>zlt-commons</artifactId>
|
||||
<version>5.1.0</version>
|
||||
<version>5.2.0</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<groupId>com.zlt</groupId>
|
||||
<artifactId>zlt-commons</artifactId>
|
||||
<version>5.1.0</version>
|
||||
<version>5.2.0</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<groupId>com.zlt</groupId>
|
||||
<artifactId>zlt-commons</artifactId>
|
||||
<version>5.1.0</version>
|
||||
<version>5.2.0</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<groupId>com.zlt</groupId>
|
||||
<artifactId>zlt-commons</artifactId>
|
||||
<version>5.1.0</version>
|
||||
<version>5.2.0</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
+1
-1
@@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<groupId>com.zlt</groupId>
|
||||
<artifactId>central-platform</artifactId>
|
||||
<version>5.1.0</version>
|
||||
<version>5.2.0</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
@@ -83,4 +83,7 @@ spring.redis.lettuce.pool.max-wait=-1
|
||||
# 连接池中的最大空闲连接
|
||||
spring.redis.lettuce.pool.max-idle=8
|
||||
# 连接池中的最小空闲连接
|
||||
spring.redis.lettuce.pool.min-idle=0
|
||||
spring.redis.lettuce.pool.min-idle=0
|
||||
|
||||
##### logging配置
|
||||
logging.level.com.alibaba.nacos.client.naming=warn
|
||||
@@ -6,7 +6,7 @@
|
||||
<parent>
|
||||
<groupId>com.zlt</groupId>
|
||||
<artifactId>zlt-demo</artifactId>
|
||||
<version>5.1.0</version>
|
||||
<version>5.2.0</version>
|
||||
</parent>
|
||||
<artifactId>dubbo-demo</artifactId>
|
||||
|
||||
|
||||
+1
-1
@@ -4,7 +4,7 @@
|
||||
<parent>
|
||||
<groupId>com.zlt</groupId>
|
||||
<artifactId>central-platform</artifactId>
|
||||
<version>5.1.0</version>
|
||||
<version>5.2.0</version>
|
||||
</parent>
|
||||
<artifactId>zlt-demo</artifactId>
|
||||
<packaging>pom</packaging>
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<parent>
|
||||
<groupId>com.zlt</groupId>
|
||||
<artifactId>zlt-demo</artifactId>
|
||||
<version>5.1.0</version>
|
||||
<version>5.2.0</version>
|
||||
</parent>
|
||||
<artifactId>rocketmq-demo</artifactId>
|
||||
<packaging>pom</packaging>
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<parent>
|
||||
<groupId>com.zlt</groupId>
|
||||
<artifactId>rocketmq-demo</artifactId>
|
||||
<version>5.1.0</version>
|
||||
<version>5.2.0</version>
|
||||
</parent>
|
||||
<artifactId>rocketmq-consume</artifactId>
|
||||
<description>rocketMQ消费者demo</description>
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<parent>
|
||||
<groupId>com.zlt</groupId>
|
||||
<artifactId>rocketmq-demo</artifactId>
|
||||
<version>5.1.0</version>
|
||||
<version>5.2.0</version>
|
||||
</parent>
|
||||
<artifactId>rocketmq-produce</artifactId>
|
||||
<description>rocketMQ生产者demo</description>
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<parent>
|
||||
<groupId>com.zlt</groupId>
|
||||
<artifactId>rocketmq-demo</artifactId>
|
||||
<version>5.1.0</version>
|
||||
<version>5.2.0</version>
|
||||
</parent>
|
||||
<artifactId>rocketmq-transactional</artifactId>
|
||||
<description>rocketMQ事务消息demo</description>
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<groupId>com.zlt</groupId>
|
||||
<artifactId>seata-demo</artifactId>
|
||||
<version>5.1.0</version>
|
||||
<version>5.2.0</version>
|
||||
</parent>
|
||||
<artifactId>account-service</artifactId>
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<groupId>com.zlt</groupId>
|
||||
<artifactId>seata-demo</artifactId>
|
||||
<version>5.1.0</version>
|
||||
<version>5.2.0</version>
|
||||
</parent>
|
||||
<artifactId>business-service</artifactId>
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<groupId>com.zlt</groupId>
|
||||
<artifactId>seata-demo</artifactId>
|
||||
<version>5.1.0</version>
|
||||
<version>5.2.0</version>
|
||||
</parent>
|
||||
<artifactId>order-service</artifactId>
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<parent>
|
||||
<groupId>com.zlt</groupId>
|
||||
<artifactId>zlt-demo</artifactId>
|
||||
<version>5.1.0</version>
|
||||
<version>5.2.0</version>
|
||||
</parent>
|
||||
<artifactId>seata-demo</artifactId>
|
||||
<description>seata分布式事务demo</description>
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<groupId>com.zlt</groupId>
|
||||
<artifactId>seata-demo</artifactId>
|
||||
<version>5.1.0</version>
|
||||
<version>5.2.0</version>
|
||||
</parent>
|
||||
<artifactId>seata-common-starter</artifactId>
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<groupId>com.zlt</groupId>
|
||||
<artifactId>seata-demo</artifactId>
|
||||
<version>5.1.0</version>
|
||||
<version>5.2.0</version>
|
||||
</parent>
|
||||
<artifactId>storage-service</artifactId>
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<parent>
|
||||
<groupId>com.zlt</groupId>
|
||||
<artifactId>zlt-demo</artifactId>
|
||||
<version>5.1.0</version>
|
||||
<version>5.2.0</version>
|
||||
</parent>
|
||||
<artifactId>sharding-jdbc-demo</artifactId>
|
||||
<description>sharding-jdbc分库分表demo</description>
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<parent>
|
||||
<groupId>com.zlt</groupId>
|
||||
<artifactId>sso-demo</artifactId>
|
||||
<version>5.1.0</version>
|
||||
<version>5.2.0</version>
|
||||
</parent>
|
||||
<artifactId>oidc-sso</artifactId>
|
||||
<description>OIDC协议单点登录demo</description>
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<parent>
|
||||
<groupId>com.zlt</groupId>
|
||||
<artifactId>zlt-demo</artifactId>
|
||||
<version>5.1.0</version>
|
||||
<version>5.2.0</version>
|
||||
</parent>
|
||||
<artifactId>sso-demo</artifactId>
|
||||
<packaging>pom</packaging>
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<parent>
|
||||
<groupId>com.zlt</groupId>
|
||||
<artifactId>sso-demo</artifactId>
|
||||
<version>5.1.0</version>
|
||||
<version>5.2.0</version>
|
||||
</parent>
|
||||
<artifactId>ss-sso</artifactId>
|
||||
<description>springSecurity单点登录demo</description>
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<parent>
|
||||
<groupId>com.zlt</groupId>
|
||||
<artifactId>sso-demo</artifactId>
|
||||
<version>5.1.0</version>
|
||||
<version>5.2.0</version>
|
||||
</parent>
|
||||
<artifactId>web-sso</artifactId>
|
||||
<description>前后端分离单点登录demo</description>
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<parent>
|
||||
<groupId>com.zlt</groupId>
|
||||
<artifactId>zlt-demo</artifactId>
|
||||
<version>5.1.0</version>
|
||||
<version>5.2.0</version>
|
||||
</parent>
|
||||
<artifactId>txlcn-demo</artifactId>
|
||||
<description>txlcn分布式事务demo</description>
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<parent>
|
||||
<groupId>com.zlt</groupId>
|
||||
<artifactId>txlcn-demo</artifactId>
|
||||
<version>5.1.0</version>
|
||||
<version>5.2.0</version>
|
||||
</parent>
|
||||
<artifactId>txlcn-demo-common</artifactId>
|
||||
<name>demo-common</name>
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<groupId>com.zlt</groupId>
|
||||
<artifactId>txlcn-demo</artifactId>
|
||||
<version>5.1.0</version>
|
||||
<version>5.2.0</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<groupId>com.zlt</groupId>
|
||||
<artifactId>txlcn-demo</artifactId>
|
||||
<version>5.1.0</version>
|
||||
<version>5.2.0</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<artifactId>txlcn-demo-spring-service-b</artifactId>
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<groupId>com.zlt</groupId>
|
||||
<artifactId>txlcn-demo</artifactId>
|
||||
<version>5.1.0</version>
|
||||
<version>5.2.0</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<artifactId>txlcn-demo-spring-service-c</artifactId>
|
||||
|
||||
+1
-1
@@ -4,7 +4,7 @@
|
||||
<parent>
|
||||
<groupId>com.zlt</groupId>
|
||||
<artifactId>central-platform</artifactId>
|
||||
<version>5.1.0</version>
|
||||
<version>5.2.0</version>
|
||||
</parent>
|
||||
<artifactId>zlt-gateway</artifactId>
|
||||
<packaging>pom</packaging>
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<parent>
|
||||
<groupId>com.zlt</groupId>
|
||||
<artifactId>zlt-gateway</artifactId>
|
||||
<version>5.1.0</version>
|
||||
<version>5.2.0</version>
|
||||
</parent>
|
||||
<artifactId>sc-gateway</artifactId>
|
||||
<description>spring cloud gateway网关</description>
|
||||
|
||||
@@ -34,7 +34,7 @@ public class TraceFilter implements GlobalFilter, Ordered {
|
||||
ServerHttpRequest serverHttpRequest = exchange.getRequest().mutate()
|
||||
.headers(h -> {
|
||||
h.add(MDCTraceUtils.TRACE_ID_HEADER, MDCTraceUtils.getTraceId());
|
||||
h.add(MDCTraceUtils.SPAN_ID_HEADER, MDCTraceUtils.getSpanId());
|
||||
h.add(MDCTraceUtils.SPAN_ID_HEADER, MDCTraceUtils.getNextSpanId());
|
||||
})
|
||||
.build();
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<parent>
|
||||
<groupId>com.zlt</groupId>
|
||||
<artifactId>zlt-job</artifactId>
|
||||
<version>5.1.0</version>
|
||||
<version>5.2.0</version>
|
||||
</parent>
|
||||
<artifactId>job-admin</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<parent>
|
||||
<groupId>com.zlt</groupId>
|
||||
<artifactId>zlt-job</artifactId>
|
||||
<version>5.1.0</version>
|
||||
<version>5.2.0</version>
|
||||
</parent>
|
||||
<artifactId>job-core</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
<parent>
|
||||
<groupId>com.zlt</groupId>
|
||||
<artifactId>zlt-job</artifactId>
|
||||
<version>5.1.0</version>
|
||||
<version>5.2.0</version>
|
||||
</parent>
|
||||
<artifactId>job-executor-samples</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
+1
-1
@@ -4,7 +4,7 @@
|
||||
<parent>
|
||||
<groupId>com.zlt</groupId>
|
||||
<artifactId>central-platform</artifactId>
|
||||
<version>5.1.0</version>
|
||||
<version>5.2.0</version>
|
||||
</parent>
|
||||
<artifactId>zlt-job</artifactId>
|
||||
<packaging>pom</packaging>
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<parent>
|
||||
<groupId>com.zlt</groupId>
|
||||
<artifactId>zlt-monitor</artifactId>
|
||||
<version>5.1.0</version>
|
||||
<version>5.2.0</version>
|
||||
</parent>
|
||||
<artifactId>log-center</artifactId>
|
||||
<dependencies>
|
||||
|
||||
+40
-7
@@ -1,16 +1,20 @@
|
||||
package com.central.log.controller;
|
||||
|
||||
import com.central.common.model.PageResult;
|
||||
import com.central.log.model.TraceLog;
|
||||
import com.central.log.service.TraceLogService;
|
||||
import com.central.search.client.service.IQueryService;
|
||||
import com.central.search.model.SearchDto;
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
import io.swagger.annotations.ApiImplicitParams;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* 系统日志
|
||||
*
|
||||
@@ -18,19 +22,48 @@ import org.springframework.web.bind.annotation.RestController;
|
||||
*/
|
||||
@RestController
|
||||
public class SysLogController {
|
||||
@Autowired
|
||||
/**
|
||||
* 系统日志索引名
|
||||
*/
|
||||
private static final String SYS_LOG_INDEXNAME = "sys-log-*";
|
||||
|
||||
@Resource
|
||||
private IQueryService queryService;
|
||||
|
||||
@Resource
|
||||
private TraceLogService traceLogService;
|
||||
|
||||
@ApiOperation(value = "系统日志全文搜索列表")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "page", value = "分页起始位置", required = true, dataType = "Integer"),
|
||||
@ApiImplicitParam(name = "limit", value = "分页结束位置", required = true, dataType = "Integer"),
|
||||
@ApiImplicitParam(name = "queryStr", value = "搜索关键字", dataType = "String")
|
||||
@ApiImplicitParam(name = "queryStr", value = "搜索关键字", dataType = "String"),
|
||||
@ApiImplicitParam(name = "sortCol", value = "排序字段", dataType = "String"),
|
||||
@ApiImplicitParam(name = "sortOrder", value = "排序顺序", dataType = "String"),
|
||||
@ApiImplicitParam(name = "isHighlighter", value = "是否显示高亮", dataType = "String")
|
||||
})
|
||||
@GetMapping(value = "/sysLog")
|
||||
public PageResult<JsonNode> getPage(SearchDto searchDto) {
|
||||
searchDto.setIsHighlighter(true);
|
||||
searchDto.setSortCol("timestamp");
|
||||
return queryService.strQuery("sys-log-*", searchDto);
|
||||
public PageResult<JsonNode> sysLog(SearchDto searchDto) {
|
||||
return queryService.strQuery(SYS_LOG_INDEXNAME, searchDto);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "系统日志链路列表")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "queryStr", value = "搜索关键字", dataType = "String"),
|
||||
@ApiImplicitParam(name = "sortCol", value = "排序字段", dataType = "String"),
|
||||
@ApiImplicitParam(name = "sortOrder", value = "排序顺序", dataType = "String"),
|
||||
@ApiImplicitParam(name = "isHighlighter", value = "是否显示高亮", dataType = "String")
|
||||
})
|
||||
@GetMapping(value = "/traceLog")
|
||||
public PageResult<TraceLog> traceLog(SearchDto searchDto) {
|
||||
PageResult<JsonNode> pageResult = queryService.strQuery(SYS_LOG_INDEXNAME, searchDto);
|
||||
List<JsonNode> jsonNodeList = pageResult.getData();
|
||||
List<TraceLog> logList;
|
||||
if (jsonNodeList != null) {
|
||||
logList = traceLogService.transTraceLog(jsonNodeList);
|
||||
} else {
|
||||
logList = new ArrayList<>(0);
|
||||
}
|
||||
return PageResult.<TraceLog>builder().data(logList).code(0).count((long) logList.size()).build();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
package com.central.log.model;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
/**
|
||||
* 日志链路对象
|
||||
*
|
||||
* @author zlt
|
||||
* @version 1.0
|
||||
* @date 2022/1/27
|
||||
* <p>
|
||||
* Blog: https://zlt2000.gitee.io
|
||||
* Github: https://github.com/zlt2000
|
||||
*/
|
||||
@Setter
|
||||
@Getter
|
||||
public class TraceLog {
|
||||
private String spanId;
|
||||
private String parentId;
|
||||
private String appName;
|
||||
private String serverIp;
|
||||
private String serverPort;
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
package com.central.log.service;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.central.common.utils.JsonUtil;
|
||||
import com.central.log.model.TraceLog;
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* 日志链路service
|
||||
*
|
||||
* @author zlt
|
||||
* @version 1.0
|
||||
* @date 2022/1/27
|
||||
* <p>
|
||||
* Blog: https://zlt2000.gitee.io
|
||||
* Github: https://github.com/zlt2000
|
||||
*/
|
||||
@Service
|
||||
public class TraceLogService {
|
||||
public List<TraceLog> transTraceLog(List<JsonNode> jsonNodeList) {
|
||||
List<TraceLog> logList = new ArrayList<>();
|
||||
Set<String> logSet = new HashSet<>();
|
||||
jsonNodeList.forEach(e -> {
|
||||
TraceLog log = JsonUtil.toObject(e, TraceLog.class);
|
||||
String spanId = log.getSpanId();
|
||||
if (StrUtil.isNotEmpty(spanId)) {
|
||||
if (spanId.length() == 1) {
|
||||
log.setParentId("-1");
|
||||
} else {
|
||||
log.setParentId(spanId.substring(0, spanId.length() - 2));
|
||||
}
|
||||
if (checkLog(genLogKey(log), logSet)) {
|
||||
logList.add(log);
|
||||
}
|
||||
}
|
||||
});
|
||||
return logList;
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过集合来去重
|
||||
*/
|
||||
private boolean checkLog(String logKey, Set<String> logSet) {
|
||||
if (logSet.contains(logKey)) {
|
||||
return false;
|
||||
} else {
|
||||
logSet.add(logKey);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
private String genLogKey(TraceLog log) {
|
||||
return StrUtil.format("{}_{}_{}_{}", log.getAppName(), log.getSpanId(), log.getServerIp(), log.getServerPort());
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<groupId>com.zlt</groupId>
|
||||
<artifactId>central-platform</artifactId>
|
||||
<version>5.1.0</version>
|
||||
<version>5.2.0</version>
|
||||
</parent>
|
||||
<artifactId>zlt-monitor</artifactId>
|
||||
<packaging>pom</packaging>
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<parent>
|
||||
<groupId>com.zlt</groupId>
|
||||
<artifactId>zlt-monitor</artifactId>
|
||||
<version>5.1.0</version>
|
||||
<version>5.2.0</version>
|
||||
</parent>
|
||||
<artifactId>sc-admin</artifactId>
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<parent>
|
||||
<groupId>com.zlt</groupId>
|
||||
<artifactId>central-platform</artifactId>
|
||||
<version>5.1.0</version>
|
||||
<version>5.2.0</version>
|
||||
</parent>
|
||||
<artifactId>zlt-transaction</artifactId>
|
||||
<description>事务</description>
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<groupId>com.zlt</groupId>
|
||||
<artifactId>zlt-transaction</artifactId>
|
||||
<version>5.1.0</version>
|
||||
<version>5.2.0</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<artifactId>txlcn-tm</artifactId>
|
||||
|
||||
+1
-1
@@ -4,7 +4,7 @@
|
||||
<parent>
|
||||
<groupId>com.zlt</groupId>
|
||||
<artifactId>central-platform</artifactId>
|
||||
<version>5.1.0</version>
|
||||
<version>5.2.0</version>
|
||||
</parent>
|
||||
<artifactId>zlt-uaa</artifactId>
|
||||
<description>认证中心</description>
|
||||
|
||||
@@ -7,8 +7,8 @@ import com.central.oauth.service.IValidateCodeService;
|
||||
import com.central.oauth.service.impl.CustomTokenServices;
|
||||
import com.central.oauth.service.impl.UserDetailServiceFactory;
|
||||
import com.central.oauth.service.impl.UserDetailsByNameServiceFactoryWrapper;
|
||||
import com.central.oauth2.common.properties.SecurityProperties;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
@@ -71,11 +71,8 @@ public class TokenGranterConfig {
|
||||
|
||||
private TokenGranter tokenGranter;
|
||||
|
||||
/**
|
||||
* 是否登录同应用同账号互踢
|
||||
*/
|
||||
@Value("${zlt.uaa.isSingleLogin:false}")
|
||||
private boolean isSingleLogin;
|
||||
@Resource
|
||||
private SecurityProperties securityProperties;
|
||||
|
||||
/**
|
||||
* 授权模式
|
||||
@@ -153,7 +150,7 @@ public class TokenGranterConfig {
|
||||
@Bean
|
||||
@ConditionalOnMissingBean
|
||||
protected DefaultTokenServices createDefaultTokenServices() {
|
||||
DefaultTokenServices tokenServices = new CustomTokenServices(isSingleLogin);
|
||||
DefaultTokenServices tokenServices = new CustomTokenServices(securityProperties.getAuth());
|
||||
tokenServices.setTokenStore(tokenStore);
|
||||
tokenServices.setSupportRefreshToken(true);
|
||||
tokenServices.setReuseRefreshToken(reuseRefreshToken);
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.central.oauth.service.impl;
|
||||
|
||||
import com.central.common.constant.SecurityConstants;
|
||||
import com.central.oauth2.common.properties.AuthProperties;
|
||||
import org.springframework.security.authentication.AbstractAuthenticationToken;
|
||||
import org.springframework.security.authentication.AuthenticationManager;
|
||||
import org.springframework.security.core.Authentication;
|
||||
@@ -41,10 +42,10 @@ public class CustomTokenServices extends DefaultTokenServices {
|
||||
/**
|
||||
* 是否登录同应用同账号互踢
|
||||
*/
|
||||
private boolean isSingleLogin;
|
||||
private final AuthProperties authProperties;
|
||||
|
||||
public CustomTokenServices(boolean isSingleLogin) {
|
||||
this.isSingleLogin = isSingleLogin;
|
||||
public CustomTokenServices(AuthProperties auth) {
|
||||
this.authProperties = auth;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -53,7 +54,7 @@ public class CustomTokenServices extends DefaultTokenServices {
|
||||
OAuth2AccessToken existingAccessToken = tokenStore.getAccessToken(authentication);
|
||||
OAuth2RefreshToken refreshToken = null;
|
||||
if (existingAccessToken != null) {
|
||||
if (isSingleLogin) {
|
||||
if (authProperties.getIsSingleLogin()) {
|
||||
if (existingAccessToken.getRefreshToken() != null) {
|
||||
tokenStore.removeRefreshToken(existingAccessToken.getRefreshToken());
|
||||
}
|
||||
@@ -67,8 +68,7 @@ public class CustomTokenServices extends DefaultTokenServices {
|
||||
tokenStore.removeRefreshToken(refreshToken);
|
||||
}
|
||||
tokenStore.removeAccessToken(existingAccessToken);
|
||||
}
|
||||
else {
|
||||
} else if (authProperties.getIsShareToken()) {
|
||||
// oidc每次授权都刷新id_token
|
||||
existingAccessToken = refreshIdToken(existingAccessToken, authentication);
|
||||
// Re-store the access token in case the authentication has changed
|
||||
|
||||
@@ -101,7 +101,7 @@ public class RedisClientDetailsService extends JdbcClientDetailsService {
|
||||
return;
|
||||
}
|
||||
|
||||
list.parallelStream().forEach(client -> redisTemplate.opsForValue().set(clientRedisKey(client.getClientId()), client));
|
||||
list.forEach(client -> redisTemplate.opsForValue().set(clientRedisKey(client.getClientId()), client));
|
||||
}
|
||||
|
||||
private String clientRedisKey(String clientId) {
|
||||
|
||||
@@ -39,7 +39,7 @@ public class RedisTokensServiceImpl implements ITokensService {
|
||||
public PageResult<TokenVo> listTokens(Map<String, Object> params, String clientId) {
|
||||
Integer page = MapUtils.getInteger(params, "page");
|
||||
Integer limit = MapUtils.getInteger(params, "limit");
|
||||
int[] startEnds = PageUtil.transToStartEnd(page, limit);
|
||||
int[] startEnds = PageUtil.transToStartEnd(page-1, limit);
|
||||
//根据请求参数生成redis的key
|
||||
String redisKey = getRedisKey(params, clientId);
|
||||
long size = redisRepository.length(redisKey);
|
||||
|
||||
@@ -29,12 +29,12 @@ zlt:
|
||||
# 忽略验证码的应用编号
|
||||
ignoreClientCode: app
|
||||
auth:
|
||||
# 开启统一登出
|
||||
unifiedLogout: true
|
||||
# 同账号登录互踢
|
||||
isSingleLogin: true
|
||||
#多租户配置
|
||||
tenant:
|
||||
enable: true
|
||||
ignoreTables:
|
||||
- oauth_client_details
|
||||
#是否登录同应用同账号互踢
|
||||
uaa:
|
||||
isSingleLogin: false
|
||||
- oauth_client_details
|
||||
@@ -6,7 +6,7 @@
|
||||
<parent>
|
||||
<groupId>com.zlt</groupId>
|
||||
<artifactId>zlt-web</artifactId>
|
||||
<version>5.1.0</version>
|
||||
<version>5.2.0</version>
|
||||
</parent>
|
||||
<artifactId>back-web</artifactId>
|
||||
<description>后台管理前端</description>
|
||||
|
||||
@@ -29,33 +29,68 @@
|
||||
layui.use(['form', 'table', 'util', 'config', 'admin', 'upload'], function () {
|
||||
let table = layui.table;
|
||||
let config = layui.config;
|
||||
let util = layui.util;
|
||||
let admin = layui.admin;
|
||||
|
||||
// 渲染表格
|
||||
table.render({
|
||||
elem: '#sysLog-table',
|
||||
url: config.base_server + 'api-log/sysLog',
|
||||
url: config.base_server + 'api-log/sysLog?sortCol=timestamp&isHighlighter=true',
|
||||
method: 'GET',
|
||||
headers:{'Authorization': 'Bearer ' + config.getToken().access_token},
|
||||
page: true,
|
||||
cols: [[
|
||||
{type: 'numbers'},
|
||||
{
|
||||
field: 'timestamp', width: 200, sort: true, templet: function (d) {
|
||||
return util.toDateString(d.timestamp, 'yyyy-MM-dd HH:mm:ss');
|
||||
}, title: '日志时间'
|
||||
field: 'timestamp', width: 180, sort: true, templet: function (d) {
|
||||
let newDate = Date.parse(d.timestamp);
|
||||
newDate = new Date(newDate);
|
||||
let yyyy = newDate.getFullYear();
|
||||
let MM = (newDate.getMonth()+1);
|
||||
let dd = newDate.getDate();
|
||||
let hh = newDate.getHours()<10 ? "0"+newDate.getHours() : newDate.getHours();
|
||||
let mm = newDate.getMinutes()<10 ? "0"+newDate.getMinutes() : newDate.getMinutes();
|
||||
let ss = newDate.getSeconds()<10 ? "0"+newDate.getSeconds() : newDate.getSeconds();
|
||||
let SSS = newDate.getMilliseconds();
|
||||
return yyyy+"-"+MM+"-"+dd+" "+hh+":"+mm+":"+ss+"."+SSS;
|
||||
}, title: '时间'
|
||||
},
|
||||
{field: 'message', sort: true, title: '日志信息', width: 350},
|
||||
{field: 'logLevel', sort: true, title: '日志级别', width: 100},
|
||||
{field: 'logLevel', sort: true, title: '日志级别', width: 110},
|
||||
{field: 'appName', sort: true, title: '应用名', width: 120},
|
||||
{field: 'serverIp', sort: true, title: '服务ip', width: 130},
|
||||
{field: 'serverPort', sort: true, title: '服务端口', width: 100},
|
||||
{field: 'threadName', sort: true, title: '线程名', width: 150},
|
||||
{field: 'traceId', sort: false, title: '追踪id', width: 180, templet: function (d) {
|
||||
if (d.traceId){
|
||||
return '<a class="layui-table-link" href="javascript:void(0);" lay-event="traceLog">'+d.traceId+'</a>';
|
||||
} else {
|
||||
return '';
|
||||
}
|
||||
}},
|
||||
{field: 'spanId', sort: false, title: 'spanId', width: 80},
|
||||
{field: 'classname', sort: true, title: '类名', width: 250},
|
||||
{field: 'traceId', sort: true, title: '链路追踪id', width: 200}
|
||||
{field: 'threadName', sort: true, title: '线程名', width: 150},
|
||||
{field: 'serverIp', sort: true, title: '服务ip', width: 130},
|
||||
{field: 'serverPort', sort: true, title: '服务端口', width: 110}
|
||||
]]
|
||||
});
|
||||
|
||||
// 工具条点击事件
|
||||
table.on('tool(sysLog-table)', function (obj) {
|
||||
if (obj.event === 'traceLog') {
|
||||
showTraceLog(obj.data.traceId);
|
||||
}
|
||||
});
|
||||
|
||||
//显示表单弹窗
|
||||
let showTraceLog = function (traceId) {
|
||||
traceId = traceId.replace('<mark>', '');
|
||||
traceId = traceId.replace('</mark>', '');
|
||||
admin.putTempData('traceId', traceId);
|
||||
admin.popupCenter({
|
||||
title: '日志链路',
|
||||
area: '670px',
|
||||
path: 'pages/log/traceLog.html'
|
||||
});
|
||||
};
|
||||
|
||||
// 搜索按钮点击事件
|
||||
$('#sysLog-btn-search').click(function () {
|
||||
let key = $('#sysLog-search-key').val();
|
||||
@@ -63,7 +98,9 @@
|
||||
if (key != '_all' && value) {
|
||||
value = key + ':' + value;
|
||||
}
|
||||
table.reload('sysLog-table', {where: {queryStr: value}});
|
||||
table.reload('sysLog-table', {
|
||||
where: {queryStr: value}
|
||||
});
|
||||
});
|
||||
});
|
||||
</script>
|
||||
@@ -0,0 +1,45 @@
|
||||
<!-- 数据表格 -->
|
||||
<table class="layui-table" id="trace-table" lay-filter="trace-table"></table>
|
||||
|
||||
<script>
|
||||
layui.use(['config', 'admin', 'table', 'treetable'],function () {
|
||||
let layer = layui.layer;
|
||||
let treetable = layui.treetable;
|
||||
let config = layui.config;
|
||||
let admin = layui.admin;
|
||||
|
||||
let traceId = admin.getTempData('traceId');
|
||||
// 渲染表格
|
||||
let renderTable = function () {
|
||||
layer.load(2);
|
||||
treetable.render({
|
||||
treeColIndex: 1,
|
||||
treeSpid: '-1',
|
||||
treeIdName: 'spanId',
|
||||
treePidName: 'parentId',
|
||||
elem: '#trace-table',
|
||||
url: config.base_server + 'api-log/traceLog',
|
||||
where: {
|
||||
access_token: config.getToken().access_token,
|
||||
queryStr: 'traceId:'+traceId,
|
||||
sortCol: 'timestamp',
|
||||
sortOrder: 'ASC'
|
||||
},
|
||||
page: false,
|
||||
cols: [[
|
||||
{type: 'numbers'},
|
||||
{field: 'appName', sort: true, title: '应用名', width: 220},
|
||||
{field: 'spanId', sort: false, title: 'spanId', width: 130},
|
||||
{field: 'serverIp', sort: true, title: '服务ip', width: 150},
|
||||
{field: 'serverPort', sort: true, title: '服务端口', width: 120}
|
||||
]],
|
||||
done: function() {
|
||||
layer.closeAll('loading');
|
||||
}
|
||||
});
|
||||
};
|
||||
if (traceId) {
|
||||
renderTable();
|
||||
}
|
||||
});
|
||||
</script>
|
||||
@@ -39,14 +39,7 @@
|
||||
let form = layui.form;
|
||||
|
||||
// 渲染表格
|
||||
var renderTable = function (param) {
|
||||
if (param) {
|
||||
param.access_token = config.getToken().access_token;
|
||||
} else {
|
||||
param = {
|
||||
access_token: config.getToken().access_token
|
||||
};
|
||||
}
|
||||
var renderTable = function (tenantId) {
|
||||
treetable.render({
|
||||
treeColIndex: 1,
|
||||
treeSpid: -1,
|
||||
@@ -54,7 +47,10 @@
|
||||
treePidName: 'parentId',
|
||||
elem: '#menus-table',
|
||||
url: config.base_server + 'api-user/menus/findAlls',
|
||||
where: param,
|
||||
where: {
|
||||
access_token: config.getToken().access_token,
|
||||
tenantId: tenantId
|
||||
},
|
||||
page: false,
|
||||
cols: [[
|
||||
{type: 'numbers'},
|
||||
@@ -79,7 +75,7 @@
|
||||
]]
|
||||
});
|
||||
};
|
||||
renderTable({tenantId: config.clientId});
|
||||
renderTable(config.clientId);
|
||||
|
||||
// 获取应用列表
|
||||
layer.load(2);
|
||||
@@ -117,7 +113,7 @@
|
||||
layer.closeAll('loading');
|
||||
if (0 === data.resp_code) {
|
||||
layer.msg(data.resp_msg, {icon: 1, time: 500});
|
||||
renderTable({tenantId: tenantId});
|
||||
renderTable(tenantId);
|
||||
} else {
|
||||
layer.msg(data.resp_msg, {icon: 2, time: 500});
|
||||
}
|
||||
@@ -143,7 +139,7 @@
|
||||
title: title,
|
||||
path: 'pages/system/menus_form.html',
|
||||
finish: function () {
|
||||
renderTable({tenantId: tenantId});
|
||||
renderTable(tenantId);
|
||||
}
|
||||
});
|
||||
};
|
||||
@@ -186,7 +182,7 @@
|
||||
|
||||
// 应用下来框点击事件
|
||||
form.on('select(menu_clients)', function(data){
|
||||
renderTable({tenantId: data.value});
|
||||
renderTable(data.value);
|
||||
});
|
||||
});
|
||||
</script>
|
||||
+1
-1
@@ -6,7 +6,7 @@
|
||||
<parent>
|
||||
<groupId>com.zlt</groupId>
|
||||
<artifactId>central-platform</artifactId>
|
||||
<version>5.1.0</version>
|
||||
<version>5.2.0</version>
|
||||
</parent>
|
||||
<artifactId>zlt-web</artifactId>
|
||||
<description>前端</description>
|
||||
|
||||
Reference in New Issue
Block a user