feat: 添加部门字段显示并优化用户界面

fix(service): 修复创建时编码重复检查问题
refactor(middleware): 优化CORS中间件配置
style(model): 更新用户模型默认性别值
perf(request): 增强前端请求错误处理
docs(cli): 改进命令行帮助文本
chore: 清理无用配置并更新依赖
This commit is contained in:
zhangtao
2025-11-21 01:11:08 +08:00
parent 30118a4148
commit 749c97f4e3
15 changed files with 237 additions and 122 deletions
@@ -84,6 +84,9 @@ class DeptService:
dept = await DeptCRUD(auth).get(name=data.name)
if dept:
raise CustomException(msg='创建失败,该部门已存在')
obj = await DeptCRUD(auth).get(code=data.code)
if obj:
raise CustomException(msg='创建失败,编码已存在')
dept = await DeptCRUD(auth).create(data=data)
return DeptOutSchema.model_validate(dept).model_dump()
@@ -66,6 +66,9 @@ class RoleService:
role = await RoleCRUD(auth).get(name=data.name)
if role:
raise CustomException(msg='创建失败,该角色已存在')
obj = await RoleCRUD(auth).get(code=data.code)
if obj:
raise CustomException(msg='创建失败,编码已存在')
new_role = await RoleCRUD(auth).create(data=data)
return RoleOutSchema.model_validate(new_role).model_dump()
@@ -97,6 +97,9 @@ class TenantService:
obj = await TenantCRUD(auth).get(name=data.name)
if obj:
raise CustomException(msg='创建失败,名称已存在')
obj = await TenantCRUD(auth).get(code=data.code)
if obj:
raise CustomException(msg='创建失败,编码已存在')
obj = await TenantCRUD(auth).create_crud(data=data)
return TenantOutSchema.model_validate(obj).model_dump()
@@ -78,7 +78,7 @@ class UserModel(MappedBase):
status: Mapped[bool] = mapped_column(Boolean(), default=True, nullable=False, comment="是否启用(True:启用 False:禁用)")
mobile: Mapped[Optional[str]] = mapped_column(String(20),nullable=True,unique=True,comment="手机号")
email: Mapped[Optional[str]] = mapped_column(String(64),nullable=True,unique=True,comment="邮箱")
gender: Mapped[Optional[str]] = mapped_column(String(1), default='0',nullable=True,comment="性别(0:男 1:女 2:未知)")
gender: Mapped[Optional[str]] = mapped_column(String(1), default='2',nullable=True,comment="性别(0:男 1:女 2:未知)")
avatar: Mapped[Optional[str]] = mapped_column(String(500),nullable=True,comment="头像URL地址")
is_superuser: Mapped[bool] = mapped_column(Boolean,default=False,nullable=False,comment="是否超管")
last_login: Mapped[Optional[datetime]] = mapped_column(DateTime(timezone=True),nullable=True,comment="最后登录时间")