package models

import (
	"github.com/beego/beego/v2/client/orm"
	"time"
)

// PredictEdbConfCalculateMapping 预测基础指标规则 与 计算预测指标关联关系表
type PredictEdbConfCalculateMapping struct {
	PredictEdbConfCalculateMappingId int       `orm:"column(predict_edb_conf_calculate_mapping_id);pk"`
	EdbInfoId                        int       `description:"指标id"`
	ConfigId                         int       `description:"配置id"`
	FromEdbInfoId                    int       `description:"基础指标id"`
	FromEdbCode                      string    `description:"基础指标编码"`
	FromEdbName                      string    `description:"基础指标名称"`
	FromSource                       int       `description:"基础指标来源"`
	FromSourceName                   string    `description:"基础指标来源名称"`
	FromTag                          string    `description:"来源指标标签"`
	Sort                             int       `description:"计算指标名称排序"`
	CreateTime                       time.Time `description:"创建时间"`
	ModifyTime                       time.Time `description:"修改时间"`
}

// GetPredictEdbConfCalculateMappingListByEdbInfoId 根据预测指标id获取所有关联指标
func GetPredictEdbConfCalculateMappingListByEdbInfoId(edbInfoId int) (list []*PredictEdbConfCalculateMapping, err error) {
	o := orm.NewOrm()
	sql := ` SELECT * from predict_edb_conf_calculate_mapping
			WHERE edb_info_id=? ORDER BY predict_edb_conf_calculate_mapping_id ASC `

	_, err = o.Raw(sql, edbInfoId).QueryRows(&list)
	return
}
