from Utils.ObjUtil import SpecObject from Utils.ValidateUtil import ValidateAttr, Validate class ScoreModelObj(SpecObject): """打分模型""" class LevelSetting(SpecObject): """级别设置""" level = ValidateAttr(field='level', type=str) score = ValidateAttr(field='score', type=[int, float]) position = ValidateAttr(field='position', type=[int, float]) fields_map = { "level": "级别", "score": "得分", "position": "分位" } class Dimension(SpecObject): """维度""" class FirstIndex(SpecObject): """一级指标""" class SecondaryIndex(SpecObject): """二级指标""" class ScoreSetting(SpecObject): """打分设置""" pattern = ValidateAttr(field="pattern", type=str) interval = ValidateAttr(field="interval", type=list) score_position = ValidateAttr(field="score_position", type=list) fields_map = { "pattern": "模式", "interval": "区间", "score_position": "打分位" } standard_score = ValidateAttr(field="standard_score", type=str) score_setting = ValidateAttr(field="score_setting", type=ScoreSetting) name = ValidateAttr(field="name", type=str) fields_map = { "standard_score": "标准分", "score_setting": "打分设置", "name": "指标名称" } name = ValidateAttr(field="name", type=str) secondary_index = ValidateAttr(field="secondary_index", instance_list=SecondaryIndex) fields_map = { "name": "指标名称", "secondary_index": "二级指标" } name = ValidateAttr(field="name", type=str) first_index = ValidateAttr(field="first_index", instance_list=FirstIndex) fields_map = { "name": "维度名称", "first_index": "一级指标" } model_name = ValidateAttr(field="model_name", type=str) level_setting = ValidateAttr(field="level_setting", instance_list=LevelSetting) dimension = ValidateAttr(field="dimension", instance_list=Dimension) author = ValidateAttr(field="author", type=str) edit_date = ValidateAttr(field="edit_date", func=Validate.date_format) tags = ValidateAttr(field="tags", type=list) status = ValidateAttr(field="status", type=str, in_list=['normal', 'lock']) fields_map = { "model_name": "模型名称", "level_setting": "级别设置", "dimension": "维度", "author": "作者", "date": "日期", "tags": "标签", "status": "状态" } class ScoreIndexObj(SpecObject): """打分指标""" class BindSet(SpecObject): """构建模型""" class Params(SpecObject): """传入参数""" param = ValidateAttr(field="param", type=str) describe = ValidateAttr(field="describe", type=str) data_bind = ValidateAttr(field="data_bind", type=[int, float]) fields_map = { "param": "参数", "describe": "说明", "data_bind": "数据绑定" } type = ValidateAttr(field='type', type=str) name = ValidateAttr(field='name', type=str) params = ValidateAttr(field='params', type=Params) fields_map = { "type": "类型", "name": "名称", "params": "传入参数" } index_name = ValidateAttr(field="index_name", type=str) bind_set = ValidateAttr(field="bind_set", type=BindSet) fields_map = { "index_name": "指标名称", "bind_set": "绑定设置" }