package factor_edb_series_chart_mapping

import (
	"hongze/hongze_yb/global"
	"time"
)

// FactorEdbSeriesChartMapping 因子指标系列-图表关联
type FactorEdbSeriesChartMapping struct {
	FactorEdbSeriesChartMappingId int       `orm:"column(factor_edb_series_chart_mapping_id);pk"`
	ChartInfoId                   int       `description:"图表ID"`
	Source                        int       `description:"图表来源, 同chart_info表source"`
	CalculateType                 int       `description:"计算方式: 1-相关性"`
	CalculatePars                 string    `description:"计算参数-JSON(如计算窗口等)"`
	CalculateData                 string    `description:"计算数据-JSON(如相关性矩阵等)"`
	FactorEdbSeriesId             int       `description:"因子指标系列ID"`
	EdbInfoId                     int       `description:"指标ID"`
	EdbUsed                       int       `description:"指标是否使用: 0-否; 1-是"`
	CreateTime                    time.Time `description:"创建时间"`
	ModifyTime                    time.Time `description:"修改时间"`
}

// GetChartUsedFactorSeriesEdb 获取图表引用的系列指标
func GetChartUsedFactorSeriesEdb(chartId int) (items []*FactorEdbSeriesChartMapping, err error) {
	sql := `SELECT * FROM factor_edb_series_chart_mapping WHERE chart_info_id = ? AND edb_used = 1`
	err = global.MYSQL["data"].Raw(sql, chartId).Scan(&items).Error
	return
}
