95 lines
3.2 KiB
Python
95 lines
3.2 KiB
Python
from datetime import datetime
|
|
from pydantic import BaseModel, ConfigDict, Field
|
|
from pydantic.alias_generators import to_camel
|
|
from pydantic_validation_decorator import NotBlank
|
|
from typing import Optional
|
|
from module_admin.annotation.pydantic_annotation import as_query
|
|
|
|
|
|
|
|
|
|
# class RolePairing(BaseModel):
|
|
# """
|
|
# 角色-机器人-映射表对应pydantic模型, 查询角色-机器人结果的返回模型
|
|
# """
|
|
# model_config = ConfigDict(alias_generator=to_camel, from_attributes=True)
|
|
#
|
|
# pairing_id: Optional[int] = Field(default=None, description='主键ID')
|
|
# rolename: Optional[str] = Field(default=None, description='角色名称')
|
|
# detail: Optional[str] = Field(default=None, description='角色介绍')
|
|
# status: Optional[str] = Field(default=None, description='使用情况(0停用,1使用)')
|
|
|
|
class ChangeRobotRoleModel(BaseModel):
|
|
model_config = ConfigDict(alias_generator=to_camel, from_attributes=True)
|
|
robot_id: Optional[int] = Field(default=None, description='机器人ID')
|
|
pairing_id: Optional[int] = Field(default=None, description='主键ID')
|
|
|
|
class PairingModel(BaseModel):
|
|
"""
|
|
角色-机器人-映射表对应pydantic模型
|
|
"""
|
|
model_config = ConfigDict(alias_generator=to_camel, from_attributes=True)
|
|
|
|
pairing_id: Optional[int] = Field(default=None, description='主键ID')
|
|
robot_role_id: Optional[int] = Field(default=None, description='机器人角色ID')
|
|
robot_id: Optional[int] = Field(default=None, description='机器人ID')
|
|
status: Optional[str] = Field(default=None, description='使用情况(0停用,1使用)')
|
|
update_time: Optional[datetime] = Field(default=None, description='更新时间')
|
|
update_by: Optional[str] = Field(default=None, description='修改者')
|
|
|
|
@NotBlank(field_name='robot_role_id', message='机器人角色ID不能为空')
|
|
def get_robot_role_id(self):
|
|
return self.robot_role_id
|
|
|
|
@NotBlank(field_name='robot_id', message='机器人ID不能为空')
|
|
def get_robot_id(self):
|
|
return self.robot_id
|
|
|
|
@NotBlank(field_name='status', message='使用情况(0停用,1使用)不能为空')
|
|
def get_status(self):
|
|
return self.status
|
|
|
|
@NotBlank(field_name='update_time', message='更新时间不能为空')
|
|
def get_update_time(self):
|
|
return self.update_time
|
|
|
|
@NotBlank(field_name='update_by', message='修改者不能为空')
|
|
def get_update_by(self):
|
|
return self.update_by
|
|
|
|
def validate_fields(self):
|
|
self.get_robot_role_id()
|
|
self.get_robot_id()
|
|
self.get_status()
|
|
self.get_update_time()
|
|
self.get_update_by()
|
|
|
|
|
|
|
|
|
|
class PairingQueryModel(PairingModel):
|
|
"""
|
|
角色-机器人-映射不分页查询模型
|
|
"""
|
|
pass
|
|
|
|
|
|
@as_query
|
|
class PairingPageQueryModel(PairingQueryModel):
|
|
"""
|
|
角色-机器人-映射分页查询模型
|
|
"""
|
|
|
|
page_num: int = Field(default=1, description='当前页码')
|
|
page_size: int = Field(default=10, description='每页记录数')
|
|
|
|
|
|
class DeletePairingModel(BaseModel):
|
|
"""
|
|
删除角色-机器人-映射模型
|
|
"""
|
|
|
|
model_config = ConfigDict(alias_generator=to_camel)
|
|
|
|
pairing_ids: str = Field(description='需要删除的主键ID')
|