api-datamanager/Modules/Models/SModels/SModelsObj.py

118 lines
3.9 KiB
Python
Raw Normal View History

2022-06-23 16:44:09 +08:00
from Utils.ObjUtil import SpecObject
from Utils.ValidateUtil import ValidateAttr, Validate
class ScoreModelObj(SpecObject):
"""打分模型"""
2022-07-01 14:36:02 +08:00
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": "分位"
}
2022-06-23 16:44:09 +08:00
class Dimension(SpecObject):
"""维度"""
2022-07-01 14:36:02 +08:00
class FirstIndex(SpecObject):
2022-06-23 16:44:09 +08:00
"""一级指标"""
class SecondaryIndex(SpecObject):
"""二级指标"""
class ScoreSetting(SpecObject):
"""打分设置"""
pattern = ValidateAttr(field="pattern", type=str)
2022-07-01 14:36:02 +08:00
interval = ValidateAttr(field="interval", type=list)
score_position = ValidateAttr(field="score_position", type=list)
2022-06-23 16:44:09 +08:00
fields_map = {
"pattern": "模式",
2022-07-01 14:36:02 +08:00
"interval": "区间",
"score_position": "打分位"
2022-06-23 16:44:09 +08:00
}
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": "指标名称"
2022-06-23 16:44:09 +08:00
}
name = ValidateAttr(field="name", type=str)
secondary_index = ValidateAttr(field="secondary_index", instance_list=SecondaryIndex)
fields_map = {
"name": "指标名称",
"secondary_index": "二级指标"
2022-06-23 16:44:09 +08:00
}
name = ValidateAttr(field="name", type=str)
2022-07-01 14:36:02 +08:00
first_index = ValidateAttr(field="first_index", instance_list=FirstIndex)
2022-06-23 16:44:09 +08:00
fields_map = {
"name": "维度名称",
2022-07-01 14:36:02 +08:00
"first_index": "一级指标"
2022-06-23 16:44:09 +08:00
}
model_name = ValidateAttr(field="model_name", type=str)
2022-07-01 14:36:02 +08:00
level_setting = ValidateAttr(field="level_setting", instance_list=LevelSetting)
2022-06-23 16:44:09 +08:00
dimension = ValidateAttr(field="dimension", instance_list=Dimension)
2022-07-01 14:36:02 +08:00
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'])
2022-06-23 16:44:09 +08:00
fields_map = {
"model_name": "模型名称",
2022-07-01 14:36:02 +08:00
"level_setting": "级别设置",
2022-06-23 16:44:09 +08:00
"dimension": "维度",
"author": "作者",
"date": "日期",
2022-07-01 14:36:02 +08:00
"tags": "标签",
"status": "状态"
2022-06-23 16:44:09 +08:00
}
2022-07-01 14:36:02 +08:00
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": "绑定设置"
}