from Utils.ObjUtil import SpecObject from Utils.ValidateUtil import ValidateAttr, Validate class QuestionnaireObj(SpecObject): """问卷类""" class Section(SpecObject): """小节""" class Content(SpecObject): """内容详情""" topic = ValidateAttr(field="topic", type=str) version = ValidateAttr(field="version", type=str) question_id = ValidateAttr(field="question_id", type=str) weight = ValidateAttr(field="weight", type=[int, float]) fields_map = { "topic": "题目", "version": "题型", "question_id": "问题ID", "weight": "权重" } section_name = ValidateAttr(field='section_name', type=str) section_content = ValidateAttr(field='section_content', instance_list=Content) total = ValidateAttr(field='total', type=int) fields_map = { "section_name": "小节名称", "section_content": "小节内容", "total": "合计" } class Tags(SpecObject): """标签""" tag_name = ValidateAttr(field='tag_name', type=str) tag_id = ValidateAttr(field='tag_id', type=str) fields_map = { "tag_name": "标签名称", "tag_id": "标签ID" } questionnaire_id = ValidateAttr(field='questionnaire_id', type=str) questionnaire_name = ValidateAttr(field='questionnaire_name', type=str) questionnaire_score = ValidateAttr(field='questionnaire_score', type=int) tags = ValidateAttr(field="tags", instance_list=Tags) author = ValidateAttr(field='author', type=str) date = ValidateAttr(field='date', func=Validate.date_format) section = ValidateAttr(field='section', instance_list=Section) fields_map = { "questionnaire_id": "问卷ID", "questionnaire_name": "问卷名称", "questionnaire_score": "问卷分值", "tags": "标签", "author": "作者", "date": "日期", "section": "小节" }