|
@ -1,8 +1,9 @@ |
|
|
from pydantic import BaseModel, ConfigDict |
|
|
from pydantic import BaseModel, ConfigDict, Field |
|
|
from pydantic.alias_generators import to_camel |
|
|
from pydantic.alias_generators import to_camel |
|
|
from typing import Union, Optional, List |
|
|
from typing import Union, Optional, List, Literal |
|
|
from datetime import datetime |
|
|
from datetime import datetime |
|
|
from module_admin.annotation.pydantic_annotation import as_query, as_form |
|
|
from module_admin.annotation.pydantic_annotation import as_query, as_form |
|
|
|
|
|
from module_admin.annotation.validate_annotation import NotBlank, Size, Xss |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class NoticeModel(BaseModel): |
|
|
class NoticeModel(BaseModel): |
|
@ -11,24 +12,33 @@ class NoticeModel(BaseModel): |
|
|
""" |
|
|
""" |
|
|
model_config = ConfigDict(alias_generator=to_camel, from_attributes=True) |
|
|
model_config = ConfigDict(alias_generator=to_camel, from_attributes=True) |
|
|
|
|
|
|
|
|
notice_id: Optional[int] = None |
|
|
notice_id: Optional[int] = Field(default=None, description='公告ID') |
|
|
notice_title: Optional[str] = None |
|
|
notice_title: Optional[str] = Field(default=None, description='公告标题') |
|
|
notice_type: Optional[str] = None |
|
|
notice_type: Optional[Literal['1', '2']] = Field(default=None, description='公告类型(1通知 2公告)') |
|
|
notice_content: Optional[bytes] = None |
|
|
notice_content: Optional[bytes] = Field(default=None, description='公告内容') |
|
|
status: Optional[str] = None |
|
|
status: Optional[Literal['0', '1']] = Field(default=None, description='公告状态(0正常 1关闭)') |
|
|
create_by: Optional[str] = None |
|
|
create_by: Optional[str] = Field(default=None, description='创建者') |
|
|
create_time: Optional[datetime] = None |
|
|
create_time: Optional[datetime] = Field(default=None, description='创建时间') |
|
|
update_by: Optional[str] = None |
|
|
update_by: Optional[str] = Field(default=None, description='更新者') |
|
|
update_time: Optional[datetime] = None |
|
|
update_time: Optional[datetime] = Field(default=None, description='更新时间') |
|
|
remark: Optional[str] = None |
|
|
remark: Optional[str] = Field(default=None, description='备注') |
|
|
|
|
|
|
|
|
|
|
|
@Xss(field_name='notice_title', message='公告标题不能包含脚本字符') |
|
|
|
|
|
@NotBlank(field_name='notice_title', message='公告标题不能为空') |
|
|
|
|
|
@Size(field_name='notice_title', min_length=0, max_length=50, message='公告标题不能超过50个字符') |
|
|
|
|
|
def get_notice_title(self): |
|
|
|
|
|
return self.notice_title |
|
|
|
|
|
|
|
|
|
|
|
def validate_fields(self): |
|
|
|
|
|
self.get_notice_title() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class NoticeQueryModel(NoticeModel): |
|
|
class NoticeQueryModel(NoticeModel): |
|
|
""" |
|
|
""" |
|
|
通知公告管理不分页查询模型 |
|
|
通知公告管理不分页查询模型 |
|
|
""" |
|
|
""" |
|
|
begin_time: Optional[str] = None |
|
|
begin_time: Optional[str] = Field(default=None, description='开始时间') |
|
|
end_time: Optional[str] = None |
|
|
end_time: Optional[str] = Field(default=None, description='结束时间') |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@as_query |
|
|
@as_query |
|
@ -37,8 +47,8 @@ class NoticePageQueryModel(NoticeQueryModel): |
|
|
""" |
|
|
""" |
|
|
通知公告管理分页查询模型 |
|
|
通知公告管理分页查询模型 |
|
|
""" |
|
|
""" |
|
|
page_num: int = 1 |
|
|
page_num: int = Field(default=1, description='当前页码') |
|
|
page_size: int = 10 |
|
|
page_size: int = Field(default=10, description='每页记录数') |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class DeleteNoticeModel(BaseModel): |
|
|
class DeleteNoticeModel(BaseModel): |
|
@ -47,4 +57,4 @@ class DeleteNoticeModel(BaseModel): |
|
|
""" |
|
|
""" |
|
|
model_config = ConfigDict(alias_generator=to_camel) |
|
|
model_config = ConfigDict(alias_generator=to_camel) |
|
|
|
|
|
|
|
|
notice_ids: str |
|
|
notice_ids: str = Field(description='需要删除的公告ID') |
|
|