chore: 基线提交(重构前代码快照)
- git 初始化 + .gitignore 补全(根 .env / logs / instance / __pycache__ 等) - 修复 utils/.gitignore 误将整个 utils/ 源码层忽略的问题,补入全部工具源码(含 ip2region.xdb) - 含后端全部代码:application / extensions / utils / config / migrations - 含前端 ui/(后续整体迁走) - 不含根 .env(含密钥,本地保留) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,51 @@
|
||||
"""
|
||||
用户角色表单验证模块
|
||||
=============================================================
|
||||
|
||||
提供用户角色相关的表单验证功能,包括:
|
||||
- 用户角色分配表单验证
|
||||
"""
|
||||
|
||||
from wtforms import IntegerField
|
||||
from wtforms.fields.choices import SelectMultipleField
|
||||
from wtforms.validators import DataRequired, NumberRange, Optional
|
||||
|
||||
from application.forms.base_form import BaseForm
|
||||
|
||||
|
||||
# ============================================================
|
||||
# 用户角色表单验证
|
||||
# ============================================================
|
||||
|
||||
class UserRoleForm(BaseForm):
|
||||
"""
|
||||
用户角色表单验证类
|
||||
|
||||
用于用户分配角色权限时的数据验证。
|
||||
|
||||
Attributes:
|
||||
userId: 用户ID(必填,必须大于0)
|
||||
roleIds: 角色ID列表(可选,多个角色ID)
|
||||
"""
|
||||
|
||||
# 用户ID
|
||||
userId = IntegerField(
|
||||
label='用户ID',
|
||||
validators=[
|
||||
DataRequired(message='用户ID不能为空'),
|
||||
NumberRange(min=1, message='用户ID必须大于0')
|
||||
],
|
||||
description='要分配角色的用户ID'
|
||||
)
|
||||
|
||||
# 角色ID列表
|
||||
roleIds = SelectMultipleField(
|
||||
label='角色ID列表',
|
||||
validators=[
|
||||
Optional(),
|
||||
],
|
||||
coerce=int,
|
||||
choices=[],
|
||||
validate_choice=False,
|
||||
description='分配的角色ID列表'
|
||||
)
|
||||
Reference in New Issue
Block a user