fix:角色设计修改

This commit is contained in:
waner
2026-04-22 18:29:00 +08:00
parent 1fc32dbcf0
commit a3fd33a6e4
34 changed files with 1819 additions and 338 deletions
@@ -244,14 +244,7 @@ CREATE TABLE IF NOT EXISTS tms_role_account (
role_code VARCHAR(64) NOT NULL,
display_name VARCHAR(128) NOT NULL,
required_ukey_count INT NOT NULL,
password_hash VARCHAR(256) NOT NULL,
password_salt VARCHAR(128) NOT NULL,
status VARCHAR(32) NOT NULL,
need_change_password TINYINT(1) NOT NULL DEFAULT 1,
failed_count INT NOT NULL DEFAULT 0,
locked_until DATETIME(3) NULL,
last_login_at DATETIME(3) NULL,
last_active_at DATETIME(3) NULL,
create_time DATETIME(3) NOT NULL,
update_time DATETIME(3) NOT NULL,
UNIQUE KEY uk_tms_role_account_role_code (role_code)
@@ -281,6 +274,7 @@ CREATE TABLE IF NOT EXISTS tms_auth_user_account (
password_hash VARCHAR(256) NOT NULL,
password_salt VARCHAR(128) NOT NULL,
status VARCHAR(32) NOT NULL,
need_change_password TINYINT(1) NOT NULL DEFAULT 1,
failed_count INT NOT NULL DEFAULT 0,
locked_until DATETIME(3) NULL,
last_login_at DATETIME(3) NULL,
@@ -291,11 +285,32 @@ CREATE TABLE IF NOT EXISTS tms_auth_user_account (
KEY idx_tms_auth_user_account_role_code (role_code)
);
CREATE TABLE IF NOT EXISTS tms_auth_full_account (
id BIGINT PRIMARY KEY,
role_code VARCHAR(64) NOT NULL,
uid INT NOT NULL,
account_name VARCHAR(64) NOT NULL,
display_name VARCHAR(128) NOT NULL,
password_hash VARCHAR(256) NOT NULL,
password_salt VARCHAR(128) NOT NULL,
status VARCHAR(32) NOT NULL,
need_change_password TINYINT(1) NOT NULL DEFAULT 1,
failed_count INT NOT NULL DEFAULT 0,
locked_until DATETIME(3) NULL,
last_login_at DATETIME(3) NULL,
last_active_at DATETIME(3) NULL,
create_time DATETIME(3) NOT NULL,
update_time DATETIME(3) NOT NULL,
UNIQUE KEY uk_tms_auth_full_account_role_uid (role_code, uid),
UNIQUE KEY uk_tms_auth_full_account_name (account_name),
KEY idx_tms_auth_full_account_role_code (role_code)
);
CREATE TABLE IF NOT EXISTS tms_auth_session (
id BIGINT PRIMARY KEY,
session_token VARCHAR(128) NOT NULL,
role_code VARCHAR(64) NOT NULL,
authenticated_users_json JSON NULL,
authenticated_principals_json JSON NULL,
auth_method VARCHAR(32) NOT NULL,
auth_level VARCHAR(32) NOT NULL,
issued_at DATETIME(3) NOT NULL,
@@ -379,14 +394,7 @@ INSERT IGNORE INTO tms_role_account (
role_code,
display_name,
required_ukey_count,
password_hash,
password_salt,
status,
need_change_password,
failed_count,
locked_until,
last_login_at,
last_active_at,
create_time,
update_time
)
@@ -396,14 +404,7 @@ VALUES
'SUPER_ADMIN',
'超级管理员',
2,
'Viuew8WE+qziUZwGGU0x25cUpzsTF+QvQFU0uhb+yVA=',
'init-super-admin-salt-20260325',
'UNENABLED',
1,
0,
NULL,
NULL,
NULL,
CURRENT_TIMESTAMP(3),
CURRENT_TIMESTAMP(3)
),
@@ -412,14 +413,7 @@ VALUES
'KEY_ADMIN',
'密钥管理员',
1,
'/xqmDy3A/q9X5p7XWznIPSBabQ6bxTLAPgtHQ6Be33c=',
'init-key-admin-salt-20260325',
'ACTIVE',
1,
0,
NULL,
NULL,
NULL,
CURRENT_TIMESTAMP(3),
CURRENT_TIMESTAMP(3)
),
@@ -428,14 +422,7 @@ VALUES
'AUDIT_ADMIN',
'审计管理员',
1,
'j/J1LKyUOzVEJfbbHe2dwKBKNdabRk502olk/LWIwhg=',
'init-audit-admin-salt-20260325',
'UNENABLED',
1,
0,
NULL,
NULL,
NULL,
CURRENT_TIMESTAMP(3),
CURRENT_TIMESTAMP(3)
),
@@ -444,14 +431,7 @@ VALUES
'OPS_ADMIN',
'运维管理员',
1,
'2e9F4aCgsDb+AuD1LrBEqEg8yjy3ODo27UHtx06vj/A=',
'init-ops-admin-salt-20260325',
'UNENABLED',
1,
0,
NULL,
NULL,
NULL,
CURRENT_TIMESTAMP(3),
CURRENT_TIMESTAMP(3)
);
@@ -464,6 +444,7 @@ INSERT IGNORE INTO tms_auth_user_account (
password_hash,
password_salt,
status,
need_change_password,
failed_count,
locked_until,
last_login_at,
@@ -480,6 +461,7 @@ VALUES
'Viuew8WE+qziUZwGGU0x25cUpzsTF+QvQFU0uhb+yVA=',
'init-super-admin-salt-20260325',
'ACTIVE',
1,
0,
NULL,
NULL,
@@ -495,6 +477,7 @@ VALUES
'Viuew8WE+qziUZwGGU0x25cUpzsTF+QvQFU0uhb+yVA=',
'init-super-admin-salt-20260325',
'ACTIVE',
1,
0,
NULL,
NULL,
@@ -510,6 +493,7 @@ VALUES
'/xqmDy3A/q9X5p7XWznIPSBabQ6bxTLAPgtHQ6Be33c=',
'init-key-admin-salt-20260325',
'ACTIVE',
1,
0,
NULL,
NULL,
@@ -525,6 +509,7 @@ VALUES
'j/J1LKyUOzVEJfbbHe2dwKBKNdabRk502olk/LWIwhg=',
'init-audit-admin-salt-20260325',
'ACTIVE',
1,
0,
NULL,
NULL,
@@ -540,6 +525,111 @@ VALUES
'2e9F4aCgsDb+AuD1LrBEqEg8yjy3ODo27UHtx06vj/A=',
'init-ops-admin-salt-20260325',
'ACTIVE',
1,
0,
NULL,
NULL,
NULL,
CURRENT_TIMESTAMP(3),
CURRENT_TIMESTAMP(3)
);
INSERT IGNORE INTO tms_auth_full_account (
id,
role_code,
uid,
account_name,
display_name,
password_hash,
password_salt,
status,
need_change_password,
failed_count,
locked_until,
last_login_at,
last_active_at,
create_time,
update_time
)
VALUES
(
12101,
'SUPER_ADMIN',
1,
'super-admin-full-01',
'超级管理员UKey席位一',
'Viuew8WE+qziUZwGGU0x25cUpzsTF+QvQFU0uhb+yVA=',
'init-super-admin-salt-20260325',
'ACTIVE',
1,
0,
NULL,
NULL,
NULL,
CURRENT_TIMESTAMP(3),
CURRENT_TIMESTAMP(3)
),
(
12102,
'SUPER_ADMIN',
2,
'super-admin-full-02',
'超级管理员UKey席位二',
'Viuew8WE+qziUZwGGU0x25cUpzsTF+QvQFU0uhb+yVA=',
'init-super-admin-salt-20260325',
'ACTIVE',
1,
0,
NULL,
NULL,
NULL,
CURRENT_TIMESTAMP(3),
CURRENT_TIMESTAMP(3)
),
(
12103,
'KEY_ADMIN',
1,
'key-admin-full-01',
'密钥管理员UKey席位',
'/xqmDy3A/q9X5p7XWznIPSBabQ6bxTLAPgtHQ6Be33c=',
'init-key-admin-salt-20260325',
'ACTIVE',
1,
0,
NULL,
NULL,
NULL,
CURRENT_TIMESTAMP(3),
CURRENT_TIMESTAMP(3)
),
(
12104,
'AUDIT_ADMIN',
1,
'audit-admin-full-01',
'审计管理员UKey席位',
'j/J1LKyUOzVEJfbbHe2dwKBKNdabRk502olk/LWIwhg=',
'init-audit-admin-salt-20260325',
'ACTIVE',
1,
0,
NULL,
NULL,
NULL,
CURRENT_TIMESTAMP(3),
CURRENT_TIMESTAMP(3)
),
(
12105,
'OPS_ADMIN',
1,
'ops-admin-full-01',
'运维管理员UKey席位',
'2e9F4aCgsDb+AuD1LrBEqEg8yjy3ODo27UHtx06vj/A=',
'init-ops-admin-salt-20260325',
'ACTIVE',
1,
0,
NULL,
NULL,
@@ -0,0 +1,67 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.cisd.tms.modules.auth.mapper.AuthFullAccountMapper">
<resultMap id="AuthFullAccountResultMap" type="com.cisd.tms.modules.auth.entity.AuthFullAccountEntity">
<id property="id" column="id"/>
<result property="roleCode" column="role_code"/>
<result property="uid" column="uid"/>
<result property="accountName" column="account_name"/>
<result property="displayName" column="display_name"/>
<result property="passwordHash" column="password_hash"/>
<result property="passwordSalt" column="password_salt"/>
<result property="status" column="status"/>
<result property="needChangePassword" column="need_change_password"/>
<result property="failedCount" column="failed_count"/>
<result property="lockedUntil" column="locked_until"/>
<result property="lastLoginAt" column="last_login_at"/>
<result property="lastActiveAt" column="last_active_at"/>
<result property="createTime" column="create_time"/>
<result property="updateTime" column="update_time"/>
</resultMap>
<select id="selectByRoleCodeAndUid" resultMap="AuthFullAccountResultMap">
SELECT id,
role_code,
uid,
account_name,
display_name,
password_hash,
password_salt,
status,
need_change_password,
failed_count,
locked_until,
last_login_at,
last_active_at,
create_time,
update_time
FROM tms_auth_full_account
WHERE role_code = #{roleCode}
AND uid = #{uid}
LIMIT 1
</select>
<select id="selectByRoleCode" resultMap="AuthFullAccountResultMap">
SELECT id,
role_code,
uid,
account_name,
display_name,
password_hash,
password_salt,
status,
need_change_password,
failed_count,
locked_until,
last_login_at,
last_active_at,
create_time,
update_time
FROM tms_auth_full_account
WHERE role_code = #{roleCode}
ORDER BY uid ASC
</select>
</mapper>
@@ -8,7 +8,7 @@
<id property="id" column="id"/>
<result property="sessionToken" column="session_token"/>
<result property="roleCode" column="role_code"/>
<result property="authenticatedUsersJson" column="authenticated_users_json"/>
<result property="authenticatedPrincipalsJson" column="authenticated_principals_json"/>
<result property="authMethod" column="auth_method"/>
<result property="authLevel" column="auth_level"/>
<result property="issuedAt" column="issued_at"/>
@@ -23,7 +23,7 @@
SELECT id,
session_token,
role_code,
authenticated_users_json,
authenticated_principals_json,
auth_method,
auth_level,
issued_at,
@@ -36,4 +36,47 @@
WHERE session_token = #{sessionToken}
LIMIT 1
</select>
<select id="selectActiveByRoleCodeAndAuthLevel" resultMap="AuthSessionResultMap">
SELECT id,
session_token,
role_code,
authenticated_principals_json,
auth_method,
auth_level,
issued_at,
last_active_at,
expires_at,
logout_at,
create_time,
update_time
FROM tms_auth_session
WHERE role_code = #{roleCode}
AND auth_level = #{authLevel}
AND logout_at IS NULL
AND expires_at IS NOT NULL
AND expires_at > #{now}
</select>
<select id="selectActiveByRoleCodeAndAuthLevelAndAuthenticatedPrincipalsJson" resultMap="AuthSessionResultMap">
SELECT id,
session_token,
role_code,
authenticated_principals_json,
auth_method,
auth_level,
issued_at,
last_active_at,
expires_at,
logout_at,
create_time,
update_time
FROM tms_auth_session
WHERE role_code = #{roleCode}
AND auth_level = #{authLevel}
AND authenticated_principals_json = #{authenticatedPrincipalsJson}
AND logout_at IS NULL
AND expires_at IS NOT NULL
AND expires_at > #{now}
</select>
</mapper>
@@ -12,6 +12,7 @@
<result property="passwordHash" column="password_hash"/>
<result property="passwordSalt" column="password_salt"/>
<result property="status" column="status"/>
<result property="needChangePassword" column="need_change_password"/>
<result property="failedCount" column="failed_count"/>
<result property="lockedUntil" column="locked_until"/>
<result property="lastLoginAt" column="last_login_at"/>
@@ -28,6 +29,7 @@
password_hash,
password_salt,
status,
need_change_password,
failed_count,
locked_until,
last_login_at,
@@ -47,6 +49,7 @@
password_hash,
password_salt,
status,
need_change_password,
failed_count,
locked_until,
last_login_at,
@@ -9,14 +9,7 @@
<result property="roleCode" column="role_code"/>
<result property="displayName" column="display_name"/>
<result property="requiredUkeyCount" column="required_ukey_count"/>
<result property="passwordHash" column="password_hash"/>
<result property="passwordSalt" column="password_salt"/>
<result property="status" column="status"/>
<result property="needChangePassword" column="need_change_password"/>
<result property="failedCount" column="failed_count"/>
<result property="lockedUntil" column="locked_until"/>
<result property="lastLoginAt" column="last_login_at"/>
<result property="lastActiveAt" column="last_active_at"/>
<result property="createTime" column="create_time"/>
<result property="updateTime" column="update_time"/>
</resultMap>
@@ -26,14 +19,7 @@
role_code,
display_name,
required_ukey_count,
password_hash,
password_salt,
status,
need_change_password,
failed_count,
locked_until,
last_login_at,
last_active_at,
create_time,
update_time
FROM tms_role_account