♻️ 重构管理后台冗余逻辑与优化数据持久化模式 - #5
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PR 标题
♻️ 重构管理后台冗余逻辑与优化数据持久化模式
关联 Issue
Closes # (如果适用)
简要概述 (Summary)
本项目对
CQUT-Auth系统的多个模块进行了彻底的去冗余(DRY)重构与架构调整,核心关注点为基础工具库精简、身份认证流程解耦、数据持久化事务模板消减,以及管理台管理员开通体验提升。全部修改已被拆分为 6 个清晰的、职责独立的 Git Commits。
变更类型 (Type of Change)
详细变更清单 (Detailed Changes)
1. 基础编解码与公共工具库 (
src/utils.ts,src/crypto.ts)Buffer.toString("base64url"),提高处理效率及可维护性。parseCommaKeyValuePairs,整合 scrypt 加密参数以及统一校验解析逻辑。2. 身份认证与 Provider 模块 (
src/identity/)src/identity/utils.ts文件,全部引用收拢至主src/utils.ts。subject-profile.service.ts中抽取私有updateProfile统一整合setEmail和setVerifiedEmail的流程。node:timers/promises的setTimeout异步等待,替代自定义 Promise 延时器。3. 持久化存储层 (
src/persistence/)contracts.ts中抽离出buildArtifactCleanupSql动态 SQL 生成器,消除artifact-cleanup.scheduler.ts和oidc-artifact.repository.ts中重复的 CTE 删除语句。oidc-client.repository.ts实现通用的transaction(pool, fn)回调包装器,隔离BEGIN / COMMIT / ROLLBACK模版代码,使写入操作更健壮。4. 易用性与管理员配置优化 (
web/src/components/layout/)Subject ID并接入一键复制,彻底解决之前用户配置OIDC_ADMIN_SUBJECT_IDS时难以查阅自身 ID 的痛点。验证与测试 (Verification & Testing)
pnpm build和pnpm lint全程无类型或格式问题。pnpm test,所有 151 个服务端单元测试 以及 3 个 Refine 前端测试 全部高分通过(无任何失败用例)。