|
@@ -1,9 +1,9 @@
|
|
|
package data_source
|
|
|
|
|
|
import (
|
|
|
+ "eta/eta_task/global"
|
|
|
"eta/eta_task/utils"
|
|
|
"fmt"
|
|
|
- "github.com/beego/beego/v2/client/orm"
|
|
|
"github.com/rdlucklib/rdluck_tools/paging"
|
|
|
"strings"
|
|
|
"time"
|
|
@@ -150,7 +150,7 @@ func GetEsBaseFromIndexByTableName(tableName string) EsBaseFromIndex {
|
|
|
|
|
|
// BaseFromRzdIndex 睿咨得
|
|
|
type BaseFromRzdIndex struct {
|
|
|
- BaseFromRzdIndexId int `orm:"column(base_from_rzd_index_id);pk"`
|
|
|
+ BaseFromRzdIndexId int `gorm:"column:base_from_rzd_index_id;primaryKey;autoIncrement"`
|
|
|
BaseFromRzdClassifyId int `description:"分类ID"`
|
|
|
IndexCode string `description:"指标编码"`
|
|
|
IndexName string `description:"指标名称"`
|
|
@@ -207,7 +207,7 @@ func (m *BaseFromRzdIndex) Format2SearchDataSource(origin *BaseFromRzdIndex) (it
|
|
|
}
|
|
|
|
|
|
func (m *BaseFromRzdIndex) GetItemsByCondition(condition string, pars []interface{}, fieldArr []string, orderRule string) (items []*BaseFromRzdIndex, err error) {
|
|
|
- o := orm.NewOrmUsingDB("data")
|
|
|
+ o := global.DbMap[utils.DbNameIndex]
|
|
|
fields := strings.Join(fieldArr, ",")
|
|
|
if len(fieldArr) == 0 {
|
|
|
fields = `*`
|
|
@@ -217,13 +217,13 @@ func (m *BaseFromRzdIndex) GetItemsByCondition(condition string, pars []interfac
|
|
|
order = ` ORDER BY ` + orderRule
|
|
|
}
|
|
|
sql := fmt.Sprintf(`SELECT %s FROM base_from_rzd_index WHERE 1=1 %s %s`, fields, condition, order)
|
|
|
- _, err = o.Raw(sql, pars).QueryRows(&items)
|
|
|
+ err = o.Raw(sql, pars...).Find(&items).Error
|
|
|
return
|
|
|
}
|
|
|
|
|
|
// BaseFromHisugarIndex 泛糖科技
|
|
|
type BaseFromHisugarIndex struct {
|
|
|
- BaseFromHisugarIndexId int `orm:"column(base_from_hisugar_index_id);pk"`
|
|
|
+ BaseFromHisugarIndexId int `gorm:"column:base_from_hisugar_index_id;primaryKey;autoIncrement"`
|
|
|
ClassifyId int `description:"分类ID"`
|
|
|
IndexCode string `description:"指标编码"`
|
|
|
IndexName string `description:"指标名称"`
|
|
@@ -283,7 +283,7 @@ func (m *BaseFromHisugarIndex) Format2SearchDataSource(origin *BaseFromHisugarIn
|
|
|
}
|
|
|
|
|
|
func (m *BaseFromHisugarIndex) GetItemsByCondition(condition string, pars []interface{}, fieldArr []string, orderRule string) (items []*BaseFromHisugarIndex, err error) {
|
|
|
- o := orm.NewOrmUsingDB("data")
|
|
|
+ o := global.DbMap[utils.DbNameIndex]
|
|
|
fields := strings.Join(fieldArr, ",")
|
|
|
if len(fieldArr) == 0 {
|
|
|
fields = `*`
|
|
@@ -293,13 +293,13 @@ func (m *BaseFromHisugarIndex) GetItemsByCondition(condition string, pars []inte
|
|
|
order = ` ORDER BY ` + orderRule
|
|
|
}
|
|
|
sql := fmt.Sprintf(`SELECT %s FROM base_from_hisugar_index WHERE 1=1 %s %s`, fields, condition, order)
|
|
|
- _, err = o.Raw(sql, pars).QueryRows(&items)
|
|
|
+ err = o.Raw(sql, pars...).Find(&items).Error
|
|
|
return
|
|
|
}
|
|
|
|
|
|
// BaseFromLyIndex 粮油商务网
|
|
|
type BaseFromLyIndex struct {
|
|
|
- BaseFromLyIndexId int `orm:"column(base_from_ly_index_id);pk"`
|
|
|
+ BaseFromLyIndexId int `gorm:"column:base_from_ly_index_id;primaryKey;autoIncrement"`
|
|
|
BaseFromLyClassifyId int `description:"分类ID"`
|
|
|
IndexCode string `description:"指标编码"`
|
|
|
IndexName string `description:"指标名称"`
|
|
@@ -357,7 +357,7 @@ func (m *BaseFromLyIndex) Format2SearchDataSource(origin *BaseFromLyIndex) (item
|
|
|
}
|
|
|
|
|
|
func (m *BaseFromLyIndex) GetItemsByCondition(condition string, pars []interface{}, fieldArr []string, orderRule string) (items []*BaseFromLyIndex, err error) {
|
|
|
- o := orm.NewOrmUsingDB("data")
|
|
|
+ o := global.DbMap[utils.DbNameIndex]
|
|
|
fields := strings.Join(fieldArr, ",")
|
|
|
if len(fieldArr) == 0 {
|
|
|
fields = `*`
|
|
@@ -367,13 +367,13 @@ func (m *BaseFromLyIndex) GetItemsByCondition(condition string, pars []interface
|
|
|
order = ` ORDER BY ` + orderRule
|
|
|
}
|
|
|
sql := fmt.Sprintf(`SELECT %s FROM base_from_ly_index WHERE 1=1 %s %s`, fields, condition, order)
|
|
|
- _, err = o.Raw(sql, pars).QueryRows(&items)
|
|
|
+ err = o.Raw(sql, pars...).Find(&items).Error
|
|
|
return
|
|
|
}
|
|
|
|
|
|
// BaseFromSciHqIndex 卓创红期
|
|
|
type BaseFromSciHqIndex struct {
|
|
|
- BaseFromSciHqIndexId int `orm:"column(base_from_sci_hq_index_id);pk"`
|
|
|
+ BaseFromSciHqIndexId int `gorm:"column:base_from_sci_hq_index_id;primaryKey;autoIncrement"`
|
|
|
ClassifyId int `description:"分类ID"`
|
|
|
IndexCode string `description:"指标编码"`
|
|
|
IndexName string `description:"指标名称"`
|
|
@@ -434,7 +434,7 @@ func (m *BaseFromSciHqIndex) Format2SearchDataSource(origin *BaseFromSciHqIndex)
|
|
|
}
|
|
|
|
|
|
func (m *BaseFromSciHqIndex) GetItemsByCondition(condition string, pars []interface{}, fieldArr []string, orderRule string) (items []*BaseFromSciHqIndex, err error) {
|
|
|
- o := orm.NewOrmUsingDB("data")
|
|
|
+ o := global.DbMap[utils.DbNameIndex]
|
|
|
fields := strings.Join(fieldArr, ",")
|
|
|
if len(fieldArr) == 0 {
|
|
|
fields = `*`
|
|
@@ -444,13 +444,13 @@ func (m *BaseFromSciHqIndex) GetItemsByCondition(condition string, pars []interf
|
|
|
order = ` ORDER BY ` + orderRule
|
|
|
}
|
|
|
sql := fmt.Sprintf(`SELECT %s FROM base_from_sci_hq_index WHERE 1=1 %s %s`, fields, condition, order)
|
|
|
- _, err = o.Raw(sql, pars).QueryRows(&items)
|
|
|
+ err = o.Raw(sql, pars...).Find(&items).Error
|
|
|
return
|
|
|
}
|
|
|
|
|
|
// BaseFromOilchemIndex 隆众资讯
|
|
|
type BaseFromOilchemIndex struct {
|
|
|
- BaseFromOilchemIndexId int `orm:"column(base_from_oilchem_index_id);pk"`
|
|
|
+ BaseFromOilchemIndexId int `gorm:"column:base_from_oilchem_index_id;primaryKey;autoIncrement"`
|
|
|
ClassifyId int `description:"分类ID"`
|
|
|
IndexCode string `description:"指标编码"`
|
|
|
IndexName string `description:"指标名称"`
|
|
@@ -507,7 +507,7 @@ func (m *BaseFromOilchemIndex) Format2SearchDataSource(origin *BaseFromOilchemIn
|
|
|
}
|
|
|
|
|
|
func (m *BaseFromOilchemIndex) GetItemsByCondition(condition string, pars []interface{}, fieldArr []string, orderRule string) (items []*BaseFromOilchemIndex, err error) {
|
|
|
- o := orm.NewOrmUsingDB("data")
|
|
|
+ o := global.DbMap[utils.DbNameIndex]
|
|
|
fields := strings.Join(fieldArr, ",")
|
|
|
if len(fieldArr) == 0 {
|
|
|
fields = `*`
|
|
@@ -517,13 +517,13 @@ func (m *BaseFromOilchemIndex) GetItemsByCondition(condition string, pars []inte
|
|
|
order = ` ORDER BY ` + orderRule
|
|
|
}
|
|
|
sql := fmt.Sprintf(`SELECT %s FROM base_from_oilchem_index WHERE 1=1 %s %s`, fields, condition, order)
|
|
|
- _, err = o.Raw(sql, pars).QueryRows(&items)
|
|
|
+ err = o.Raw(sql, pars...).Find(&items).Error
|
|
|
return
|
|
|
}
|
|
|
|
|
|
// BaseFromThsHfIndex 同花顺高频数据
|
|
|
type BaseFromThsHfIndex struct {
|
|
|
- BaseFromThsHfIndexId int `orm:"column(base_from_ths_hf_index_id);pk"`
|
|
|
+ BaseFromThsHfIndexId int `gorm:"column:base_from_ths_hf_index_id;primaryKey;autoIncrement"`
|
|
|
BaseFromThsHfClassifyId int `description:"分类ID"`
|
|
|
IndexCode string `description:"指标编码"`
|
|
|
IndexName string `description:"指标名称"`
|
|
@@ -590,7 +590,7 @@ func (m *BaseFromThsHfIndex) Format2SearchDataSource(origin *BaseFromThsHfIndex)
|
|
|
}
|
|
|
|
|
|
func (m *BaseFromThsHfIndex) GetItemsByCondition(condition string, pars []interface{}, fieldArr []string, orderRule string) (items []*BaseFromThsHfIndex, err error) {
|
|
|
- o := orm.NewOrmUsingDB("data")
|
|
|
+ o := global.DbMap[utils.DbNameIndex]
|
|
|
fields := strings.Join(fieldArr, ",")
|
|
|
if len(fieldArr) == 0 {
|
|
|
fields = `*`
|
|
@@ -600,13 +600,13 @@ func (m *BaseFromThsHfIndex) GetItemsByCondition(condition string, pars []interf
|
|
|
order = ` ORDER BY ` + orderRule
|
|
|
}
|
|
|
sql := fmt.Sprintf(`SELECT %s FROM base_from_ths_hf_index WHERE 1=1 %s %s`, fields, condition, order)
|
|
|
- _, err = o.Raw(sql, pars).QueryRows(&items)
|
|
|
+ err = o.Raw(sql, pars...).Find(&items).Error
|
|
|
return
|
|
|
}
|
|
|
|
|
|
// BaseFromCcfIndex CCF化纤信息
|
|
|
type BaseFromCcfIndex struct {
|
|
|
- BaseFromCcfIndexId int `orm:"column(base_from_ccf_index_id);pk"`
|
|
|
+ BaseFromCcfIndexId int `gorm:"column:base_from_ccf_index_id;primaryKey;autoIncrement"`
|
|
|
ClassifyId int `description:"分类ID"`
|
|
|
IndexCode string `description:"指标编码"`
|
|
|
IndexName string `description:"指标名称"`
|
|
@@ -663,7 +663,7 @@ func (m *BaseFromCcfIndex) Format2SearchDataSource(origin *BaseFromCcfIndex) (it
|
|
|
}
|
|
|
|
|
|
func (m *BaseFromCcfIndex) GetItemsByCondition(condition string, pars []interface{}, fieldArr []string, orderRule string) (items []*BaseFromCcfIndex, err error) {
|
|
|
- o := orm.NewOrmUsingDB("data")
|
|
|
+ o := global.DbMap[utils.DbNameIndex]
|
|
|
fields := strings.Join(fieldArr, ",")
|
|
|
if len(fieldArr) == 0 {
|
|
|
fields = `*`
|
|
@@ -673,13 +673,13 @@ func (m *BaseFromCcfIndex) GetItemsByCondition(condition string, pars []interfac
|
|
|
order = ` ORDER BY ` + orderRule
|
|
|
}
|
|
|
sql := fmt.Sprintf(`SELECT %s FROM base_from_ccf_index WHERE 1=1 %s %s`, fields, condition, order)
|
|
|
- _, err = o.Raw(sql, pars).QueryRows(&items)
|
|
|
+ err = o.Raw(sql, pars...).Find(&items).Error
|
|
|
return
|
|
|
}
|
|
|
|
|
|
// BaseFromUsdaFasIndex 美国农业部
|
|
|
type BaseFromUsdaFasIndex struct {
|
|
|
- BaseFromUsdaFasIndexId int `orm:"column(base_from_usda_fas_index_id);pk"`
|
|
|
+ BaseFromUsdaFasIndexId int `gorm:"column:base_from_usda_fas_index_id;primaryKey;autoIncrement"`
|
|
|
ClassifyId int `description:"分类ID"`
|
|
|
IndexCode string `description:"指标编码"`
|
|
|
IndexName string `description:"指标名称"`
|
|
@@ -736,7 +736,7 @@ func (m *BaseFromUsdaFasIndex) Format2SearchDataSource(origin *BaseFromUsdaFasIn
|
|
|
}
|
|
|
|
|
|
func (m *BaseFromUsdaFasIndex) GetItemsByCondition(condition string, pars []interface{}, fieldArr []string, orderRule string) (items []*BaseFromUsdaFasIndex, err error) {
|
|
|
- o := orm.NewOrmUsingDB("data")
|
|
|
+ o := global.DbMap[utils.DbNameIndex]
|
|
|
fields := strings.Join(fieldArr, ",")
|
|
|
if len(fieldArr) == 0 {
|
|
|
fields = `*`
|
|
@@ -746,13 +746,13 @@ func (m *BaseFromUsdaFasIndex) GetItemsByCondition(condition string, pars []inte
|
|
|
order = ` ORDER BY ` + orderRule
|
|
|
}
|
|
|
sql := fmt.Sprintf(`SELECT %s, end_value AS latest_value FROM base_from_usda_fas_index WHERE 1=1 %s %s`, fields, condition, order)
|
|
|
- _, err = o.Raw(sql, pars).QueryRows(&items)
|
|
|
+ err = o.Raw(sql, pars...).Find(&items).Error
|
|
|
return
|
|
|
}
|
|
|
|
|
|
// BaseFromMysteelChemicalIndex 上海钢联
|
|
|
type BaseFromMysteelChemicalIndex struct {
|
|
|
- BaseFromMysteelChemicalIndexId int `orm:"column(base_from_mysteel_chemical_index_id);pk"`
|
|
|
+ BaseFromMysteelChemicalIndexId int `gorm:"column:base_from_mysteel_chemical_index_id;primaryKey;autoIncrement"`
|
|
|
BaseFromMysteelChemicalClassifyId int `description:"分类ID"`
|
|
|
IndexCode string `description:"指标编码"`
|
|
|
IndexName string `description:"指标名称"`
|
|
@@ -809,7 +809,7 @@ func (m *BaseFromMysteelChemicalIndex) Format2SearchDataSource(origin *BaseFromM
|
|
|
}
|
|
|
|
|
|
func (m *BaseFromMysteelChemicalIndex) GetItemsByCondition(condition string, pars []interface{}, fieldArr []string, orderRule string) (items []*BaseFromMysteelChemicalIndex, err error) {
|
|
|
- o := orm.NewOrmUsingDB("data")
|
|
|
+ o := global.DbMap[utils.DbNameIndex]
|
|
|
fields := strings.Join(fieldArr, ",")
|
|
|
if len(fieldArr) == 0 {
|
|
|
fields = `*`
|
|
@@ -819,13 +819,13 @@ func (m *BaseFromMysteelChemicalIndex) GetItemsByCondition(condition string, par
|
|
|
order = ` ORDER BY ` + orderRule
|
|
|
}
|
|
|
sql := fmt.Sprintf(`SELECT %s, end_value AS latest_value FROM base_from_mysteel_chemical_index WHERE 1=1 %s %s`, fields, condition, order)
|
|
|
- _, err = o.Raw(sql, pars).QueryRows(&items)
|
|
|
+ err = o.Raw(sql, pars...).Find(&items).Error
|
|
|
return
|
|
|
}
|
|
|
|
|
|
// BaseFromSmmIndex 有色原始数据库
|
|
|
type BaseFromSmmIndex struct {
|
|
|
- BaseFromSmmIndexId int `orm:"column(base_from_smm_index_id);pk"`
|
|
|
+ BaseFromSmmIndexId int `gorm:"column:base_from_smm_index_id;primaryKey;autoIncrement"`
|
|
|
ClassifyId int `description:"分类ID"`
|
|
|
IndexCode string `description:"指标编码"`
|
|
|
IndexName string `description:"指标名称"`
|
|
@@ -882,7 +882,7 @@ func (m *BaseFromSmmIndex) Format2SearchDataSource(origin *BaseFromSmmIndex) (it
|
|
|
}
|
|
|
|
|
|
func (m *BaseFromSmmIndex) GetItemsByCondition(condition string, pars []interface{}, fieldArr []string, orderRule string) (items []*BaseFromSmmIndex, err error) {
|
|
|
- o := orm.NewOrmUsingDB("data")
|
|
|
+ o := global.DbMap[utils.DbNameIndex]
|
|
|
fields := strings.Join(fieldArr, ",")
|
|
|
if len(fieldArr) == 0 {
|
|
|
fields = `*`
|
|
@@ -892,13 +892,13 @@ func (m *BaseFromSmmIndex) GetItemsByCondition(condition string, pars []interfac
|
|
|
order = ` ORDER BY ` + orderRule
|
|
|
}
|
|
|
sql := fmt.Sprintf(`SELECT %s, end_value AS latest_value FROM base_from_smm_index WHERE 1=1 %s %s`, fields, condition, order)
|
|
|
- _, err = o.Raw(sql, pars).QueryRows(&items)
|
|
|
+ err = o.Raw(sql, pars...).Find(&items).Error
|
|
|
return
|
|
|
}
|
|
|
|
|
|
// BaseFromBaiinfoIndex 百川盈孚
|
|
|
type BaseFromBaiinfoIndex struct {
|
|
|
- BaseFromBaiinfoIndexId int `orm:"column(base_from_baiinfo_index_id);pk"`
|
|
|
+ BaseFromBaiinfoIndexId int `gorm:"column:base_from_baiinfo_index_id;primaryKey;autoIncrement"`
|
|
|
ClassifyId int `description:"分类ID"`
|
|
|
IndexCode string `description:"指标编码"`
|
|
|
IndexName string `description:"指标名称"`
|
|
@@ -955,7 +955,7 @@ func (m *BaseFromBaiinfoIndex) Format2SearchDataSource(origin *BaseFromBaiinfoIn
|
|
|
}
|
|
|
|
|
|
func (m *BaseFromBaiinfoIndex) GetItemsByCondition(condition string, pars []interface{}, fieldArr []string, orderRule string) (items []*BaseFromBaiinfoIndex, err error) {
|
|
|
- o := orm.NewOrmUsingDB("data")
|
|
|
+ o := global.DbMap[utils.DbNameIndex]
|
|
|
fields := strings.Join(fieldArr, ",")
|
|
|
if len(fieldArr) == 0 {
|
|
|
fields = `*`
|
|
@@ -965,13 +965,13 @@ func (m *BaseFromBaiinfoIndex) GetItemsByCondition(condition string, pars []inte
|
|
|
order = ` ORDER BY ` + orderRule
|
|
|
}
|
|
|
sql := fmt.Sprintf(`SELECT %s FROM base_from_baiinfo_index WHERE 1=1 %s %s`, fields, condition, order)
|
|
|
- _, err = o.Raw(sql, pars).QueryRows(&items)
|
|
|
+ err = o.Raw(sql, pars...).Find(&items).Error
|
|
|
return
|
|
|
}
|
|
|
|
|
|
// BaseFromSciIndex 卓创数据(红桃3)
|
|
|
type BaseFromSciIndex struct {
|
|
|
- BaseFromSciIndexId int `orm:"column(base_from_sci_index_id);pk"`
|
|
|
+ BaseFromSciIndexId int `gorm:"column:base_from_sci_index_id;primaryKey;autoIncrement"`
|
|
|
ClassifyId int `description:"分类ID"`
|
|
|
IndexCode string `description:"指标编码"`
|
|
|
IndexName string `description:"指标名称"`
|
|
@@ -1028,7 +1028,7 @@ func (m *BaseFromSciIndex) Format2SearchDataSource(origin *BaseFromSciIndex) (it
|
|
|
}
|
|
|
|
|
|
func (m *BaseFromSciIndex) GetItemsByCondition(condition string, pars []interface{}, fieldArr []string, orderRule string) (items []*BaseFromSciIndex, err error) {
|
|
|
- o := orm.NewOrmUsingDB("data")
|
|
|
+ o := global.DbMap[utils.DbNameIndex]
|
|
|
fields := strings.Join(fieldArr, ",")
|
|
|
if len(fieldArr) == 0 {
|
|
|
fields = `*`
|
|
@@ -1038,13 +1038,13 @@ func (m *BaseFromSciIndex) GetItemsByCondition(condition string, pars []interfac
|
|
|
order = ` ORDER BY ` + orderRule
|
|
|
}
|
|
|
sql := fmt.Sprintf(`SELECT %s FROM base_from_sci_index WHERE 1=1 %s %s`, fields, condition, order)
|
|
|
- _, err = o.Raw(sql, pars).QueryRows(&items)
|
|
|
+ err = o.Raw(sql, pars...).Find(&items).Error
|
|
|
return
|
|
|
}
|
|
|
|
|
|
// BaseFromCoalmineMapping 中国煤炭市场网
|
|
|
type BaseFromCoalmineMapping struct {
|
|
|
- BaseFromCoalmineMappingId int `orm:"column(base_from_coalmine_mapping_id);pk"`
|
|
|
+ BaseFromCoalmineMappingId int `gorm:"column:base_from_coalmine_mapping_id;primaryKey;autoIncrement"`
|
|
|
ClassifyId int `description:"分类ID"`
|
|
|
IndexCode string `description:"指标编码"`
|
|
|
IndexName string `description:"指标名称"`
|
|
@@ -1101,7 +1101,7 @@ func (m *BaseFromCoalmineMapping) Format2SearchDataSource(origin *BaseFromCoalmi
|
|
|
}
|
|
|
|
|
|
func (m *BaseFromCoalmineMapping) GetItemsByCondition(condition string, pars []interface{}, fieldArr []string, orderRule string) (items []*BaseFromCoalmineMapping, err error) {
|
|
|
- o := orm.NewOrmUsingDB("data")
|
|
|
+ o := global.DbMap[utils.DbNameIndex]
|
|
|
fields := strings.Join(fieldArr, ",")
|
|
|
if len(fieldArr) == 0 {
|
|
|
fields = `*`
|
|
@@ -1111,13 +1111,13 @@ func (m *BaseFromCoalmineMapping) GetItemsByCondition(condition string, pars []i
|
|
|
order = ` ORDER BY ` + orderRule
|
|
|
}
|
|
|
sql := fmt.Sprintf(`SELECT %s FROM base_from_coalmine_mapping WHERE 1=1 %s %s`, fields, condition, order)
|
|
|
- _, err = o.Raw(sql, pars).QueryRows(&items)
|
|
|
+ err = o.Raw(sql, pars...).Find(&items).Error
|
|
|
return
|
|
|
}
|
|
|
|
|
|
// BaseFromEiaSteoIndex EIA STEO报告
|
|
|
type BaseFromEiaSteoIndex struct {
|
|
|
- BaseFromEiaSteoIndexId int `orm:"column(base_from_eia_steo_index_id);pk"`
|
|
|
+ BaseFromEiaSteoIndexId int `gorm:"column:base_from_eia_steo_index_id;primaryKey;autoIncrement"`
|
|
|
BaseFromEiaSteoClassifyId int `description:"分类ID"`
|
|
|
IndexCode string `description:"指标编码"`
|
|
|
IndexName string `description:"指标名称"`
|
|
@@ -1174,7 +1174,7 @@ func (m *BaseFromEiaSteoIndex) Format2SearchDataSource(origin *BaseFromEiaSteoIn
|
|
|
}
|
|
|
|
|
|
func (m *BaseFromEiaSteoIndex) GetItemsByCondition(condition string, pars []interface{}, fieldArr []string, orderRule string) (items []*BaseFromEiaSteoIndex, err error) {
|
|
|
- o := orm.NewOrmUsingDB("data")
|
|
|
+ o := global.DbMap[utils.DbNameIndex]
|
|
|
fields := strings.Join(fieldArr, ",")
|
|
|
if len(fieldArr) == 0 {
|
|
|
fields = `*`
|
|
@@ -1184,13 +1184,13 @@ func (m *BaseFromEiaSteoIndex) GetItemsByCondition(condition string, pars []inte
|
|
|
order = ` ORDER BY ` + orderRule
|
|
|
}
|
|
|
sql := fmt.Sprintf(`SELECT %s FROM base_from_eia_steo_index WHERE 1=1 %s %s`, fields, condition, order)
|
|
|
- _, err = o.Raw(sql, pars).QueryRows(&items)
|
|
|
+ err = o.Raw(sql, pars...).Find(&items).Error
|
|
|
return
|
|
|
}
|
|
|
|
|
|
// BaseFromIcpiIndex ICPI消费价格指数
|
|
|
type BaseFromIcpiIndex struct {
|
|
|
- BaseFromIcpiIndexId int `orm:"column(base_from_icpi_index_id);pk"`
|
|
|
+ BaseFromIcpiIndexId int `gorm:"column:base_from_icpi_index_id;primaryKey;autoIncrement"`
|
|
|
BaseFromIcpiClassifyId int `description:"分类ID"`
|
|
|
IndexCode string `description:"指标编码"`
|
|
|
IndexName string `description:"指标名称"`
|
|
@@ -1247,7 +1247,7 @@ func (m *BaseFromIcpiIndex) Format2SearchDataSource(origin *BaseFromIcpiIndex) (
|
|
|
}
|
|
|
|
|
|
func (m *BaseFromIcpiIndex) GetItemsByCondition(condition string, pars []interface{}, fieldArr []string, orderRule string) (items []*BaseFromIcpiIndex, err error) {
|
|
|
- o := orm.NewOrmUsingDB("data")
|
|
|
+ o := global.DbMap[utils.DbNameIndex]
|
|
|
fields := strings.Join(fieldArr, ",")
|
|
|
if len(fieldArr) == 0 {
|
|
|
fields = `*`
|
|
@@ -1257,13 +1257,13 @@ func (m *BaseFromIcpiIndex) GetItemsByCondition(condition string, pars []interfa
|
|
|
order = ` ORDER BY ` + orderRule
|
|
|
}
|
|
|
sql := fmt.Sprintf(`SELECT %s FROM base_from_icpi_index WHERE 1=1 %s %s`, fields, condition, order)
|
|
|
- _, err = o.Raw(sql, pars).QueryRows(&items)
|
|
|
+ err = o.Raw(sql, pars...).Find(&items).Error
|
|
|
return
|
|
|
}
|
|
|
|
|
|
// BaseFromYongyiIndex 涌益咨询
|
|
|
type BaseFromYongyiIndex struct {
|
|
|
- YongyiIndexId int `orm:"column(yongyi_index_id);pk"`
|
|
|
+ YongyiIndexId int `gorm:"column:yongyi_index_id;primaryKey;autoIncrement"`
|
|
|
ClassifyId int `description:"分类ID"`
|
|
|
IndexCode string `description:"指标编码"`
|
|
|
IndexName string `description:"指标名称"`
|
|
@@ -1320,7 +1320,7 @@ func (m *BaseFromYongyiIndex) Format2SearchDataSource(origin *BaseFromYongyiInde
|
|
|
}
|
|
|
|
|
|
func (m *BaseFromYongyiIndex) GetItemsByCondition(condition string, pars []interface{}, fieldArr []string, orderRule string) (items []*BaseFromYongyiIndex, err error) {
|
|
|
- o := orm.NewOrmUsingDB("data")
|
|
|
+ o := global.DbMap[utils.DbNameIndex]
|
|
|
fields := strings.Join(fieldArr, ",")
|
|
|
if len(fieldArr) == 0 {
|
|
|
fields = `*`
|
|
@@ -1330,13 +1330,13 @@ func (m *BaseFromYongyiIndex) GetItemsByCondition(condition string, pars []inter
|
|
|
order = ` ORDER BY ` + orderRule
|
|
|
}
|
|
|
sql := fmt.Sprintf(`SELECT %s FROM base_from_yongyi_index WHERE 1=1 %s %s`, fields, condition, order)
|
|
|
- _, err = o.Raw(sql, pars).QueryRows(&items)
|
|
|
+ err = o.Raw(sql, pars...).Find(&items).Error
|
|
|
return
|
|
|
}
|
|
|
|
|
|
// BaseFromFenweiIndex 汾渭数据
|
|
|
type BaseFromFenweiIndex struct {
|
|
|
- FenweiIndexId int `orm:"column(fenwei_index_id);pk"`
|
|
|
+ FenweiIndexId int `gorm:"column:fenwei_index_id;primaryKey;autoIncrement"`
|
|
|
ClassifyId int `description:"分类ID"`
|
|
|
IndexCode string `description:"指标编码"`
|
|
|
IndexName string `description:"指标名称"`
|
|
@@ -1393,7 +1393,7 @@ func (m *BaseFromFenweiIndex) Format2SearchDataSource(origin *BaseFromFenweiInde
|
|
|
}
|
|
|
|
|
|
func (m *BaseFromFenweiIndex) GetItemsByCondition(condition string, pars []interface{}, fieldArr []string, orderRule string) (items []*BaseFromFenweiIndex, err error) {
|
|
|
- o := orm.NewOrmUsingDB("data")
|
|
|
+ o := global.DbMap[utils.DbNameIndex]
|
|
|
fields := strings.Join(fieldArr, ",")
|
|
|
if len(fieldArr) == 0 {
|
|
|
fields = `*`
|
|
@@ -1403,13 +1403,13 @@ func (m *BaseFromFenweiIndex) GetItemsByCondition(condition string, pars []inter
|
|
|
order = ` ORDER BY ` + orderRule
|
|
|
}
|
|
|
sql := fmt.Sprintf(`SELECT %s FROM base_from_fenwei_index WHERE 1=1 %s %s`, fields, condition, order)
|
|
|
- _, err = o.Raw(sql, pars).QueryRows(&items)
|
|
|
+ err = o.Raw(sql, pars...).Find(&items).Error
|
|
|
return
|
|
|
}
|
|
|
|
|
|
// BaseFromSci99Index 卓创资讯
|
|
|
type BaseFromSci99Index struct {
|
|
|
- BaseFromSciIndexId int `orm:"column(base_from_sci_index_id);pk"`
|
|
|
+ BaseFromSciIndexId int `gorm:"column:base_from_sci_index_id;primaryKey;autoIncrement"`
|
|
|
ClassifyId int `description:"分类ID"`
|
|
|
IndexCode string `description:"指标编码"`
|
|
|
IndexName string `description:"指标名称"`
|
|
@@ -1466,7 +1466,7 @@ func (m *BaseFromSci99Index) Format2SearchDataSource(origin *BaseFromSci99Index)
|
|
|
}
|
|
|
|
|
|
func (m *BaseFromSci99Index) GetItemsByCondition(condition string, pars []interface{}, fieldArr []string, orderRule string) (items []*BaseFromSci99Index, err error) {
|
|
|
- o := orm.NewOrmUsingDB("data")
|
|
|
+ o := global.DbMap[utils.DbNameIndex]
|
|
|
fields := strings.Join(fieldArr, ",")
|
|
|
if len(fieldArr) == 0 {
|
|
|
fields = `*`
|
|
@@ -1476,13 +1476,13 @@ func (m *BaseFromSci99Index) GetItemsByCondition(condition string, pars []interf
|
|
|
order = ` ORDER BY ` + orderRule
|
|
|
}
|
|
|
sql := fmt.Sprintf(`SELECT %s FROM base_from_sci99_index WHERE 1=1 %s %s`, fields, condition, order)
|
|
|
- _, err = o.Raw(sql, pars).QueryRows(&items)
|
|
|
+ err = o.Raw(sql, pars...).Find(&items).Error
|
|
|
return
|
|
|
}
|
|
|
|
|
|
// BaseFromGlIndex 钢联原始指标库
|
|
|
type BaseFromGlIndex struct {
|
|
|
- PrimaryId int `orm:"column(ID);pk"`
|
|
|
+ PrimaryId int `gorm:"column:ID;primaryKey;autoIncrement" orm:"column(ID);pk"`
|
|
|
IndexCode string `orm:"column(INDEX_CODE)" description:"指标编码"`
|
|
|
IndexName string `orm:"column(INDEX_NAME)" description:"指标名称"`
|
|
|
Unit string `orm:"column(UNIT_NAME)" description:"单位"`
|
|
@@ -1538,7 +1538,7 @@ func (m *BaseFromGlIndex) Format2SearchDataSource(origin *BaseFromGlIndex) (item
|
|
|
}
|
|
|
|
|
|
func (m *BaseFromGlIndex) GetItemsByCondition(condition string, pars []interface{}, fieldArr []string, orderRule string) (items []*BaseFromGlIndex, err error) {
|
|
|
- o := orm.NewOrmUsingDB("gl")
|
|
|
+ o := global.DbMap[utils.DbNameGL]
|
|
|
fields := strings.Join(fieldArr, ",")
|
|
|
if len(fieldArr) == 0 {
|
|
|
fields = `*`
|
|
@@ -1548,7 +1548,7 @@ func (m *BaseFromGlIndex) GetItemsByCondition(condition string, pars []interface
|
|
|
order = ` ORDER BY ` + orderRule
|
|
|
}
|
|
|
sql := fmt.Sprintf(`SELECT %s FROM mb_index_main_info WHERE 1=1 %s %s`, fields, condition, order)
|
|
|
- _, err = o.Raw(sql, pars).QueryRows(&items)
|
|
|
+ err = o.Raw(sql, pars...).Find(&items).Error
|
|
|
return
|
|
|
}
|
|
|
|
|
@@ -1611,7 +1611,7 @@ func (m *BaseFromManualEdb) Format2SearchDataSource(origin *BaseFromManualEdb) (
|
|
|
}
|
|
|
|
|
|
func (m *BaseFromManualEdb) GetItemsByCondition(condition string, pars []interface{}, fieldArr []string, orderRule string) (items []*BaseFromManualEdb, err error) {
|
|
|
- o := orm.NewOrmUsingDB("edb")
|
|
|
+ o := global.DbMap[utils.DbNameManualIndex]
|
|
|
fields := strings.Join(fieldArr, ",")
|
|
|
if len(fieldArr) == 0 {
|
|
|
fields = `*`
|
|
@@ -1621,13 +1621,13 @@ func (m *BaseFromManualEdb) GetItemsByCondition(condition string, pars []interfa
|
|
|
order = ` ORDER BY ` + orderRule
|
|
|
}
|
|
|
sql := fmt.Sprintf(`SELECT %s FROM edbinfo WHERE 1=1 %s %s`, fields, condition, order)
|
|
|
- _, err = o.Raw(sql, pars).QueryRows(&items)
|
|
|
+ err = o.Raw(sql, pars...).Find(&items).Error
|
|
|
return
|
|
|
}
|
|
|
|
|
|
// BaseFromBusinessIndex 自有数据
|
|
|
type BaseFromBusinessIndex struct {
|
|
|
- BaseFromBusinessIndexId int `orm:"column(base_from_business_index_id);pk"`
|
|
|
+ BaseFromBusinessIndexId int `gorm:"column:base_from_business_index_id;primaryKey;autoIncrement"`
|
|
|
//ClassifyId int `description:"分类ID"`
|
|
|
IndexCode string `description:"指标编码"`
|
|
|
IndexName string `description:"指标名称"`
|
|
@@ -1684,7 +1684,7 @@ func (m *BaseFromBusinessIndex) Format2SearchDataSource(origin *BaseFromBusiness
|
|
|
}
|
|
|
|
|
|
func (m *BaseFromBusinessIndex) GetItemsByCondition(condition string, pars []interface{}, fieldArr []string, orderRule string) (items []*BaseFromBusinessIndex, err error) {
|
|
|
- o := orm.NewOrmUsingDB("data")
|
|
|
+ o := global.DbMap[utils.DbNameIndex]
|
|
|
fields := strings.Join(fieldArr, ",")
|
|
|
if len(fieldArr) == 0 {
|
|
|
fields = `*`
|
|
@@ -1694,13 +1694,13 @@ func (m *BaseFromBusinessIndex) GetItemsByCondition(condition string, pars []int
|
|
|
order = ` ORDER BY ` + orderRule
|
|
|
}
|
|
|
sql := fmt.Sprintf(`SELECT %s FROM base_from_business_index WHERE 1=1 %s %s`, fields, condition, order)
|
|
|
- _, err = o.Raw(sql, pars).QueryRows(&items)
|
|
|
+ err = o.Raw(sql, pars...).Find(&items).Error
|
|
|
return
|
|
|
}
|
|
|
|
|
|
// BaseFromBloombergIndex Bloomberg
|
|
|
type BaseFromBloombergIndex struct {
|
|
|
- BaseFromBloombergIndexId int `orm:"column(base_from_bloomberg_index_id);pk"`
|
|
|
+ BaseFromBloombergIndexId int `gorm:"column:base_from_bloomberg_index_id;primaryKey;autoIncrement"`
|
|
|
//ClassifyId int `description:"分类ID"`
|
|
|
IndexCode string `description:"指标编码"`
|
|
|
IndexName string `description:"指标名称"`
|
|
@@ -1757,7 +1757,7 @@ func (m *BaseFromBloombergIndex) Format2SearchDataSource(origin *BaseFromBloombe
|
|
|
}
|
|
|
|
|
|
func (m *BaseFromBloombergIndex) GetItemsByCondition(condition string, pars []interface{}, fieldArr []string, orderRule string) (items []*BaseFromBloombergIndex, err error) {
|
|
|
- o := orm.NewOrmUsingDB("data")
|
|
|
+ o := global.DbMap[utils.DbNameIndex]
|
|
|
fields := strings.Join(fieldArr, ",")
|
|
|
if len(fieldArr) == 0 {
|
|
|
fields = `*`
|
|
@@ -1767,13 +1767,13 @@ func (m *BaseFromBloombergIndex) GetItemsByCondition(condition string, pars []in
|
|
|
order = ` ORDER BY ` + orderRule
|
|
|
}
|
|
|
sql := fmt.Sprintf(`SELECT %s FROM base_from_bloomberg_index WHERE 1=1 %s %s`, fields, condition, order)
|
|
|
- _, err = o.Raw(sql, pars).QueryRows(&items)
|
|
|
+ err = o.Raw(sql, pars...).Find(&items).Error
|
|
|
return
|
|
|
}
|
|
|
|
|
|
// BaseFromMtjhMapping 煤炭江湖
|
|
|
type BaseFromMtjhMapping struct {
|
|
|
- BaseFromMtjhMappingId int `orm:"column(base_from_mtjh_mapping_id);pk"`
|
|
|
+ BaseFromMtjhMappingId int `gorm:"column:base_from_mtjh_mapping_id;primaryKey;autoIncrement"`
|
|
|
//ClassifyId int `description:"分类ID"`
|
|
|
IndexCode string `description:"指标编码"`
|
|
|
IndexName string `description:"指标名称"`
|
|
@@ -1830,7 +1830,7 @@ func (m *BaseFromMtjhMapping) Format2SearchDataSource(origin *BaseFromMtjhMappin
|
|
|
}
|
|
|
|
|
|
func (m *BaseFromMtjhMapping) GetItemsByCondition(condition string, pars []interface{}, fieldArr []string, orderRule string) (items []*BaseFromMtjhMapping, err error) {
|
|
|
- o := orm.NewOrmUsingDB("data")
|
|
|
+ o := global.DbMap[utils.DbNameIndex]
|
|
|
fields := strings.Join(fieldArr, ",")
|
|
|
if len(fieldArr) == 0 {
|
|
|
fields = `*`
|
|
@@ -1840,7 +1840,7 @@ func (m *BaseFromMtjhMapping) GetItemsByCondition(condition string, pars []inter
|
|
|
order = ` ORDER BY ` + orderRule
|
|
|
}
|
|
|
sql := fmt.Sprintf(`SELECT %s FROM base_from_mtjh_mapping WHERE 1=1 %s %s`, fields, condition, order)
|
|
|
- _, err = o.Raw(sql, pars).QueryRows(&items)
|
|
|
+ err = o.Raw(sql, pars...).Find(&items).Error
|
|
|
return
|
|
|
}
|
|
|
|
|
@@ -1943,20 +1943,20 @@ func getCoalmineDataTableName(indexCode string) string {
|
|
|
|
|
|
// GetBaseIndexDataMinMax 获取数据源极值
|
|
|
func GetBaseIndexDataMinMax(source, subSource int, indexCode string) (item *BaseIndexDataMinMax, err error) {
|
|
|
- o := orm.NewOrmUsingDB("data")
|
|
|
+ o := global.DbMap[utils.DbNameIndex]
|
|
|
var sql string
|
|
|
var latestVal float64
|
|
|
|
|
|
// 煤炭江湖
|
|
|
if source == utils.DATA_SOURCE_MTJH {
|
|
|
sql = `SELECT MIN(data_time) AS min_date, MAX(data_time) AS max_date FROM base_from_mtjh_index WHERE index_code = ?`
|
|
|
- if e := o.Raw(sql, indexCode).QueryRow(&item); e != nil {
|
|
|
+ if e := o.Raw(sql, indexCode).Scan(&item); e != nil {
|
|
|
err = fmt.Errorf("获取数据源开始结束时间失败, %v", e)
|
|
|
return
|
|
|
}
|
|
|
|
|
|
sql = `SELECT deal_value AS latest_value FROM base_from_mtjh_index WHERE index_code = ? ORDER BY data_time DESC LIMIT 1`
|
|
|
- if e := o.Raw(sql, indexCode).QueryRow(&latestVal); e != nil {
|
|
|
+ if e := o.Raw(sql, indexCode).Scan(&latestVal); e != nil {
|
|
|
err = fmt.Errorf("获取数据源最新值失败, %v", e)
|
|
|
return
|
|
|
}
|
|
@@ -1977,14 +1977,14 @@ func GetBaseIndexDataMinMax(source, subSource int, indexCode string) (item *Base
|
|
|
}
|
|
|
sql = `SELECT MIN(%s) AS min_date, MAX(%s) AS max_date FROM %s WHERE index_code = ?`
|
|
|
sql = fmt.Sprintf(sql, fieldDataTime, fieldDataTime, dataTable)
|
|
|
- if e := o.Raw(sql, indexCode).QueryRow(&item); e != nil {
|
|
|
+ if e := o.Raw(sql, indexCode).Scan(&item); e != nil {
|
|
|
err = fmt.Errorf("获取数据源开始结束时间失败, %v", e)
|
|
|
return
|
|
|
}
|
|
|
|
|
|
sql = `SELECT deal_value AS latest_value FROM %s WHERE index_code = ? ORDER BY %s DESC LIMIT 1`
|
|
|
sql = fmt.Sprintf(sql, dataTable, fieldDataTime)
|
|
|
- if e := o.Raw(sql, indexCode).QueryRow(&latestVal); e != nil {
|
|
|
+ if e := o.Raw(sql, indexCode).Scan(&latestVal); e != nil {
|
|
|
err = fmt.Errorf("获取数据源最新值失败, %v", e)
|
|
|
return
|
|
|
}
|
|
@@ -2001,14 +2001,14 @@ func GetBaseIndexDataMinMax(source, subSource int, indexCode string) (item *Base
|
|
|
|
|
|
sql = `SELECT MIN(data_time) AS min_date, MAX(data_time) AS max_date FROM %s WHERE index_code = ?`
|
|
|
sql = fmt.Sprintf(sql, dataTable)
|
|
|
- if e := o.Raw(sql, indexCode).QueryRow(&item); e != nil {
|
|
|
+ if e := o.Raw(sql, indexCode).Scan(&item); e != nil {
|
|
|
err = fmt.Errorf("获取数据源开始结束时间失败, %v", e)
|
|
|
return
|
|
|
}
|
|
|
|
|
|
sql = `SELECT value AS latest_value FROM %s WHERE index_code = ? ORDER BY data_time DESC LIMIT 1`
|
|
|
sql = fmt.Sprintf(sql, dataTable)
|
|
|
- if e := o.Raw(sql, indexCode).QueryRow(&latestVal); e != nil {
|
|
|
+ if e := o.Raw(sql, indexCode).Scan(&latestVal); e != nil {
|
|
|
err = fmt.Errorf("获取数据源最新值失败, %v", e)
|
|
|
return
|
|
|
}
|