package future_good_edb_info

import "hongze/hongze_yb/global"

// GetFutureGoodEdbInfoListByParentId 根据父级ID获取指标数据列表
func GetFutureGoodEdbInfoListByParentId(parentId int) (list []*FutureGoodEdbInfo, err error) {
	sql := `SELECT * FROM future_good_edb_info WHERE parent_id = ? or  future_good_edb_info_id = ? ORDER BY future_good_edb_info_id ASC `
	err = global.MYSQL["data"].Raw(sql, parentId, parentId).Scan(&list).Error

	return
}

// GetFutureGoodEdbInfoByCode 根据期货code获取 期货指标信息
func GetFutureGoodEdbInfoByCode(futureGoodEdbCode string) (item *FutureGoodEdbInfo, err error) {
	sql := `SELECT * FROM future_good_edb_info WHERE future_good_edb_code = ?  ORDER BY future_good_edb_info_id ASC `
	err = global.MYSQL["data"].Raw(sql, futureGoodEdbCode).First(&item).Error

	return
}

// GetFutureGoodEdbInfo 期货指标
func GetFutureGoodEdbInfo(edbInfoId int) (item *FutureGoodEdbInfo, err error) {
	sql := `SELECT * FROM future_good_edb_info WHERE future_good_edb_info_id = ?  ORDER BY future_good_edb_info_id ASC `
	err = global.MYSQL["data"].Raw(sql, edbInfoId).First(&item).Error

	return
}
