mirror of
https://github.com/fastapiadmin/FastapiAdmin.git
synced 2026-09-23 05:10:57 +00:00
feat: enforce required department and role codes with validation
- Updated DeptModel and RoleModel to make the `code` field mandatory and unique. - Enhanced DeptCreateSchema and RoleCreateSchema to require a valid `code` format, ensuring it starts with a letter and is 2-16 characters long. - Implemented validation logic in the backend to check for existing codes during updates, preventing duplicates. - Adjusted frontend forms to reflect the required `code` field and added validation messages for user guidance.
This commit is contained in:
@@ -23,8 +23,8 @@ class DeptModel(ModelMixin):
|
||||
|
||||
name: Mapped[str] = mapped_column(String(64), nullable=False, comment="部门名称")
|
||||
order: Mapped[int] = mapped_column(Integer, nullable=False, default=999, comment="显示排序")
|
||||
code: Mapped[str | None] = mapped_column(
|
||||
String(16), nullable=True, index=True, comment="部门编码"
|
||||
code: Mapped[str] = mapped_column(
|
||||
String(16), nullable=False, unique=True, comment="部门编码"
|
||||
)
|
||||
leader: Mapped[str | None] = mapped_column(String(32), default=None, comment="部门负责人")
|
||||
phone: Mapped[str | None] = mapped_column(String(11), default=None, comment="手机")
|
||||
|
||||
Reference in New Issue
Block a user