This commit is contained in:
孙小云 2025-07-19 10:24:08 +08:00
parent d053df88d1
commit c4c8e9989b
12 changed files with 26 additions and 59 deletions

View File

@ -65,55 +65,3 @@
> 主键id > 主键id
> 外键tenant_id 关联 tenants.idsubsystem_id 关联 subsystems.id > 外键tenant_id 关联 tenants.idsubsystem_id 关联 subsystems.id
## 二、子系统(如订单、支付等)表结构
### 1. 业务用户表users 和 统一认证网关(主工程) 用的不是一个数据库,表名可以重复)
| 字段名 | 类型 | 说明 |
| -------------- | -------------- | -------------------------- |
| id | BIGINT | 主键,自增 |
| user_id | BIGINT | 关联统一认证网关 users 表的 id 字段,外键->users.id |
| username | VARCHAR(50) | 业务系统内用户名 |
| ... | ... | 业务相关字段(如地址、类型等)|
| create_time | TIMESTAMP | 创建时间 |
| update_time | TIMESTAMP | 更新时间 |
> 主键id
> 外键user_id 关联统一认证网关 users.idusers 表为统一认证主工程的用户表)
---
**主外键关系说明:**
- users.tenant_id → tenants.id
- users.subsystem_id → subsystems.id
- tenant_subsystem_permissions.tenant_id → tenants.id
- tenant_subsystem_permissions.subsystem_id → subsystems.id
- 子系统业务用户表 user_id → 统一认证 users.id
- 业务数据表 user_id → 统一认证 users.id
-- 插入租户
INSERT INTO tenants (id, tenant_code, tenant_name, description, status, create_time, update_time)
VALUES (1, 'test-tenant', '测试租户', '测试用租户', 'ACTIVE', NOW(), NOW());
-- 插入用户
INSERT INTO users (
id, username, password, user_type, tenant_id, subsystem_id, email, phone, real_name, status, create_time, update_time
) VALUES (
1,
'testuser',
'$2a$10$wH6Qw6Qw6Qw6Qw6Qw6Qw6uQw6Qw6Qw6Qw6Qw6Qw6Qw6Qw6Qw6Qw6', -- 密码123456的BCrypt加密
'TENANT',
1,
NULL,
'testuser@example.com',
'13800000000',
'测试用户',
'ACTIVE',
NOW(),
NOW()
);
租户ID1 或 租户名test-tenant
用户名testuser
密码123456

View File

@ -4,12 +4,7 @@
<option name="autoReloadType" value="SELECTIVE" /> <option name="autoReloadType" value="SELECTIVE" />
</component> </component>
<component name="ChangeListManager"> <component name="ChangeListManager">
<list default="true" id="b713637a-3b19-4c5b-9e88-95e35dd83d2e" name="更改" comment=""> <list default="true" id="b713637a-3b19-4c5b-9e88-95e35dd83d2e" name="更改" comment="" />
<change beforePath="$PROJECT_DIR$/../oidc/src/main/java/com/tuoheng/oauth/oidc/config/SecurityConfig.java" beforeDir="false" afterPath="$PROJECT_DIR$/../oidc/src/main/java/com/tuoheng/oauth/oidc/config/SecurityConfig.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/../resourceservice/target/classes/application.properties" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/../resourceservice/target/classes/com/tuoheng/resourceservice/HelloController.class" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/../resourceservice/target/classes/com/tuoheng/resourceservice/ResourceServiceApplication.class" beforeDir="false" />
</list>
<option name="SHOW_DIALOG" value="false" /> <option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" /> <option name="HIGHLIGHT_CONFLICTS" value="true" />
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" /> <option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
@ -109,7 +104,9 @@
<workItem from="1752745264222" duration="2832000" /> <workItem from="1752745264222" duration="2832000" />
<workItem from="1752751160098" duration="1320000" /> <workItem from="1752751160098" duration="1320000" />
<workItem from="1752798688493" duration="8426000" /> <workItem from="1752798688493" duration="8426000" />
<workItem from="1752886146802" duration="618000" /> <workItem from="1752886146802" duration="788000" />
<workItem from="1752887366989" duration="14000" />
<workItem from="1752887418038" duration="62000" />
</task> </task>
<servers /> <servers />
</component> </component>

View File

@ -0,0 +1,15 @@
server.port=8080
spring.cloud.gateway.routes[0].id=resource-server-a
spring.cloud.gateway.routes[0].uri=http://localhost:8081
spring.cloud.gateway.routes[0].predicates[0]=Path=/a/**
spring.cloud.gateway.routes[0].filters[0]=RewritePath=/a/(?<segment>.*), /api/${segment}
spring.cloud.gateway.routes[0].filters[1]=TokenRelay
spring.cloud.gateway.routes[1].id=resource-server-b
spring.cloud.gateway.routes[1].uri=http://localhost:8082
spring.cloud.gateway.routes[1].predicates[0]=Path=/b/**
spring.cloud.gateway.routes[1].filters[0]=RewritePath=/b/(?<segment>.*), /api/${segment}
spring.cloud.gateway.routes[1].filters[1]=TokenRelay
spring.security.oauth2.resourceserver.jwt.jwk-set-uri=http://localhost:9000/oauth2/jwks

View File

@ -161,6 +161,11 @@
<input type="password" id="password" name="password" required autocomplete="current-password"> <input type="password" id="password" name="password" required autocomplete="current-password">
</div> </div>
<div class="form-group">
<label for="tenant-code">租户代码</label>
<input type="text" id="tenant-code" name="tenant-code" placeholder="请输入租户代码" autocomplete="off">
</div>
<div class="checkbox-group"> <div class="checkbox-group">
<input type="checkbox" id="remember-me" name="remember-me"> <input type="checkbox" id="remember-me" name="remember-me">
<label for="remember-me">记住我</label> <label for="remember-me">记住我</label>

View File

@ -0,0 +1 @@
server.port=8081

View File

@ -0,0 +1 @@
server.port=8082