mirror of
https://github.com/fastapiadmin/FastapiAdmin.git
synced 2026-09-22 05:02: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:
@@ -74,8 +74,8 @@ class RoleModel(ModelMixin):
|
||||
__permission_strategy__: PermissionFilterStrategy = PermissionFilterStrategy.USER_ROLE
|
||||
|
||||
name: Mapped[str] = mapped_column(String(64), nullable=False, 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="角色编码"
|
||||
)
|
||||
order: Mapped[int] = mapped_column(Integer, nullable=False, default=999, comment="显示排序")
|
||||
data_scope: Mapped[int] = mapped_column(
|
||||
|
||||
Reference in New Issue
Block a user