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

90 lines
3.1 KiB
Python

from Utils.ObjUtil import SpecObject
from Utils.ValidateUtil import ValidateAttr, Validate
class ScoreModelObj(SpecObject):
"""打分模型"""
class Dimension(SpecObject):
"""维度"""
class FirstLevelIndex(SpecObject):
"""一级指标"""
class SecondaryIndex(SpecObject):
"""二级指标"""
class ScoreSetting(SpecObject):
"""打分设置"""
class Setting(SpecObject):
"""设置"""
class Interval(SpecObject):
"""区间"""
gt = ValidateAttr(field="", type=[int, float])
lte = ValidateAttr(field="", type=[int, float])
fields_map = {
"gt": "最大值",
"lte": "最小值",
}
percentage = ValidateAttr(field="percentage", type=[int, float])
interval = ValidateAttr(field="interval", type=Interval)
gear = ValidateAttr(field="gear", type=str)
fields_map = {
"percentage": "百分比(%)",
"interval": "区间",
"gear": "档位",
}
pattern = ValidateAttr(field="pattern", type=str)
setting = ValidateAttr(field="setting", instance_list=Setting)
fields_map = {
"pattern": "模式",
"setting": "设置"
}
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_level_index = ValidateAttr(field="first_level_index", instance_list=FirstLevelIndex)
fields_map = {
"name": "维度名称",
"first_level_index": "一级指标"
}
model_name = ValidateAttr(field="model_name", type=str)
dimension = ValidateAttr(field="dimension", instance_list=Dimension)
author = ValidateAttr(field="", type=str)
date = ValidateAttr(field="", func=Validate.date_format)
tags = ValidateAttr(field="", type=list)
fields_map = {
"model_name": "模型名称",
"dimension": "维度",
"author": "作者",
"date": "日期",
"tags": "标签"
}