- 21 个模块目录(auth/system/dictionary/configuration/cms/member/region/link/notice/job/log/upload/index) - 每个模块 router.py(合并模块导出多个 router)/schemas.py/service.py/repository.py/models.py - routers/v1.py 与 routers/__init__.py 改为直接引用 modules,前缀与权限串原样保留 - core/middleware.py 懒加载指向 modules.system.menu / modules.log;core/redis_client.py 指向 modules.job.scheduler - apps/views|services|forms 全部改为 re-export 垫片 - 迁移后 grep 守门通过:modules/core 无 apps/extensions 残留引用 - 实测登录、27+ 模块接口、写操作 commit、操作日志落库均正常 Co-Authored-By: Claude <noreply@anthropic.com>
62 lines
3.3 KiB
Python
62 lines
3.3 KiB
Python
from datetime import date
|
|
from typing import Any, Optional
|
|
|
|
from pydantic import BaseModel, Field, model_validator
|
|
|
|
# 用户表单验证
|
|
class UserForm(BaseModel):
|
|
id: Optional[int] = Field(None, description="用户ID")
|
|
realname: str = Field(..., min_length=1, max_length=150, description="用户姓名")
|
|
nickname: str = Field(..., min_length=1, max_length=150, description="用户昵称")
|
|
gender: int = Field(..., ge=1, le=3, description="性别")
|
|
avatar: str = Field(..., min_length=1, max_length=255, description="头像")
|
|
mobile: str = Field(..., min_length=1, max_length=30, description="手机号")
|
|
email: str = Field(..., min_length=1, max_length=30, description="邮箱")
|
|
birthday: date
|
|
dept_id: int = Field(..., ge=0, description="部门ID")
|
|
level_id: int = Field(..., ge=0, description="职级ID")
|
|
position_id: int = Field(..., ge=0, description="岗位ID")
|
|
city: Any = Field(..., description="行政区划")
|
|
province_code: Optional[str] = Field(None, max_length=30, description="省份编码")
|
|
city_code: Optional[str] = Field(None, max_length=30, description="城市编码")
|
|
district_code: Optional[str] = Field(None, max_length=30, description="县区编码")
|
|
address: str = Field(..., min_length=1, max_length=255, description="详细地址")
|
|
username: str = Field(..., min_length=1, max_length=30, description="登录账号")
|
|
password: Optional[str] = Field(None, min_length=6, max_length=128, description="登录密码")
|
|
intro: Optional[str] = Field(None, max_length=255, description="个人简介")
|
|
status: int = Field(..., ge=1, le=2, description="用户状态")
|
|
note: Optional[str] = Field(None, max_length=255, description="用户备注")
|
|
sort: int = Field(..., ge=0, le=99999, description="用户排序")
|
|
roles: Optional[Any] = Field(default=[], description="用户角色")
|
|
|
|
# 设置状态表单
|
|
class UserStatusForm(BaseModel):
|
|
id: int = Field(..., gt=0, description="用户ID")
|
|
status: int = Field(..., ge=1, le=2, description="用户状态")
|
|
|
|
# 修改个人信息表单验证
|
|
class UserInfoForm(BaseModel):
|
|
realname: str = Field(..., min_length=1, max_length=150, description="用户姓名")
|
|
nickname: str = Field(..., min_length=1, max_length=150, description="用户昵称")
|
|
gender: int = Field(..., ge=1, le=3, description="性别")
|
|
mobile: str = Field(..., min_length=1, max_length=30, description="手机号")
|
|
email: str = Field(..., min_length=1, max_length=30, description="邮箱")
|
|
address: str = Field(..., min_length=1, max_length=255, description="详细地址")
|
|
intro: Optional[str] = Field(None, max_length=255, description="个人简介")
|
|
|
|
# 修改密码表单验证
|
|
class UpdatePwdForm(BaseModel):
|
|
oldPassword: str = Field(..., min_length=6, max_length=128, description="原始密码")
|
|
newPassword: str = Field(..., min_length=6, max_length=128, description="新密码")
|
|
rePassword: str = Field(..., min_length=6, max_length=128, description="确认密码")
|
|
|
|
@model_validator(mode='after')
|
|
def check_passwords_match(self):
|
|
if self.newPassword != self.rePassword:
|
|
raise ValueError('rePassword: 两次输入的密码不一致')
|
|
return self
|
|
|
|
# 重置密码表单
|
|
class ResetPwdForm(BaseModel):
|
|
id: int = Field(..., gt=0, description="用户ID")
|