package data_manage import ( "eta/eta_api/utils" "time" "github.com/beego/beego/v2/client/orm" "github.com/rdlucklib/rdluck_tools/paging" ) type BaseFromGprRiskIndex struct { BaseFromGprRiskIndexId int `orm:"column(base_from_gpr_risk_index_id);pk"` ClassifyId int IndexCode string IndexName string Frequency string Unit string Sort int StartDate string `description:"开始日期"` EndDate string `description:"结束日期"` EndValue float64 CreateTime time.Time ModifyTime time.Time } type BaseFromGprRiskIndexList struct { BaseFromGprRiskIndexId int `orm:"column(base_from_gpr_risk_index_id);pk"` ClassifyId int Interface string EdbInfoId int EdbUniqueCode string `description:"指标库唯一编码"` EdbClassifyId int `description:"指标库分类ID"` StartDate string EndDate string EndValue float64 IndexCode string IndexName string Frequency string Unit string Sort int CreateTime string ModifyTime string EdbExist int `description:"指标库是否已添加:0-否;1-是"` DataList []*BaseFromGprRiskData Paging *paging.PagingItem `description:"分页数据"` } type BaseFromGprRiskIndexSearchList struct { List []*BaseFromGprRiskIndexList Paging *paging.PagingItem `description:"分页数据"` } type GprRiskSingleDataResp struct { BaseFromGprRiskIndexId int ClassifyId int EdbInfoId int IndexCode string IndexName string Frequency string Unit string StartTime string CreateTime string ModifyTime string EdbExist int `description:"指标库是否已添加:0-否;1-是"` Data []*GprRiskSingleData Paging *paging.PagingItem `description:"分页数据"` } type GprRiskSingleData struct { Value string `orm:"column(value)" description:"日期"` DataTime string `orm:"column(data_time)" description:"值"` } func GetGprRiskIndexByClassifyId(classifyId int) (items []*BaseFromGprRiskIndex, err error) { o := orm.NewOrmUsingDB("data") sql := ` SELECT base_from_gpr_risk_index_id, classify_id, index_code, index_name FROM base_from_gpr_risk_index WHERE classify_id=? ORDER BY sort ASC, base_from_gpr_risk_index_id ASC ` _, err = o.Raw(sql, classifyId).QueryRows(&items) return } func GetGprRiskIndex(condition string, pars interface{}) (items []*BaseFromGprRiskIndexList, err error) { o := orm.NewOrmUsingDB("data") sql := ` SELECT * FROM base_from_gpr_risk_index WHERE 1=1 ` if condition != "" { sql += condition } sql += ` ORDER BY sort ASC, base_from_gpr_risk_index_id asc` _, err = o.Raw(sql, pars).QueryRows(&items) return } func GetGprRiskIndexPage(condition string, pars interface{}, startSize, pageSize int) (items []*BaseFromGprRiskIndexList, err error) { o := orm.NewOrmUsingDB("data") sql := ` SELECT * FROM base_from_gpr_risk_index WHERE 1=1 ` if condition != "" { sql += condition } sql += ` ORDER BY sort ASC, base_from_gpr_risk_index_id asc LIMIT ?,?` _, err = o.Raw(sql, pars, startSize, pageSize).QueryRows(&items) return } func GetGprRiskIndexPageCount(condition string, pars interface{}) (count int, err error) { o := orm.NewOrmUsingDB("data") sql := ` SELECT COUNT(1) AS count FROM base_from_gpr_risk_index WHERE 1=1 ` if condition != "" { sql += condition } err = o.Raw(sql, pars).QueryRow(&count) return } func GetGprRiskIndexDataCount(indexCode string) (count int, err error) { o := orm.NewOrmUsingDB("data") sql := ` SELECT COUNT(1) AS count FROM base_from_gpr_risk_data WHERE index_code=? ` err = o.Raw(sql, indexCode).QueryRow(&count) return } func GetGprRiskIndexDataByDataTime(indexCodes []string, startDate, endDate string) (items []*BaseFromGprRiskData, err error) { o := orm.NewOrmUsingDB("data") sql := ` SELECT * FROM base_from_gpr_risk_data WHERE index_code in (` + utils.GetOrmInReplace(len(indexCodes)) + `) and data_time >=? and data_time