guarantee-admin-api-v0.2/Modules/Reports/ReportDataObj.py

69 lines
2.0 KiB
Python
Raw Normal View History

2022-06-13 17:17:30 +08:00
from Utils.ObjUtil import SpecObject
from Utils.ValidateUtil import ValidateAttr, Validate
class SectionContent(SpecObject):
"""小节内容"""
paragraph = ValidateAttr(field="paragraph", type=str)
tableName = ValidateAttr(field="tableName", type=str)
unit = ValidateAttr(field="unit", type=str)
table = ValidateAttr(field="table", type=list)
comment = ValidateAttr(field="comment", type=str)
fields_map = {
"paragraph": "段落",
"tableName": "表名",
"unit": "单位",
"table": "表格",
"comment": "注释",
}
class Section(SpecObject):
"""小节"""
section_title = ValidateAttr(field="section_title", type=str)
section_content = ValidateAttr(field="section_content", instance_list=SectionContent)
fields_map = {
"section_title": "小节",
"section_content": "小节内容"
}
class Chapter(SpecObject):
"""章节"""
chapter_title = ValidateAttr(field="chapter_title", type=str)
chapter_content = ValidateAttr(field="chapter_content", instance_list=Section)
fields_map = {
"chapter_title": "章节",
"chapter_content": "章节内容"
}
class ReportDataObj(SpecObject):
"""报告数据"""
cid = ValidateAttr(field='cid', type=str, length=8)
rid = ValidateAttr(field="rid", type=str, length=8)
name = ValidateAttr(field='name', type=str)
year = ValidateAttr(field='year', func=Validate.year_format)
industry = ValidateAttr(field='industry', type=list)
title = ValidateAttr(field='title', type=str)
content = ValidateAttr(field='content', instance_list=Chapter)
generate_date = ValidateAttr(field='generate_date', func=Validate.time_format)
fields_map = {
"cid": "企业ID",
"rid": "评价ID",
"name": "企业名称",
"year": "评价年度",
"industry": "行业选择",
"title": "报告标题",
"content": "报告内容",
"generate_date": "生成日期"
}