更新配置
This commit is contained in:
@@ -41,7 +41,7 @@ import java.util.concurrent.TimeUnit;
|
|||||||
* 对外开放 API
|
* 对外开放 API
|
||||||
* <p>
|
* <p>
|
||||||
* Token 一次消费:每个 token 只能用一次,消费后立即失效
|
* Token 一次消费:每个 token 只能用一次,消费后立即失效
|
||||||
* API 文档地址:http://服务地址:9002/doc.html → "对外开放API" 分组
|
* API 文档地址:http://服务地址:32002/doc.html → "对外开放API" 分组
|
||||||
*/
|
*/
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@RestController
|
@RestController
|
||||||
|
|||||||
@@ -1116,7 +1116,7 @@ export default defineConfig({
|
|||||||
<!-- 配置项通过 data-* 属性传入 -->
|
<!-- 配置项通过 data-* 属性传入 -->
|
||||||
<div
|
<div
|
||||||
id="mokee-user-chip"
|
id="mokee-user-chip"
|
||||||
data-api-base="http://127.0.0.1:9000"
|
data-api-base="http://127.0.0.1:32000"
|
||||||
data-login-url="http://127.0.0.1:5001/login"
|
data-login-url="http://127.0.0.1:5001/login"
|
||||||
data-select-url="http://127.0.0.1:5001/select"
|
data-select-url="http://127.0.0.1:5001/select"
|
||||||
></div>
|
></div>
|
||||||
@@ -1136,7 +1136,7 @@ export default defineConfig({
|
|||||||
<br/>
|
<br/>
|
||||||
<!-- 2. 占位元素(可配置网关地址、登录页、切换系统页) --><br/>
|
<!-- 2. 占位元素(可配置网关地址、登录页、切换系统页) --><br/>
|
||||||
<div id="mokee-user-chip"<br/>
|
<div id="mokee-user-chip"<br/>
|
||||||
data-api-base="http://127.0.0.1:9000"<br/>
|
data-api-base="http://127.0.0.1:32000"<br/>
|
||||||
data-login-url="http://127.0.0.1:5001/login"<br/>
|
data-login-url="http://127.0.0.1:5001/login"<br/>
|
||||||
data-select-url="http://127.0.0.1:5001/select"></div><br/>
|
data-select-url="http://127.0.0.1:5001/select"></div><br/>
|
||||||
<br/>
|
<br/>
|
||||||
|
|||||||
@@ -189,7 +189,7 @@ def init():
|
|||||||
# ===== 阶段3: 测试系统 =====
|
# ===== 阶段3: 测试系统 =====
|
||||||
print("\n===== 阶段3: 测试系统 (test) =====")
|
print("\n===== 阶段3: 测试系统 (test) =====")
|
||||||
cur.execute("""INSERT INTO sys_system (system_code, system_name, front_url, backend_url, gateway_url, status, description)
|
cur.execute("""INSERT INTO sys_system (system_code, system_name, front_url, backend_url, gateway_url, status, description)
|
||||||
VALUES ('test', '测试系统', 'http://127.0.0.1:5001', 'http://127.0.0.1:9000', 'http://127.0.0.1:9000/test', 1, '测试用业务系统')""")
|
VALUES ('test', '测试系统', 'http://127.0.0.1:5001', 'http://127.0.0.1:32000', 'http://127.0.0.1:9000/test', 1, '测试用业务系统')""")
|
||||||
conn.commit()
|
conn.commit()
|
||||||
test_sid = cur.lastrowid
|
test_sid = cur.lastrowid
|
||||||
print(f" 系统: id={test_sid}")
|
print(f" 系统: id={test_sid}")
|
||||||
|
|||||||
@@ -68,6 +68,6 @@ MenuList.vue统一用URL传id
|
|||||||
|
|
||||||
## 重要信息
|
## 重要信息
|
||||||
- 数据库: 10.1.1.122:3306
|
- 数据库: 10.1.1.122:3306
|
||||||
- 微服务端口: gateway:9000, auth:9001, admin:9002
|
- 微服务端口: gateway:32000, auth:32001, admin:32002
|
||||||
- 前端构建: `npm run build:prod` (跳过vue-tsc类型检查)
|
- 前端构建: `npm run build:prod` (跳过vue-tsc类型检查)
|
||||||
- Node版本: 服务器Node 18,Vite 5.4兼容
|
- Node版本: 服务器Node 18,Vite 5.4兼容
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ metadata:
|
|||||||
|
|
||||||
## 重要信息
|
## 重要信息
|
||||||
- Redis 前缀机制详情见 [[session-20260620-1]] 的 "Redis Key 加统一前缀 GATEWAY:" 章节
|
- Redis 前缀机制详情见 [[session-20260620-1]] 的 "Redis Key 加统一前缀 GATEWAY:" 章节
|
||||||
- Auth 服务(9001)、Admin 服务(9002)、Gateway(9000) 三个服务共享同一个 Redis 实例
|
- Auth 服务(32001)、Admin 服务(32002)、Gateway(32000) 三个服务共享同一个 Redis 实例
|
||||||
- 所有 Redis key 操作都必须通过 `RedisUtil.key()` 方法,不能直接拼字符串
|
- 所有 Redis key 操作都必须通过 `RedisUtil.key()` 方法,不能直接拼字符串
|
||||||
|
|
||||||
## 待处理
|
## 待处理
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ metadata:
|
|||||||
## 关键操作
|
## 关键操作
|
||||||
|
|
||||||
### /zgapi/v1/auth/system/list 性能排查
|
### /zgapi/v1/auth/system/list 性能排查
|
||||||
- **做了什么**: 完整追踪请求链路:Nginx → Gateway(9000) → TokenAuthFilter → RateLimitFilter → HeaderInjectFilter → ApiPermissionFilter → GatewayController → [HTTP转发] → Auth(9001) → DB/Redis
|
- **做了什么**: 完整追踪请求链路:Nginx → Gateway(32000) → TokenAuthFilter → RateLimitFilter → HeaderInjectFilter → ApiPermissionFilter → GatewayController → [HTTP转发] → Auth(32001) → DB/Redis
|
||||||
- **发现的浪费**:
|
- **发现的浪费**:
|
||||||
1. JWT 签名验证执行了 3 次(TokenAuthFilter + RateLimitFilter + AuthServiceImpl)
|
1. JWT 签名验证执行了 3 次(TokenAuthFilter + RateLimitFilter + AuthServiceImpl)
|
||||||
2. 同一个 Redis key 被查询了 4 次(TokenAuthFilter GET+GETEXPIRE + AuthServiceImpl GET+GETEXPIRE)
|
2. 同一个 Redis key 被查询了 4 次(TokenAuthFilter GET+GETEXPIRE + AuthServiceImpl GET+GETEXPIRE)
|
||||||
|
|||||||
@@ -18,8 +18,8 @@ public class AdminApplication {
|
|||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
SpringApplication.run(AdminApplication.class, args);
|
SpringApplication.run(AdminApplication.class, args);
|
||||||
System.out.println("========================================");
|
System.out.println("========================================");
|
||||||
System.out.println(" 业务管理服务启动成功! 端口: 9002");
|
System.out.println(" 业务管理服务启动成功! 端口: 32002");
|
||||||
System.out.println(" Knife4j 文档: http://localhost:9002/doc.html");
|
System.out.println(" Knife4j 文档: http://localhost:32002/doc.html");
|
||||||
System.out.println("========================================");
|
System.out.println("========================================");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -114,11 +114,11 @@ public class DashboardController {
|
|||||||
|
|
||||||
// 微服务健康状态:用 TCP 端口检测替代 HTTP(快 10 倍)
|
// 微服务健康状态:用 TCP 端口检测替代 HTTP(快 10 倍)
|
||||||
List<Map<String, Object>> services = new ArrayList<>();
|
List<Map<String, Object>> services = new ArrayList<>();
|
||||||
services.add(checkTcpPort("网关服务 (Gateway)", "127.0.0.1", 9000));
|
// services.add(checkTcpPort("网关服务 (Gateway)", "127.0.0.1", 32000));
|
||||||
services.add(checkTcpPort("认证服务 (Auth)", "127.0.0.1", 9001));
|
// services.add(checkTcpPort("认证服务 (Auth)", "127.0.0.1", 32001));
|
||||||
Map<String, Object> adminSvc = new LinkedHashMap<>();
|
Map<String, Object> adminSvc = new LinkedHashMap<>();
|
||||||
adminSvc.put("name", "管理服务 (Admin)");
|
adminSvc.put("name", "管理服务 (Admin)");
|
||||||
adminSvc.put("port", 9002);
|
adminSvc.put("port", 32002);
|
||||||
adminSvc.put("status", "UP");
|
adminSvc.put("status", "UP");
|
||||||
adminSvc.put("responseTime", 0);
|
adminSvc.put("responseTime", 0);
|
||||||
services.add(adminSvc);
|
services.add(adminSvc);
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ import java.util.concurrent.TimeUnit;
|
|||||||
* 对外开放 API
|
* 对外开放 API
|
||||||
* <p>
|
* <p>
|
||||||
* Token 一次消费:每个 token 只能用一次,消费后立即失效
|
* Token 一次消费:每个 token 只能用一次,消费后立即失效
|
||||||
* API 文档地址:http://服务地址:9002/doc.html → "对外开放API" 分组
|
* API 文档地址:http://服务地址:32002/doc.html → "对外开放API" 分组
|
||||||
*/
|
*/
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@RestController
|
@RestController
|
||||||
|
|||||||
@@ -16,8 +16,8 @@ public class AuthApplication {
|
|||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
SpringApplication.run(AuthApplication.class, args);
|
SpringApplication.run(AuthApplication.class, args);
|
||||||
System.out.println("========================================");
|
System.out.println("========================================");
|
||||||
System.out.println(" 认证用户服务启动成功! 端口: 9001");
|
System.out.println(" 认证用户服务启动成功! 端口: 32001");
|
||||||
System.out.println(" Knife4j 文档: http://localhost:9001/doc.html");
|
System.out.println(" Knife4j 文档: http://localhost:32001/doc.html");
|
||||||
System.out.println("========================================");
|
System.out.println("========================================");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ public class GatewayApplication {
|
|||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
SpringApplication.run(GatewayApplication.class, args);
|
SpringApplication.run(GatewayApplication.class, args);
|
||||||
System.out.println("========================================");
|
System.out.println("========================================");
|
||||||
System.out.println(" 网关服务启动成功! 端口: 9000");
|
System.out.println(" 网关服务启动成功! 端口: 32000");
|
||||||
System.out.println("========================================");
|
System.out.println("========================================");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,10 +23,10 @@ public class GatewayController {
|
|||||||
private final RestTemplate restTemplate;
|
private final RestTemplate restTemplate;
|
||||||
private final SysSystemMapper sysSystemMapper;
|
private final SysSystemMapper sysSystemMapper;
|
||||||
|
|
||||||
@Value("${gateway.route.auth-url:http://127.0.0.1:9001}")
|
@Value("${gateway.route.auth-url:http://127.0.0.1:32001}")
|
||||||
private String authServiceUrl;
|
private String authServiceUrl;
|
||||||
|
|
||||||
@Value("${gateway.route.admin-url:http://127.0.0.1:9002}")
|
@Value("${gateway.route.admin-url:http://127.0.0.1:32002}")
|
||||||
private String adminServiceUrl;
|
private String adminServiceUrl;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -26,8 +26,8 @@ mybatis-plus:
|
|||||||
|
|
||||||
gateway:
|
gateway:
|
||||||
route:
|
route:
|
||||||
auth-url: http://10.10.1.170:9001
|
auth-url: http://10.10.1.170:32001
|
||||||
admin-url: http://10.10.1.170:9002
|
admin-url: http://10.10.1.170:32002
|
||||||
|
|
||||||
logging:
|
logging:
|
||||||
level:
|
level:
|
||||||
|
|||||||
@@ -26,8 +26,8 @@ mybatis-plus:
|
|||||||
|
|
||||||
gateway:
|
gateway:
|
||||||
route:
|
route:
|
||||||
auth-url: http://127.0.0.1:9001
|
auth-url: http://127.0.0.1:32001
|
||||||
admin-url: http://127.0.0.1:9002
|
admin-url: http://127.0.0.1:32002
|
||||||
|
|
||||||
logging:
|
logging:
|
||||||
level:
|
level:
|
||||||
|
|||||||
@@ -74,7 +74,7 @@
|
|||||||
-->
|
-->
|
||||||
<div
|
<div
|
||||||
id="mokee-user-chip"
|
id="mokee-user-chip"
|
||||||
data-api-base="http://127.0.0.1:9000"
|
data-api-base="http://127.0.0.1:32000"
|
||||||
></div>
|
></div>
|
||||||
</div>
|
</div>
|
||||||
</header>
|
</header>
|
||||||
|
|||||||
@@ -74,7 +74,7 @@
|
|||||||
-->
|
-->
|
||||||
<div
|
<div
|
||||||
id="mokee-user-chip"
|
id="mokee-user-chip"
|
||||||
data-api-base="http://127.0.0.1:9000"
|
data-api-base="http://127.0.0.1:32000"
|
||||||
></div>
|
></div>
|
||||||
</div>
|
</div>
|
||||||
</header>
|
</header>
|
||||||
|
|||||||
@@ -122,7 +122,7 @@ onMounted(fetchUploadedIcons)
|
|||||||
.arrow { color: var(--text-muted); flex-shrink: 0; }
|
.arrow { color: var(--text-muted); flex-shrink: 0; }
|
||||||
|
|
||||||
.icon-overlay {
|
.icon-overlay {
|
||||||
position: fixed; inset: 0; z-index: 9000;
|
position: fixed; inset: 0; z-index: 32000;
|
||||||
background: rgba(0,0,0,0.35);
|
background: rgba(0,0,0,0.35);
|
||||||
display: flex; align-items: center; justify-content: center;
|
display: flex; align-items: center; justify-content: center;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ cur.execute("INSERT INTO sys_user (id, username, password, real_name, email, pho
|
|||||||
test_sid = uid()
|
test_sid = uid()
|
||||||
gw_sid = uid()
|
gw_sid = uid()
|
||||||
cur.execute("INSERT INTO sys_system (id,system_code,system_name,front_url,backend_url,gateway_url,status,description) VALUES (%s,%s,%s,%s,%s,%s,%s,%s)",
|
cur.execute("INSERT INTO sys_system (id,system_code,system_name,front_url,backend_url,gateway_url,status,description) VALUES (%s,%s,%s,%s,%s,%s,%s,%s)",
|
||||||
(test_sid, 'test', '测试系统', 'http://127.0.0.1:5001', 'http://127.0.0.1:9000', 'http://127.0.0.1:9000/test', 1, '测试用业务系统'))
|
(test_sid, 'test', '测试系统', 'http://127.0.0.1:5001', 'http://127.0.0.1:32000', 'http://127.0.0.1:9000/test', 1, '测试用业务系统'))
|
||||||
cur.execute("INSERT INTO sys_system (id,system_code,system_name,front_url,backend_url,gateway_url,icon,sort_order,status,description,doc_token) VALUES (%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s)",
|
cur.execute("INSERT INTO sys_system (id,system_code,system_name,front_url,backend_url,gateway_url,icon,sort_order,status,description,doc_token) VALUES (%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s)",
|
||||||
(gw_sid, 'gateway', '网关管理平台', 'http://127.0.0.1:5001', 'http://127.0.0.1:9000', 'http://127.0.0.1:9000/gateway', '', 0, 1, '统一登录网关管理后台', 'gateway1234567890'))
|
(gw_sid, 'gateway', '网关管理平台', 'http://127.0.0.1:5001', 'http://127.0.0.1:9000', 'http://127.0.0.1:9000/gateway', '', 0, 1, '统一登录网关管理后台', 'gateway1234567890'))
|
||||||
|
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ ALTER TABLE sys_system MODIFY doc_token VARCHAR(128) DEFAULT NULL;
|
|||||||
-- 去重约束
|
-- 去重约束
|
||||||
ALTER TABLE sys_system ADD UNIQUE KEY uk_gateway_url (gateway_url);
|
ALTER TABLE sys_system ADD UNIQUE KEY uk_gateway_url (gateway_url);
|
||||||
-- 更新现有数据: 给每个系统一个不同的 gateway_url
|
-- 更新现有数据: 给每个系统一个不同的 gateway_url
|
||||||
UPDATE sys_system SET gateway_url = CONCAT('http://127.0.0.1:9000/', system_code) WHERE gateway_url = '';
|
UPDATE sys_system SET gateway_url = CONCAT('http://127.0.0.1:32000/', system_code) WHERE gateway_url = '';
|
||||||
|
|
||||||
-- 2. sys_file: 重建为新结构(文件二进制存入数据库)
|
-- 2. sys_file: 重建为新结构(文件二进制存入数据库)
|
||||||
DROP TABLE IF EXISTS sys_file;
|
DROP TABLE IF EXISTS sys_file;
|
||||||
|
|||||||
@@ -7,11 +7,11 @@ VALUES (REPLACE(UUID(),'-',''), 'admin', '$2b$10$ffAZHF6lmUuNV6OJITADXeduD5mMTS0
|
|||||||
|
|
||||||
-- 测试系统
|
-- 测试系统
|
||||||
INSERT INTO sys_system (id, system_code, system_name, front_url, backend_url, gateway_url, status, description)
|
INSERT INTO sys_system (id, system_code, system_name, front_url, backend_url, gateway_url, status, description)
|
||||||
VALUES (REPLACE(UUID(),'-',''), 'test', '测试系统', 'http://127.0.0.1:5001', 'http://127.0.0.1:9000', 'http://127.0.0.1:9000/test', 1, '测试用业务系统');
|
VALUES (REPLACE(UUID(),'-',''), 'test', '测试系统', 'http://127.0.0.1:5001', 'http://127.0.0.1:32000', 'http://127.0.0.1:32000/test', 1, '测试用业务系统');
|
||||||
|
|
||||||
-- Gateway 系统
|
-- Gateway 系统
|
||||||
INSERT INTO sys_system (id, system_code, system_name, front_url, backend_url, gateway_url, icon, sort_order, status, description, doc_token)
|
INSERT INTO sys_system (id, system_code, system_name, front_url, backend_url, gateway_url, icon, sort_order, status, description, doc_token)
|
||||||
VALUES (REPLACE(UUID(),'-',''), 'gateway', '网关管理平台', 'http://127.0.0.1:5001', 'http://127.0.0.1:9000', 'http://127.0.0.1:9000/gateway', '', 0, 1, '统一登录网关管理后台', 'gateway1234567890');
|
VALUES (REPLACE(UUID(),'-',''), 'gateway', '网关管理平台', 'http://127.0.0.1:5001', 'http://127.0.0.1:32000', 'http://127.0.0.1:32000/gateway', '', 0, 1, '统一登录网关管理后台', 'gateway1234567890');
|
||||||
|
|
||||||
-- 查询已插入的ID
|
-- 查询已插入的ID
|
||||||
SELECT id INTO @uid FROM sys_user WHERE username='admin';
|
SELECT id INTO @uid FROM sys_user WHERE username='admin';
|
||||||
|
|||||||
@@ -30,23 +30,23 @@
|
|||||||
↓
|
↓
|
||||||
[业务系统前端] → [统一登录页面(https://login.user.zgitm.com)]
|
[业务系统前端] → [统一登录页面(https://login.user.zgitm.com)]
|
||||||
↓
|
↓
|
||||||
[网关服务(9000)] → [认证用户服务(9001)]
|
[网关服务(32000)] → [认证用户服务(32001)]
|
||||||
↓ ↓
|
↓ ↓
|
||||||
[业务系统后端] ← [业务管理服务(9002)]
|
[业务系统后端] ← [业务管理服务(32002)]
|
||||||
↓
|
↓
|
||||||
[MySQL数据库] ← [Redis缓存]
|
[MySQL数据库] ← [Redis缓存]
|
||||||
```
|
```
|
||||||
|
|
||||||
### 2.2 微服务拆分与职责
|
### 2.2 微服务拆分与职责
|
||||||
|
|
||||||
#### 2.2.1 网关服务(mokee-gateway-gateway)- 端口9000
|
#### 2.2.1 网关服务(mokee-gateway-gateway)- 端口32000
|
||||||
- 统一入口:所有业务系统的接口请求和页面访问统一经过网关
|
- 统一入口:所有业务系统的接口请求和页面访问统一经过网关
|
||||||
- 路由转发:根据配置的系统信息,将请求转发到对应的业务系统后端
|
- 路由转发:根据配置的系统信息,将请求转发到对应的业务系统后端
|
||||||
- 身份认证:校验请求中的Token有效性,拦截未登录请求
|
- 身份认证:校验请求中的Token有效性,拦截未登录请求
|
||||||
- 信息透传:将用户ID、用户名、角色、岗位、系统ID等信息注入请求头,传递给业务系统后端
|
- 信息透传:将用户ID、用户名、角色、岗位、系统ID等信息注入请求头,传递给业务系统后端
|
||||||
- 接口鉴权:校验请求接口是否在业务系统的放行列表中
|
- 接口鉴权:校验请求接口是否在业务系统的放行列表中
|
||||||
|
|
||||||
#### 2.2.2 认证用户服务(mokee-gateway-auth)- 端口9001
|
#### 2.2.2 认证用户服务(mokee-gateway-auth)- 端口32001
|
||||||
- 登录认证:处理用户登录请求,验证账号密码,生成Token
|
- 登录认证:处理用户登录请求,验证账号密码,生成Token
|
||||||
- 用户管理:维护用户基本信息、用户与系统的绑定关系
|
- 用户管理:维护用户基本信息、用户与系统的绑定关系
|
||||||
- 权限管理:维护角色、菜单信息,用户与角色的绑定关系
|
- 权限管理:维护角色、菜单信息,用户与角色的绑定关系
|
||||||
@@ -54,7 +54,7 @@
|
|||||||
- 基础接口:提供获取用户信息、系统信息、菜单路由等基础接口
|
- 基础接口:提供获取用户信息、系统信息、菜单路由等基础接口
|
||||||
- 系统选择:登录成功后判断用户绑定系统数量,返回系统列表或直接跳转
|
- 系统选择:登录成功后判断用户绑定系统数量,返回系统列表或直接跳转
|
||||||
|
|
||||||
#### 2.2.3 业务管理服务(mokee-gateway-admin)- 端口9002
|
#### 2.2.3 业务管理服务(mokee-gateway-admin)- 端口32002
|
||||||
- 系统管理:维护业务系统的基本信息、域名配置、接口放行列表
|
- 系统管理:维护业务系统的基本信息、域名配置、接口放行列表
|
||||||
- 数据字典:维护全局通用的数据字典
|
- 数据字典:维护全局通用的数据字典
|
||||||
- 日志管理:记录用户登录日志和系统操作日志
|
- 日志管理:记录用户登录日志和系统操作日志
|
||||||
|
|||||||
Reference in New Issue
Block a user