按 2026-11-02 需求补齐计划交付后端能力: - 角色授权:权限目录化,接口统一准入校验,未登记默认拒绝; 管理员判断改为按数据库角色重新判定,防止权限码持有者绕过 - 系统监控:单进程采集资源、请求与异常指标,分钟级聚合, 阈值配置化;敏感配置增加 repr 保护,Redis 密码 URL 转义 - 试用期计提:按回款日判定并写入快照,年度结清与调整单联动; 人员模型补试用期、离职日期与工资版本历史字段 - 计提模板:公式骨架受控,页面维护名称与参数绑定 - T+ 采集:自动化配置表与进度查询 内置角色禁停用保护对齐模块注释;核算规则版本提为常量并 补充批量核算失败堆栈日志。 影响范围:后端全部模块、数据库迁移 V22-V28 验证:uv run ruff check 通过;922 个单元测试全部通过; 集成测试因本机 MySQL 数据卷被其他容器锁定暂未运行
46 lines
1.7 KiB
Python
46 lines
1.7 KiB
Python
"""授权请求版本化,禁止匿名覆盖他人的修改。"""
|
|
from typing import Literal
|
|
|
|
from pydantic import BaseModel, ConfigDict, Field, field_validator
|
|
|
|
|
|
class PermissionOverrideIn(BaseModel):
|
|
model_config = ConfigDict(extra="forbid")
|
|
permission_code: str = Field(min_length=1, max_length=128)
|
|
effect: Literal["ALLOW", "DENY"]
|
|
|
|
|
|
class AuthorizationPreviewIn(BaseModel):
|
|
model_config = ConfigDict(extra="forbid")
|
|
role_codes: list[str] = Field(default_factory=list, max_length=100)
|
|
# 保留空字段兼容旧客户端;不再允许个人允许/禁止覆盖角色授权。
|
|
overrides: list[PermissionOverrideIn] = Field(default_factory=list, max_length=0)
|
|
|
|
|
|
class UserAuthorizationIn(AuthorizationPreviewIn):
|
|
expected_revision: int = Field(ge=1)
|
|
reason: str = Field(min_length=1, max_length=500)
|
|
|
|
@field_validator("reason")
|
|
@classmethod
|
|
def reason_required(cls, value):
|
|
if not value.strip():
|
|
raise ValueError("修改原因不能为空")
|
|
return value.strip()
|
|
|
|
|
|
class RolePermissionsIn(BaseModel):
|
|
model_config = ConfigDict(extra="forbid")
|
|
permission_codes: list[str] = Field(max_length=300)
|
|
expected_revision: int = Field(ge=1)
|
|
reason: str = Field(min_length=1, max_length=500)
|
|
_reason = field_validator("reason")(UserAuthorizationIn.reason_required.__func__)
|
|
|
|
|
|
class AuthorizationSettingsIn(BaseModel):
|
|
model_config = ConfigDict(extra="forbid")
|
|
maker_user_id: int | None = Field(default=None, ge=1)
|
|
expected_revision: int = Field(ge=1)
|
|
reason: str = Field(min_length=1, max_length=500)
|
|
_reason = field_validator("reason")(UserAuthorizationIn.reason_required.__func__)
|