builder().data(logList).code(0).count((long) logList.size()).build();
}
}
diff --git a/zlt-monitor/log-center/src/main/java/com/central/log/model/TraceLog.java b/zlt-monitor/log-center/src/main/java/com/central/log/model/TraceLog.java
new file mode 100644
index 00000000..ee508ed3
--- /dev/null
+++ b/zlt-monitor/log-center/src/main/java/com/central/log/model/TraceLog.java
@@ -0,0 +1,24 @@
+package com.central.log.model;
+
+import lombok.Getter;
+import lombok.Setter;
+
+/**
+ * 日志链路对象
+ *
+ * @author zlt
+ * @version 1.0
+ * @date 2022/1/27
+ *
+ * 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;
+}
diff --git a/zlt-monitor/log-center/src/main/java/com/central/log/service/TraceLogService.java b/zlt-monitor/log-center/src/main/java/com/central/log/service/TraceLogService.java
new file mode 100644
index 00000000..f7c094d1
--- /dev/null
+++ b/zlt-monitor/log-center/src/main/java/com/central/log/service/TraceLogService.java
@@ -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
+ *
+ * Blog: https://zlt2000.gitee.io
+ * Github: https://github.com/zlt2000
+ */
+@Service
+public class TraceLogService {
+ public List transTraceLog(List jsonNodeList) {
+ List logList = new ArrayList<>();
+ Set 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 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());
+ }
+}
diff --git a/zlt-monitor/pom.xml b/zlt-monitor/pom.xml
index e3abf09d..18c88b9a 100644
--- a/zlt-monitor/pom.xml
+++ b/zlt-monitor/pom.xml
@@ -3,7 +3,7 @@
com.zlt
central-platform
- 5.1.0
+ 5.2.0
zlt-monitor
pom
diff --git a/zlt-monitor/sc-admin/pom.xml b/zlt-monitor/sc-admin/pom.xml
index 3cf2c046..5f0ab8fd 100644
--- a/zlt-monitor/sc-admin/pom.xml
+++ b/zlt-monitor/sc-admin/pom.xml
@@ -4,7 +4,7 @@
com.zlt
zlt-monitor
- 5.1.0
+ 5.2.0
sc-admin
diff --git a/zlt-transaction/pom.xml b/zlt-transaction/pom.xml
index 381dafd8..dc57cbd2 100644
--- a/zlt-transaction/pom.xml
+++ b/zlt-transaction/pom.xml
@@ -4,7 +4,7 @@
com.zlt
central-platform
- 5.1.0
+ 5.2.0
zlt-transaction
事务
diff --git a/zlt-transaction/txlcn-tm/pom.xml b/zlt-transaction/txlcn-tm/pom.xml
index b625844d..9e584aee 100644
--- a/zlt-transaction/txlcn-tm/pom.xml
+++ b/zlt-transaction/txlcn-tm/pom.xml
@@ -3,7 +3,7 @@
com.zlt
zlt-transaction
- 5.1.0
+ 5.2.0
4.0.0
txlcn-tm
diff --git a/zlt-uaa/pom.xml b/zlt-uaa/pom.xml
index c7e41616..2567b6a7 100644
--- a/zlt-uaa/pom.xml
+++ b/zlt-uaa/pom.xml
@@ -4,7 +4,7 @@
com.zlt
central-platform
- 5.1.0
+ 5.2.0
zlt-uaa
认证中心
diff --git a/zlt-uaa/src/main/java/com/central/oauth/config/TokenGranterConfig.java b/zlt-uaa/src/main/java/com/central/oauth/config/TokenGranterConfig.java
index a4fa0802..067ca3c7 100644
--- a/zlt-uaa/src/main/java/com/central/oauth/config/TokenGranterConfig.java
+++ b/zlt-uaa/src/main/java/com/central/oauth/config/TokenGranterConfig.java
@@ -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);
diff --git a/zlt-uaa/src/main/java/com/central/oauth/service/impl/CustomTokenServices.java b/zlt-uaa/src/main/java/com/central/oauth/service/impl/CustomTokenServices.java
index 66e1c624..6ce79c31 100644
--- a/zlt-uaa/src/main/java/com/central/oauth/service/impl/CustomTokenServices.java
+++ b/zlt-uaa/src/main/java/com/central/oauth/service/impl/CustomTokenServices.java
@@ -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
diff --git a/zlt-uaa/src/main/java/com/central/oauth/service/impl/RedisClientDetailsService.java b/zlt-uaa/src/main/java/com/central/oauth/service/impl/RedisClientDetailsService.java
index db64c39e..456b91bd 100644
--- a/zlt-uaa/src/main/java/com/central/oauth/service/impl/RedisClientDetailsService.java
+++ b/zlt-uaa/src/main/java/com/central/oauth/service/impl/RedisClientDetailsService.java
@@ -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) {
diff --git a/zlt-uaa/src/main/java/com/central/oauth/service/impl/RedisTokensServiceImpl.java b/zlt-uaa/src/main/java/com/central/oauth/service/impl/RedisTokensServiceImpl.java
index 70189dab..45fe56a5 100644
--- a/zlt-uaa/src/main/java/com/central/oauth/service/impl/RedisTokensServiceImpl.java
+++ b/zlt-uaa/src/main/java/com/central/oauth/service/impl/RedisTokensServiceImpl.java
@@ -39,7 +39,7 @@ public class RedisTokensServiceImpl implements ITokensService {
public PageResult listTokens(Map 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);
diff --git a/zlt-uaa/src/main/resources/application.yml b/zlt-uaa/src/main/resources/application.yml
index d2cdfaf1..0527d6b4 100644
--- a/zlt-uaa/src/main/resources/application.yml
+++ b/zlt-uaa/src/main/resources/application.yml
@@ -29,12 +29,12 @@ zlt:
# 忽略验证码的应用编号
ignoreClientCode: app
auth:
+ # 开启统一登出
unifiedLogout: true
+ # 同账号登录互踢
+ isSingleLogin: true
#多租户配置
tenant:
enable: true
ignoreTables:
- - oauth_client_details
- #是否登录同应用同账号互踢
- uaa:
- isSingleLogin: false
\ No newline at end of file
+ - oauth_client_details
\ No newline at end of file
diff --git a/zlt-web/back-web/pom.xml b/zlt-web/back-web/pom.xml
index f2ad06c8..c4362f94 100644
--- a/zlt-web/back-web/pom.xml
+++ b/zlt-web/back-web/pom.xml
@@ -6,7 +6,7 @@
com.zlt
zlt-web
- 5.1.0
+ 5.2.0
back-web
后台管理前端
diff --git a/zlt-web/back-web/src/main/resources/static/pages/log/sysLog.html b/zlt-web/back-web/src/main/resources/static/pages/log/sysLog.html
index b57b6d58..204ae7e7 100644
--- a/zlt-web/back-web/src/main/resources/static/pages/log/sysLog.html
+++ b/zlt-web/back-web/src/main/resources/static/pages/log/sysLog.html
@@ -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 ''+d.traceId+'';
+ } 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('', '');
+ traceId = traceId.replace('', '');
+ 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}
+ });
});
});
\ No newline at end of file
diff --git a/zlt-web/back-web/src/main/resources/static/pages/log/traceLog.html b/zlt-web/back-web/src/main/resources/static/pages/log/traceLog.html
new file mode 100644
index 00000000..9b62f01a
--- /dev/null
+++ b/zlt-web/back-web/src/main/resources/static/pages/log/traceLog.html
@@ -0,0 +1,45 @@
+
+
+
+
\ No newline at end of file
diff --git a/zlt-web/back-web/src/main/resources/static/pages/system/menus.html b/zlt-web/back-web/src/main/resources/static/pages/system/menus.html
index d678b13f..23d3861e 100644
--- a/zlt-web/back-web/src/main/resources/static/pages/system/menus.html
+++ b/zlt-web/back-web/src/main/resources/static/pages/system/menus.html
@@ -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);
});
});
\ No newline at end of file
diff --git a/zlt-web/pom.xml b/zlt-web/pom.xml
index c5333cb8..726d7cbb 100644
--- a/zlt-web/pom.xml
+++ b/zlt-web/pom.xml
@@ -6,7 +6,7 @@
com.zlt
central-platform
- 5.1.0
+ 5.2.0
zlt-web
前端