|
@@ -17,6 +17,62 @@ import (
|
|
|
"github.com/rdlucklib/rdluck_tools/paging"
|
|
|
)
|
|
|
|
|
|
+// EdbInfoOrm
|
|
|
+// @Description: 数据库映射结构体
|
|
|
+type EdbInfoOrm struct {
|
|
|
+ EdbInfoId int `orm:"column(edb_info_id);pk;auto"`
|
|
|
+ EdbInfoType int `description:"指标类型,0:普通指标,1:预测指标"`
|
|
|
+ SourceName string `description:"来源名称"`
|
|
|
+ Source int `description:"来源id"`
|
|
|
+ EdbCode string `description:"指标编码"`
|
|
|
+ EdbName string `description:"指标名称"`
|
|
|
+ EdbNameEn string `description:"英文指标名称"`
|
|
|
+ EdbNameSource string `description:"指标名称来源"`
|
|
|
+ Frequency string `description:"频率"`
|
|
|
+ Unit string `description:"单位"`
|
|
|
+ UnitEn string `description:"英文单位"`
|
|
|
+ StartDate time.Time `description:"起始日期"`
|
|
|
+ EndDate time.Time `description:"终止日期"`
|
|
|
+ ClassifyId int `description:"分类id"`
|
|
|
+ SysUserId int
|
|
|
+ SysUserRealName string
|
|
|
+ UniqueCode string `description:"指标唯一编码"`
|
|
|
+ CreateTime time.Time
|
|
|
+ ModifyTime time.Time
|
|
|
+ BaseModifyTime time.Time
|
|
|
+ MinValue float64 `description:"指标最小值"`
|
|
|
+ MaxValue float64 `description:"指标最大值"`
|
|
|
+ CalculateFormula string `description:"计算公式"`
|
|
|
+ EdbType int `description:"指标类型:1:基础指标,2:计算指标"`
|
|
|
+ Sort int `description:"排序字段"`
|
|
|
+ LatestDate time.Time `description:"数据最新日期(实际日期)"`
|
|
|
+ LatestValue float64 `description:"数据最新值(实际值)"`
|
|
|
+ EndValue float64 `description:"数据的最新值(预测日期的最新值)"`
|
|
|
+ MoveType int `description:"移动方式:1:领先(默认),2:滞后"`
|
|
|
+ MoveFrequency string `description:"移动频度"`
|
|
|
+ NoUpdate int8 `description:"是否停止更新,0:继续更新;1:停止更新"`
|
|
|
+ ServerUrl string `description:"服务器地址"`
|
|
|
+ ChartImage string `description:"图表图片"`
|
|
|
+ Calendar string `description:"公历/农历" orm:"default(公历);"`
|
|
|
+ DataDateType string `orm:"column(data_date_type);size(255);null;default(交易日)"`
|
|
|
+ ManualSave int `description:"是否有手动保存过上下限: 0-否; 1-是"`
|
|
|
+ EmptyType int `description:"空值处理类型(0查找前后35天,1不计算,2前值填充,3后值填充,4等于0)"`
|
|
|
+ MaxEmptyType int `description:"MAX、MIN公式空值处理类型(1、等于0;2、跳过空值)"`
|
|
|
+ TerminalCode string `description:"终端编码,用于配置在机器上"`
|
|
|
+ DataUpdateTime time.Time `description:"最近一次数据发生变化的时间"`
|
|
|
+ ErDataUpdateDate time.Time `description:"本次更新,数据发生变化的最早日期"`
|
|
|
+ SourceIndexName string `description:"数据源中的指标名称"`
|
|
|
+ SubSource int `description:"子数据来源:0:经济数据库,1:日期序列"`
|
|
|
+ SubSourceName string `description:"子数据来源名称"`
|
|
|
+ IndicatorCode string `description:"指标代码"`
|
|
|
+ StockCode string `description:"证券代码"`
|
|
|
+ Extra string `description:"指标额外配置"`
|
|
|
+ IsJoinPermission int `description:"是否加入权限管控,0:不加入;1:加入;默认:0"`
|
|
|
+ IsStaticData int `description:"是否是静态指标,0否,1是"`
|
|
|
+ SetUpdateTime time.Time `description:"设置启用/禁用刷新状态的时间"`
|
|
|
+ EndDateType int `description:"预测指标截止日期类型:0:未来日期,1未来期数"`
|
|
|
+}
|
|
|
+
|
|
|
type EdbInfo struct {
|
|
|
EdbInfoId int `orm:"column(edb_info_id);pk;auto"`
|
|
|
EdbInfoType int `description:"指标类型,0:普通指标,1:预测指标"`
|
|
@@ -121,9 +177,19 @@ func GetPredictEdbInfoAll(edbInfoType uint8) (items []*EdbClassifyItems, err err
|
|
|
|
|
|
// 用于分类展示
|
|
|
func GetEdbInfoAllList() (items []*EdbInfo, err error) {
|
|
|
+ var ormList []*EdbInfoOrm
|
|
|
+ items = make([]*EdbInfo, 0)
|
|
|
+
|
|
|
o := orm.NewOrmUsingDB("data")
|
|
|
sql := ` SELECT * FROM edb_info `
|
|
|
- _, err = o.Raw(sql).QueryRows(&items)
|
|
|
+ _, err = o.Raw(sql).QueryRows(&ormList)
|
|
|
+ if err != nil {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ for _, ormItem := range ormList {
|
|
|
+ items = append(items, ormItem.ToInfo())
|
|
|
+ }
|
|
|
+
|
|
|
return
|
|
|
}
|
|
|
|
|
@@ -168,9 +234,15 @@ type EdbInfoMySteelChemicalCheckResp struct {
|
|
|
}
|
|
|
|
|
|
func GetEdbInfoByEdbCode(source int, edbCode string) (item *EdbInfo, err error) {
|
|
|
+ var edbInfoOrm *EdbInfoOrm
|
|
|
o := orm.NewOrmUsingDB("data")
|
|
|
sql := ` SELECT * FROM edb_info WHERE source=? AND edb_code=? `
|
|
|
- err = o.Raw(sql, source, edbCode).QueryRow(&item)
|
|
|
+ err = o.Raw(sql, source, edbCode).QueryRow(&edbInfoOrm)
|
|
|
+ if err != nil {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ item = edbInfoOrm.ToInfo()
|
|
|
+
|
|
|
return
|
|
|
}
|
|
|
|
|
@@ -178,16 +250,32 @@ func GetEdbInfoListByEdbCodes(source int, edbCodes []string) (items []*EdbInfo,
|
|
|
if len(edbCodes) == 0 {
|
|
|
return
|
|
|
}
|
|
|
+ var ormList []*EdbInfoOrm
|
|
|
+ items = make([]*EdbInfo, 0)
|
|
|
o := orm.NewOrmUsingDB("data")
|
|
|
sql := ` SELECT * FROM edb_info WHERE source=? AND edb_code IN (` + utils.GetOrmInReplace(len(edbCodes)) + `) `
|
|
|
- _, err = o.Raw(sql, source, edbCodes).QueryRows(&items)
|
|
|
+ _, err = o.Raw(sql, source, edbCodes).QueryRows(&ormList)
|
|
|
+ if err != nil {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ for _, ormItem := range ormList {
|
|
|
+ items = append(items, ormItem.ToInfo())
|
|
|
+ }
|
|
|
+
|
|
|
return
|
|
|
}
|
|
|
|
|
|
func GetEdbInfoById(edbInfoId int) (item *EdbInfo, err error) {
|
|
|
+ var edbInfoOrm *EdbInfoOrm
|
|
|
o := orm.NewOrmUsingDB("data")
|
|
|
sql := ` SELECT * FROM edb_info WHERE edb_info_id=? `
|
|
|
- err = o.Raw(sql, edbInfoId).QueryRow(&item)
|
|
|
+ err = o.Raw(sql, edbInfoId).QueryRow(&edbInfoOrm)
|
|
|
+
|
|
|
+ if err != nil {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ item = edbInfoOrm.ToInfo()
|
|
|
+
|
|
|
return
|
|
|
}
|
|
|
|
|
@@ -260,9 +348,16 @@ func GetEdbInfoByIdExt(edbInfoId int) (item *EdbInfoExt, err error) {
|
|
|
// @return item *EdbInfo
|
|
|
// @return err error
|
|
|
func GetEdbInfoByUniqueCode(uniqueCode string) (item *EdbInfo, err error) {
|
|
|
+ var edbInfoOrm *EdbInfoOrm
|
|
|
o := orm.NewOrmUsingDB("data")
|
|
|
sql := ` SELECT * FROM edb_info WHERE unique_code=? `
|
|
|
- err = o.Raw(sql, uniqueCode).QueryRow(&item)
|
|
|
+ err = o.Raw(sql, uniqueCode).QueryRow(&edbInfoOrm)
|
|
|
+
|
|
|
+ if err != nil {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ item = edbInfoOrm.ToInfo()
|
|
|
+
|
|
|
return
|
|
|
}
|
|
|
|
|
@@ -272,9 +367,18 @@ func GetEdbInfoByIdList(edbInfoIdList []int) (items []*EdbInfo, err error) {
|
|
|
if num <= 0 {
|
|
|
return
|
|
|
}
|
|
|
+ var ormList []*EdbInfoOrm
|
|
|
+ items = make([]*EdbInfo, 0)
|
|
|
o := orm.NewOrmUsingDB("data")
|
|
|
sql := ` SELECT * FROM edb_info WHERE edb_info_id in (` + utils.GetOrmInReplace(num) + `) `
|
|
|
- _, err = o.Raw(sql, edbInfoIdList).QueryRows(&items)
|
|
|
+ _, err = o.Raw(sql, edbInfoIdList).QueryRows(&ormList)
|
|
|
+ if err != nil {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ for _, ormItem := range ormList {
|
|
|
+ items = append(items, ormItem.ToInfo())
|
|
|
+ }
|
|
|
+
|
|
|
return
|
|
|
}
|
|
|
|
|
@@ -485,117 +589,6 @@ func ModifyEdbEnInfo(item *EditEdbEnInfoReq) (err error) {
|
|
|
return
|
|
|
}
|
|
|
|
|
|
-// [2025-zsh-时间类型修复-chenhan]
|
|
|
-type EdbInfoOrm struct {
|
|
|
- EdbInfoId int `orm:"column(edb_info_id);pk"`
|
|
|
- EdbInfoType int `description:"指标类型,0:普通指标,1:预测指标"`
|
|
|
- SourceName string `description:"来源名称"`
|
|
|
- Source int `description:"来源id"`
|
|
|
- EdbCode string `description:"指标编码"`
|
|
|
- EdbNameEn string `description:"英文指标名称"`
|
|
|
- EdbName string `description:"指标名称"`
|
|
|
- Frequency string `description:"频率"`
|
|
|
- FrequencyEn string `description:"英文频率"`
|
|
|
- Unit string `description:"单位"`
|
|
|
- UnitEn string `description:"英文单位"`
|
|
|
- StartDate time.Time `description:"起始日期"`
|
|
|
- EndDate time.Time `description:"终止日期"`
|
|
|
- LatestDate time.Time `description:"数据最新日期(实际日期)"`
|
|
|
- LatestValue float64 `description:"数据最新值(实际值)"`
|
|
|
- EndValue float64 `description:"数据的最新值(预测日期的最新值)"`
|
|
|
- ClassifyId int `description:"分类id"`
|
|
|
- UniqueCode string `description:"指标唯一编码"`
|
|
|
- SysUserId int `description:"创建人id"`
|
|
|
- SysUserRealName string `description:"创建人姓名"`
|
|
|
- ModifyTime time.Time `description:"最新修改时间"`
|
|
|
- CreateTime time.Time `description:"创建时间"`
|
|
|
- EdbNameAlias string `json:"-" description:"指标名称,别名"`
|
|
|
- EdbType int `description:"指标类型:1:基础指标,2:计算指标"`
|
|
|
- ChartImage string `description:"图表图片"`
|
|
|
- RuleType int `description:"预测规则,1:最新,2:固定值"`
|
|
|
- FixedValue float64 `description:"固定值"`
|
|
|
- DataList []*EdbData `description:"实际指标数据"`
|
|
|
- PredictDataList []*EdbData `description:"预测指标数据"`
|
|
|
- Button EdbClassifyItemsButton `description:"操作权限"`
|
|
|
- IsEnEdb bool `description:"是否展示英文标识"`
|
|
|
- DataInsertConfig EdbDataInsertConfigItem `description:"指标数据插入配置"`
|
|
|
- DataDateType string `description:"数据日期类型,枚举值:交易日、自然日"`
|
|
|
- EmptyType int `description:"空值处理类型(0查找前后35天,1不计算,2前值填充,3后值填充,4等于0)"`
|
|
|
- MaxEmptyType int `description:"MAX、MIN公式空值处理类型(1、等于0;2、跳过空值)"`
|
|
|
- SubSource int `description:"子数据来源:0:经济数据库,1:日期序列"`
|
|
|
- SubSourceName string `description:"子数据来源名称"`
|
|
|
- IndicatorCode string `description:"指标代码"`
|
|
|
- StockCode string `description:"证券代码"`
|
|
|
- NoUpdate int8 `description:"是否停止更新,0:继续更新;1:停止更新"`
|
|
|
- IsJoinPermission int `description:"是否加入权限管控,0:不加入;1:加入;默认:0"`
|
|
|
- HaveOperaAuth bool `description:"是否有数据权限,默认:false"`
|
|
|
- IsStaticData int `description:"是否是静态指标,0否,1是"`
|
|
|
- IsSupplierStop int `description:"是否供应商停更:1:停更,0:未停更"`
|
|
|
- MoveType int `description:"移动方式:1:领先(默认),2:滞后"`
|
|
|
- MoveFrequency string `description:"移动频度"`
|
|
|
- MinValue float64 `description:"最小值"`
|
|
|
- MaxValue float64 `description:"最大值"`
|
|
|
- SearchText string `description:"搜索结果(含高亮)"`
|
|
|
-}
|
|
|
-
|
|
|
-func (edbInfo *EdbInfoOrm) ToEdbInfo() (edbinfoList *EdbInfoList) {
|
|
|
- edbinfoList = &EdbInfoList{
|
|
|
- EdbInfoId: edbInfo.EdbInfoId,
|
|
|
- EdbInfoType: edbInfo.EdbInfoType,
|
|
|
- SourceName: edbInfo.SourceName,
|
|
|
- Source: edbInfo.Source,
|
|
|
- EdbCode: edbInfo.EdbCode,
|
|
|
- EdbNameEn: edbInfo.EdbNameEn,
|
|
|
- EdbName: edbInfo.EdbName,
|
|
|
- Frequency: edbInfo.Frequency,
|
|
|
- FrequencyEn: edbInfo.FrequencyEn,
|
|
|
- Unit: edbInfo.Unit,
|
|
|
- UnitEn: edbInfo.UnitEn,
|
|
|
- StartDate: edbInfo.StartDate.Format(utils.FormatDate),
|
|
|
- EndDate: edbInfo.EndDate.Format(utils.FormatDate),
|
|
|
- LatestDate: edbInfo.LatestDate.Format(utils.FormatDate),
|
|
|
- LatestValue: edbInfo.LatestValue,
|
|
|
- EndValue: edbInfo.EndValue,
|
|
|
- ClassifyId: edbInfo.ClassifyId,
|
|
|
- UniqueCode: edbInfo.UniqueCode,
|
|
|
- SysUserId: edbInfo.SysUserId,
|
|
|
- SysUserRealName: edbInfo.SysUserRealName,
|
|
|
- //ModifyTime: ok:=edbInfo.ModifyTime.IsZero(); edbInfo.ModifyTime.Format(utils.FormatDateTime),
|
|
|
- CreateTime: edbInfo.CreateTime.Format(utils.FormatDateTime),
|
|
|
- EdbNameAlias: edbInfo.EdbNameAlias,
|
|
|
- EdbType: edbInfo.EdbType,
|
|
|
- ChartImage: edbInfo.ChartImage,
|
|
|
- RuleType: edbInfo.RuleType,
|
|
|
- FixedValue: edbInfo.FixedValue,
|
|
|
- DataList: edbInfo.DataList,
|
|
|
- PredictDataList: edbInfo.PredictDataList,
|
|
|
- Button: edbInfo.Button,
|
|
|
- IsEnEdb: edbInfo.IsEnEdb,
|
|
|
- DataInsertConfig: edbInfo.DataInsertConfig,
|
|
|
- DataDateType: edbInfo.DataDateType,
|
|
|
- EmptyType: edbInfo.EmptyType,
|
|
|
- MaxEmptyType: edbInfo.MaxEmptyType,
|
|
|
- SubSource: edbInfo.SubSource,
|
|
|
- SubSourceName: edbInfo.SubSourceName,
|
|
|
- IndicatorCode: edbInfo.IndicatorCode,
|
|
|
- StockCode: edbInfo.StockCode,
|
|
|
- NoUpdate: edbInfo.NoUpdate,
|
|
|
- IsJoinPermission: edbInfo.IsJoinPermission,
|
|
|
- HaveOperaAuth: edbInfo.HaveOperaAuth,
|
|
|
- IsStaticData: edbInfo.IsStaticData,
|
|
|
- IsSupplierStop: edbInfo.IsSupplierStop,
|
|
|
- MoveType: edbInfo.MoveType,
|
|
|
- MoveFrequency: edbInfo.MoveFrequency,
|
|
|
- MinValue: edbInfo.MinValue,
|
|
|
- MaxValue: edbInfo.MaxValue,
|
|
|
- SearchText: edbInfo.SearchText,
|
|
|
- }
|
|
|
- if !edbInfo.ModifyTime.IsZero() {
|
|
|
- edbinfoList.ModifyTime = edbInfo.ModifyTime.Format(utils.FormatDateTime)
|
|
|
- }
|
|
|
- return
|
|
|
-}
|
|
|
-
|
|
|
type EdbInfoList struct {
|
|
|
EdbInfoId int `orm:"column(edb_info_id);pk"`
|
|
|
EdbInfoType int `description:"指标类型,0:普通指标,1:预测指标"`
|
|
@@ -684,7 +677,8 @@ func GetEdbInfoByCondition(condition string, pars []interface{}) (item *EdbInfoL
|
|
|
if err != nil {
|
|
|
return
|
|
|
}
|
|
|
- item = ormItem.ToEdbInfo()
|
|
|
+ item = ormItem.ToList()
|
|
|
+
|
|
|
return
|
|
|
}
|
|
|
|
|
@@ -751,8 +745,15 @@ func GetAllEdbDataListByCondition(condition string, pars []interface{}, source,
|
|
|
|
|
|
func GetEdbInfoByNewest() (item *EdbInfoList, err error) {
|
|
|
o := orm.NewOrmUsingDB("data")
|
|
|
+
|
|
|
+ var ormItem *EdbInfoOrm
|
|
|
sql := ` SELECT * FROM edb_info WHERE 1=1 ORDER BY modify_time DESC LIMIT 1 `
|
|
|
- err = o.Raw(sql).QueryRow(&item)
|
|
|
+ err = o.Raw(sql).QueryRow(&ormItem)
|
|
|
+ if err != nil {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ item = ormItem.ToList()
|
|
|
+
|
|
|
return
|
|
|
}
|
|
|
|
|
@@ -782,24 +783,51 @@ func MoveEdbInfo(edbInfoId, classifyId int) (err error) {
|
|
|
|
|
|
// GetEdbInfoByName 根据名称获取普通的指标
|
|
|
func GetEdbInfoByName(edbName string) (items []*EdbInfoList, err error) {
|
|
|
+ var ormList []*EdbInfoOrm
|
|
|
+ items = make([]*EdbInfoList, 0)
|
|
|
o := orm.NewOrmUsingDB("data")
|
|
|
sql := ` SELECT * FROM edb_info WHERE edb_name=? AND edb_info_type = 0 `
|
|
|
- _, err = o.Raw(sql, edbName).QueryRows(&items)
|
|
|
+ _, err = o.Raw(sql, edbName).QueryRows(&ormList)
|
|
|
+ if err != nil {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ for _, ormItem := range ormList {
|
|
|
+ items = append(items, ormItem.ToList())
|
|
|
+ }
|
|
|
+
|
|
|
return
|
|
|
}
|
|
|
|
|
|
// GetPredictEdbInfoByName 根据指标名称获取预测指标
|
|
|
func GetPredictEdbInfoByName(edbName string) (items []*EdbInfoList, err error) {
|
|
|
+ var ormList []*EdbInfoOrm
|
|
|
+ items = make([]*EdbInfoList, 0)
|
|
|
o := orm.NewOrmUsingDB("data")
|
|
|
sql := ` SELECT * FROM edb_info WHERE edb_name=? AND edb_info_type = 1 `
|
|
|
- _, err = o.Raw(sql, edbName).QueryRows(&items)
|
|
|
+ _, err = o.Raw(sql, edbName).QueryRows(&ormList)
|
|
|
+ if err != nil {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ for _, ormItem := range ormList {
|
|
|
+ items = append(items, ormItem.ToList())
|
|
|
+ }
|
|
|
+
|
|
|
return
|
|
|
}
|
|
|
|
|
|
func GetEdbInfoByEnName(edbNameEn string) (items []*EdbInfoList, err error) {
|
|
|
+ var ormList []*EdbInfoOrm
|
|
|
+ items = make([]*EdbInfoList, 0)
|
|
|
o := orm.NewOrmUsingDB("data")
|
|
|
sql := ` SELECT * FROM edb_info WHERE edb_name_en=? AND edb_info_type = 0 `
|
|
|
- _, err = o.Raw(sql, edbNameEn).QueryRows(&items)
|
|
|
+ _, err = o.Raw(sql, edbNameEn).QueryRows(&ormList)
|
|
|
+ if err != nil {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ for _, ormItem := range ormList {
|
|
|
+ items = append(items, ormItem.ToList())
|
|
|
+ }
|
|
|
+
|
|
|
return
|
|
|
}
|
|
|
|
|
@@ -954,14 +982,23 @@ func ModifyEdbInfoMaxAndMinInfo(edbInfoId int, item *EdbInfoMaxAndMinInfo) (err
|
|
|
return
|
|
|
}
|
|
|
|
|
|
-func GetEdbInfoFilter(condition string, pars []interface{}) (list []*EdbInfoList, err error) {
|
|
|
+func GetEdbInfoFilter(condition string, pars []interface{}) (items []*EdbInfoList, err error) {
|
|
|
+ var ormList []*EdbInfoOrm
|
|
|
+ items = make([]*EdbInfoList, 0)
|
|
|
o := orm.NewOrmUsingDB("data")
|
|
|
sql := ` SELECT * FROM edb_info WHERE 1=1 AND edb_info_type = 0 `
|
|
|
if condition != "" {
|
|
|
sql += condition
|
|
|
}
|
|
|
sql += ` ORDER BY create_time DESC `
|
|
|
- _, err = o.Raw(sql, pars).QueryRows(&list)
|
|
|
+ _, err = o.Raw(sql, pars).QueryRows(&ormList)
|
|
|
+ if err != nil {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ for _, ormItem := range ormList {
|
|
|
+ items = append(items, ormItem.ToList())
|
|
|
+ }
|
|
|
+
|
|
|
return
|
|
|
}
|
|
|
|
|
@@ -991,19 +1028,29 @@ func GetEdbInfoCalculateListByCondition(condition string, pars []interface{}) (i
|
|
|
}
|
|
|
|
|
|
// GetEdbInfoAllCalculateByEdbInfoIdList 根据指标id集合 获取基础指标对应的所有计算指标
|
|
|
-func GetEdbInfoAllCalculateByEdbInfoIdList(edbInfoIdList []int) (list []*EdbInfo, err error) {
|
|
|
+func GetEdbInfoAllCalculateByEdbInfoIdList(edbInfoIdList []int) (items []*EdbInfo, err error) {
|
|
|
num := len(edbInfoIdList)
|
|
|
if num <= 0 {
|
|
|
return
|
|
|
}
|
|
|
|
|
|
+ var ormList []*EdbInfoOrm
|
|
|
+ items = make([]*EdbInfo, 0)
|
|
|
+
|
|
|
o := orm.NewOrmUsingDB("data")
|
|
|
sql := ` SELECT b.* FROM edb_info_calculate_mapping AS a
|
|
|
INNER JOIN edb_info AS b ON a.edb_info_id=b.edb_info_id
|
|
|
WHERE a.from_edb_info_id in (` + utils.GetOrmInReplace(num) + `)
|
|
|
GROUP BY a.edb_info_id
|
|
|
ORDER BY a.edb_info_id ASC `
|
|
|
- _, err = o.Raw(sql, edbInfoIdList).QueryRows(&list)
|
|
|
+ _, err = o.Raw(sql, edbInfoIdList).QueryRows(&ormList)
|
|
|
+ if err != nil {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ for _, ormItem := range ormList {
|
|
|
+ items = append(items, ormItem.ToInfo())
|
|
|
+ }
|
|
|
+
|
|
|
return
|
|
|
}
|
|
|
|
|
@@ -1040,9 +1087,15 @@ func ModifyEdbInfoDataStatus(edbInfoId int64, source, subSource int, edbCode str
|
|
|
|
|
|
// GetFirstEdbInfoByClassifyId 获取当前分类下,且排序数相同 的排序第一条的数据
|
|
|
func GetFirstEdbInfoByClassifyId(classifyId int) (item *EdbInfo, err error) {
|
|
|
+ var edbInfoOrm *EdbInfoOrm
|
|
|
o := orm.NewOrmUsingDB("data")
|
|
|
sql := ` SELECT * FROM edb_info WHERE classify_id=? order by sort asc,edb_info_id asc limit 1`
|
|
|
err = o.Raw(sql, classifyId).QueryRow(&item)
|
|
|
+ if err != nil {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ item = edbInfoOrm.ToInfo()
|
|
|
+
|
|
|
return
|
|
|
}
|
|
|
|
|
@@ -1582,7 +1635,7 @@ type EdbInfoFilterDataResp struct {
|
|
|
}
|
|
|
|
|
|
// GetEdbInfoFilterList 获取指指标列表数据接口
|
|
|
-func GetEdbInfoFilterList(condition string, pars []interface{}, startSize, pageSize int) (total int64, list []*EdbInfoList, err error) {
|
|
|
+func GetEdbInfoFilterList(condition string, pars []interface{}, startSize, pageSize int) (total int64, items []*EdbInfoList, err error) {
|
|
|
o := orm.NewOrmUsingDB("data")
|
|
|
|
|
|
sql := ` SELECT count(1) total FROM edb_info where 1=1 ` + condition + ` ORDER BY edb_info_id DESC `
|
|
@@ -1591,8 +1644,17 @@ func GetEdbInfoFilterList(condition string, pars []interface{}, startSize, pageS
|
|
|
return
|
|
|
}
|
|
|
|
|
|
+ var ormList []*EdbInfoOrm
|
|
|
+ items = make([]*EdbInfoList, 0)
|
|
|
sql = ` SELECT * FROM edb_info where 1=1 ` + condition + ` ORDER BY edb_info_id DESC LIMIT ?,? `
|
|
|
- _, err = o.Raw(sql, pars, startSize, pageSize).QueryRows(&list)
|
|
|
+ _, err = o.Raw(sql, pars, startSize, pageSize).QueryRows(&ormList)
|
|
|
+ if err != nil {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ for _, ormItem := range ormList {
|
|
|
+ items = append(items, ormItem.ToList())
|
|
|
+ }
|
|
|
+
|
|
|
return
|
|
|
}
|
|
|
|
|
@@ -1604,18 +1666,25 @@ type SetEdbInfoImageReq struct {
|
|
|
|
|
|
// GetNextEdbInfoByCondition 根据条件获取下一个指标
|
|
|
func GetNextEdbInfoByCondition(condition string, pars []interface{}) (item *EdbInfo, err error) {
|
|
|
+ var edbInfoOrm *EdbInfoOrm
|
|
|
o := orm.NewOrmUsingDB("data")
|
|
|
sql := ` SELECT * FROM edb_info WHERE 1=1 `
|
|
|
if condition != "" {
|
|
|
sql += condition
|
|
|
}
|
|
|
sql += " ORDER BY sort asc , edb_info_id asc LIMIT 1 "
|
|
|
- err = o.Raw(sql, pars).QueryRow(&item)
|
|
|
+ err = o.Raw(sql, pars).QueryRow(&edbInfoOrm)
|
|
|
+ if err != nil {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ item = edbInfoOrm.ToInfo()
|
|
|
+
|
|
|
return
|
|
|
}
|
|
|
|
|
|
// GetNextEdbInfo 根据分类id获取下一个 指标
|
|
|
func GetNextEdbInfo(classifyId, classifySort, classifyType, edbInfoType int) (item *EdbInfo, err error) {
|
|
|
+ var edbInfoOrm *EdbInfoOrm
|
|
|
o := orm.NewOrmUsingDB("data")
|
|
|
sql := ` SELECT b.* FROM edb_classify AS a
|
|
|
INNER JOIN edb_info AS b ON a.classify_id=b.classify_id
|
|
@@ -1623,7 +1692,12 @@ func GetNextEdbInfo(classifyId, classifySort, classifyType, edbInfoType int) (it
|
|
|
AND a.classify_type=? AND b.edb_info_type=?
|
|
|
ORDER BY a.sort ASC,b.sort asc,b.edb_info_id asc
|
|
|
LIMIT 1 `
|
|
|
- err = o.Raw(sql, classifySort, classifySort, classifyId, classifyType, edbInfoType).QueryRow(&item)
|
|
|
+ err = o.Raw(sql, classifySort, classifySort, classifyId, classifyType, edbInfoType).QueryRow(&edbInfoOrm)
|
|
|
+ if err != nil {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ item = edbInfoOrm.ToInfo()
|
|
|
+
|
|
|
return
|
|
|
}
|
|
|
|
|
@@ -1633,9 +1707,19 @@ func GetEdbInfoByEdbCodeList(source int, edbCodeList []string) (items []*EdbInfo
|
|
|
if num <= 0 {
|
|
|
return
|
|
|
}
|
|
|
+
|
|
|
+ var ormList []*EdbInfoOrm
|
|
|
+ items = make([]*EdbInfo, 0)
|
|
|
o := orm.NewOrmUsingDB("data")
|
|
|
sql := ` SELECT * FROM edb_info WHERE source=? AND edb_code in (` + utils.GetOrmInReplace(num) + `) `
|
|
|
- _, err = o.Raw(sql, source, edbCodeList).QueryRows(&items)
|
|
|
+ _, err = o.Raw(sql, source, edbCodeList).QueryRows(&ormList)
|
|
|
+ if err != nil {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ for _, ormItem := range ormList {
|
|
|
+ items = append(items, ormItem.ToInfo())
|
|
|
+ }
|
|
|
+
|
|
|
return
|
|
|
}
|
|
|
|
|
@@ -1652,6 +1736,9 @@ func GetEdbInfoByConditionCount(condition string, pars []interface{}) (count int
|
|
|
|
|
|
// GetEdbInfoListByCondition 根据条件获取指标列表数据
|
|
|
func GetEdbInfoListByCondition(condition string, pars []interface{}, startSize, pageSize int, orderDesc string) (items []*EdbInfoList, err error) {
|
|
|
+ var ormList []*EdbInfoOrm
|
|
|
+ items = make([]*EdbInfoList, 0)
|
|
|
+
|
|
|
o := orm.NewOrmUsingDB("data")
|
|
|
sql := ` SELECT * FROM edb_info WHERE 1=1 `
|
|
|
if condition != "" {
|
|
@@ -1669,19 +1756,36 @@ func GetEdbInfoListByCondition(condition string, pars []interface{}, startSize,
|
|
|
pars = append(pars, startSize, pageSize)
|
|
|
}
|
|
|
|
|
|
- _, err = o.Raw(sql, pars).QueryRows(&items)
|
|
|
+ _, err = o.Raw(sql, pars).QueryRows(&ormList)
|
|
|
+ if err != nil {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ for _, ormItem := range ormList {
|
|
|
+ items = append(items, ormItem.ToList())
|
|
|
+ }
|
|
|
+
|
|
|
return
|
|
|
}
|
|
|
|
|
|
// GetEdbInfoListV2ByCondition 根据条件获取指标列表数据(EdbInfo原始数据结构)
|
|
|
func GetEdbInfoListV2ByCondition(condition string, pars []interface{}, startSize, pageSize int) (items []*EdbInfo, err error) {
|
|
|
+ var ormList []*EdbInfoOrm
|
|
|
+ items = make([]*EdbInfo, 0)
|
|
|
+
|
|
|
o := orm.NewOrmUsingDB("data")
|
|
|
sql := ` SELECT * FROM edb_info WHERE 1=1 `
|
|
|
if condition != "" {
|
|
|
sql += condition
|
|
|
}
|
|
|
sql += ` ORDER BY edb_info_id ASC LIMIT ?,? `
|
|
|
- _, err = o.Raw(sql, pars, startSize, pageSize).QueryRows(&items)
|
|
|
+ _, err = o.Raw(sql, pars, startSize, pageSize).QueryRows(&ormList)
|
|
|
+ if err != nil {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ for _, ormItem := range ormList {
|
|
|
+ items = append(items, ormItem.ToInfo())
|
|
|
+ }
|
|
|
+
|
|
|
return
|
|
|
}
|
|
|
|
|
@@ -1691,10 +1795,20 @@ func GetEdbInfoListGroupByUserId(edbIdList []string) (items []*EdbInfo, err erro
|
|
|
if num <= 0 {
|
|
|
return
|
|
|
}
|
|
|
+
|
|
|
+ var ormList []*EdbInfoOrm
|
|
|
+ items = make([]*EdbInfo, 0)
|
|
|
+
|
|
|
o := orm.NewOrmUsingDB("data")
|
|
|
sql := ` SELECT * FROM edb_info WHERE edb_info_id in (` + utils.GetOrmInReplace(num) + `) GROUP BY sys_user_id `
|
|
|
+ _, err = o.Raw(sql, edbIdList).QueryRows(&ormList)
|
|
|
+ if err != nil {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ for _, ormItem := range ormList {
|
|
|
+ items = append(items, ormItem.ToInfo())
|
|
|
+ }
|
|
|
|
|
|
- _, err = o.Raw(sql, edbIdList).QueryRows(&items)
|
|
|
return
|
|
|
}
|
|
|
|
|
@@ -1708,10 +1822,21 @@ func GetEdbInfoListByEdbInfoId(edbIdList []string) (items []*EdbInfo, err error)
|
|
|
if num <= 0 {
|
|
|
return
|
|
|
}
|
|
|
+
|
|
|
+ var ormList []*EdbInfoOrm
|
|
|
+ items = make([]*EdbInfo, 0)
|
|
|
+
|
|
|
o := orm.NewOrmUsingDB("data")
|
|
|
sql := ` SELECT * FROM edb_info WHERE edb_info_id in (` + utils.GetOrmInReplace(num) + `) `
|
|
|
|
|
|
- _, err = o.Raw(sql, edbIdList).QueryRows(&items)
|
|
|
+ _, err = o.Raw(sql, edbIdList).QueryRows(&ormList)
|
|
|
+ if err != nil {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ for _, ormItem := range ormList {
|
|
|
+ items = append(items, ormItem.ToInfo())
|
|
|
+ }
|
|
|
+
|
|
|
return
|
|
|
}
|
|
|
|
|
@@ -1726,10 +1851,20 @@ func GetEdbInfoListByUserId(userIdList []int, edbInfoType int) (items []*EdbInfo
|
|
|
if num <= 0 {
|
|
|
return
|
|
|
}
|
|
|
+
|
|
|
+ var ormList []*EdbInfoOrm
|
|
|
+ items = make([]*EdbInfo, 0)
|
|
|
+
|
|
|
o := orm.NewOrmUsingDB("data")
|
|
|
sql := ` SELECT * FROM edb_info WHERE edb_info_type = ? AND sys_user_id in (` + utils.GetOrmInReplace(num) + `) `
|
|
|
|
|
|
- _, err = o.Raw(sql, edbInfoType, userIdList).QueryRows(&items)
|
|
|
+ _, err = o.Raw(sql, edbInfoType, userIdList).QueryRows(&ormList)
|
|
|
+ if err != nil {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ for _, ormItem := range ormList {
|
|
|
+ items = append(items, ormItem.ToInfo())
|
|
|
+ }
|
|
|
return
|
|
|
}
|
|
|
|
|
@@ -1929,9 +2064,18 @@ func GetEdbInfoWsdMaxAndMinInfo(source, subSource int, edbCode string) (item *Ed
|
|
|
|
|
|
// GetEdbInfoByNames 根据名称获取普通的指标
|
|
|
func GetEdbInfoByNames(edbNames string) (items []*EdbInfoList, err error) {
|
|
|
+ var ormList []*EdbInfoOrm
|
|
|
+ items = make([]*EdbInfoList, 0)
|
|
|
o := orm.NewOrmUsingDB("data")
|
|
|
sql := ` SELECT * FROM edb_info WHERE edb_name IN (` + edbNames + `) AND edb_info_type = 0 `
|
|
|
- _, err = o.Raw(sql).QueryRows(&items)
|
|
|
+ _, err = o.Raw(sql).QueryRows(&ormList)
|
|
|
+ if err != nil {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ for _, ormItem := range ormList {
|
|
|
+ items = append(items, ormItem.ToList())
|
|
|
+ }
|
|
|
+
|
|
|
return
|
|
|
}
|
|
|
|
|
@@ -2053,9 +2197,18 @@ func GetEdbInfoByNameArr(names []string, edbInfoType int) (items []*EdbInfo, err
|
|
|
if len(names) == 0 {
|
|
|
return
|
|
|
}
|
|
|
+ var ormList []*EdbInfoOrm
|
|
|
+ items = make([]*EdbInfo, 0)
|
|
|
o := orm.NewOrmUsingDB("data")
|
|
|
sql := fmt.Sprintf(`SELECT edb_info_id, edb_code, edb_name FROM edb_info WHERE edb_name IN (%s) AND edb_info_type = ? `, utils.GetOrmInReplace(len(names)))
|
|
|
- _, err = o.Raw(sql, names, edbInfoType).QueryRows(&items)
|
|
|
+ _, err = o.Raw(sql, names, edbInfoType).QueryRows(&ormList)
|
|
|
+ if err != nil {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ for _, ormItem := range ormList {
|
|
|
+ items = append(items, ormItem.ToInfo())
|
|
|
+ }
|
|
|
+
|
|
|
return
|
|
|
}
|
|
|
|
|
@@ -2064,17 +2217,35 @@ func GetEdbInfoByCodeArr(codes []string, edbInfoType int) (items []*EdbInfo, err
|
|
|
if len(codes) == 0 {
|
|
|
return
|
|
|
}
|
|
|
+ var ormList []*EdbInfoOrm
|
|
|
+ items = make([]*EdbInfo, 0)
|
|
|
o := orm.NewOrmUsingDB("data")
|
|
|
sql := fmt.Sprintf(`SELECT edb_info_id, edb_code, edb_name FROM edb_info WHERE edb_code IN (%s) AND edb_info_type = ? `, utils.GetOrmInReplace(len(codes)))
|
|
|
- _, err = o.Raw(sql, codes, edbInfoType).QueryRows(&items)
|
|
|
+ _, err = o.Raw(sql, codes, edbInfoType).QueryRows(&ormList)
|
|
|
+ if err != nil {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ for _, ormItem := range ormList {
|
|
|
+ items = append(items, ormItem.ToInfo())
|
|
|
+ }
|
|
|
+
|
|
|
return
|
|
|
}
|
|
|
|
|
|
// GetEdbCodesBySource 根据来源获取指标编码
|
|
|
func GetEdbCodesBySource(source int) (items []*EdbInfo, err error) {
|
|
|
+ var ormList []*EdbInfoOrm
|
|
|
+ items = make([]*EdbInfo, 0)
|
|
|
o := orm.NewOrmUsingDB("data")
|
|
|
sql := ` SELECT edb_info_id, edb_code, unique_code, classify_id FROM edb_info WHERE source = ? `
|
|
|
- _, err = o.Raw(sql, source).QueryRows(&items)
|
|
|
+ _, err = o.Raw(sql, source).QueryRows(&ormList)
|
|
|
+ if err != nil {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ for _, ormItem := range ormList {
|
|
|
+ items = append(items, ormItem.ToInfo())
|
|
|
+ }
|
|
|
+
|
|
|
return
|
|
|
}
|
|
|
|
|
@@ -2228,9 +2399,19 @@ func GetEdbInfoFieldList(cond string, pars []interface{}, fields []string) (item
|
|
|
if len(fields) > 0 {
|
|
|
field = strings.Join(fields, ",")
|
|
|
}
|
|
|
+ var ormList []*EdbInfoOrm
|
|
|
+ items = make([]*EdbInfo, 0)
|
|
|
+
|
|
|
o := orm.NewOrmUsingDB("data")
|
|
|
sql := fmt.Sprintf(`SELECT %s FROM edb_info WHERE 1=1 %s `, field, cond)
|
|
|
- _, err = o.Raw(sql, pars).QueryRows(&items)
|
|
|
+ _, err = o.Raw(sql, pars).QueryRows(&ormList)
|
|
|
+ if err != nil {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ for _, ormItem := range ormList {
|
|
|
+ items = append(items, ormItem.ToInfo())
|
|
|
+ }
|
|
|
+
|
|
|
return
|
|
|
}
|
|
|
|
|
@@ -2239,14 +2420,24 @@ type EdbInfoExtra struct {
|
|
|
ApiExtraPars string `description:"API-额外参数(如同花顺日期序列)"`
|
|
|
}
|
|
|
|
|
|
-func GetEdbInfoListByCond(condition string, pars []interface{}) (list []*EdbInfoList, err error) {
|
|
|
+func GetEdbInfoListByCond(condition string, pars []interface{}) (items []*EdbInfoList, err error) {
|
|
|
+ var ormList []*EdbInfoOrm
|
|
|
+ items = make([]*EdbInfoList, 0)
|
|
|
+
|
|
|
o := orm.NewOrmUsingDB("data")
|
|
|
sql := ` SELECT * FROM edb_info WHERE 1=1 `
|
|
|
if condition != "" {
|
|
|
sql += condition
|
|
|
}
|
|
|
sql += ` ORDER BY create_time DESC `
|
|
|
- _, err = o.Raw(sql, pars).QueryRows(&list)
|
|
|
+ _, err = o.Raw(sql, pars).QueryRows(&ormList)
|
|
|
+ if err != nil {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ for _, ormItem := range ormList {
|
|
|
+ items = append(items, ormItem.ToList())
|
|
|
+ }
|
|
|
+
|
|
|
return
|
|
|
}
|
|
|
|