package data_manage import ( "github.com/beego/beego/v2/client/orm" "github.com/rdlucklib/rdluck_tools/paging" "time" ) 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 } // BaseFromGprRiskClassify GprRisk原始数据分类表 type BaseFromGprRiskClassify struct { ClassifyId int `orm:"column(classify_id);pk"` ClassifyName string `description:"分类名称"` ParentId int `description:"父级id"` SysUserId int `description:"创建人id"` SysUserRealName string `description:"创建人姓名"` Level int `description:"层级"` Sort int `description:"排序字段,越小越靠前,默认值:10"` ModifyTime time.Time `description:"修改时间"` CreateTime time.Time `description:"创建时间"` } func GetBaseFromGprRiskIndexMaxDate() (max_date time.Time, err error) { o := orm.NewOrm() sql := ` SELECT max(a.modify_time)as max_date FROM base_from_gpr_risk_data as a ` err = o.Raw(sql).QueryRow(&max_date) return } type GprRiskIndexResp struct { Ret int Msg string ErrMsg string ErrCode string Data []*BaseFromGprRiskIndex } func GetBaseFromGprRiskIndexAll(dateStr string) (list []*BaseFromGprRiskIndex, err error) { o := orm.NewOrm() sql := `SELECT * FROM base_from_gpr_risk_index WHERE end_date>=?` _, err = o.Raw(sql, dateStr).QueryRows(&list) return } func (obj *BaseFromGprRiskIndex) AddBaseFromGprRiskIndex(item *BaseFromGprRiskIndex) (lastId int64, err error) { o := orm.NewOrm() lastId, err = o.Insert(item) return } func (obj *BaseFromGprRiskIndex) InsertOrUpdateBaseFromGprRiskIndex(item *BaseFromGprRiskIndex) (lastId int64, err error) { o := orm.NewOrm() lastId, err = o.InsertOrUpdate(item) return } type GprRiskClassifyResp struct { Ret int Msg string ErrMsg string ErrCode string Data []*BaseFromGprRiskClassify } func GetBaseFromGprRiskClassifyAll() (list []*BaseFromGprRiskClassify, err error) { o := orm.NewOrm() sql := `SELECT * FROM base_from_gpr_risk_classify ` _, err = o.Raw(sql).QueryRows(&list) return } func AddBaseFromGprRiskClassify(item *BaseFromGprRiskClassify) (lastId int64, err error) { o := orm.NewOrm() lastId, err = o.Insert(item) return } func InsertOrUpdateBaseFromGprRiskClassify(item *BaseFromGprRiskClassify) (lastId int64, err error) { o := orm.NewOrm() lastId, err = o.InsertOrUpdate(item) return } // GetBaseFromComTradeMaxDate 获取GprRisk消费者指数最大数据 func GetBaseFromGprRiskMaxDate() (max_date time.Time, err error) { o := orm.NewOrm() sql := ` SELECT max(a.modify_time)as max_date FROM base_from_gpr_risk_data as a ` err = o.Raw(sql).QueryRow(&max_date) return } type BaseFromGprRiskData struct { BaseFromGprRiskDataId int `orm:"column(base_from_gpr_risk_data_id);pk"` BaseFromGprRiskIndexId int `description:"指标id"` IndexCode string `description:"指标编码"` DataTime string `description:"日期"` Value string `description:"值"` CreateTime time.Time `description:"创建时间"` ModifyTime time.Time `description:"修改时间"` } // GetAllComTradeDataList 获取GprRisk消费者指数数据 func GetAllBaseFromGprRiskDataList(startDate string) (list []*BaseFromGprRiskData, err error) { o := orm.NewOrm() sql := `SELECT * FROM base_from_gpr_risk_data WHERE modify_time>=? ORDER BY base_from_gpr_risk_data_id ASC ` _, err = o.Raw(sql, startDate).QueryRows(&list) return } type BaseFromGprRiskDataResp struct { Ret int Msg string ErrMsg string ErrCode string Data BaseFromGprRiskDataIndexAndDataResp } // ComTradeIndexDataResp 分页列表响应体 type BaseFromGprRiskDataIndexAndDataResp struct { List []*BaseFromGprRiskData Paging *paging.PagingItem `description:"分页数据"` } // MultiAddBaseFromComTradeData 批量添加数据 func MultiAddBaseFromGprRiskDataIndex(items []*BaseFromGprRiskData) (lastId int64, err error) { num := len(items) if num <= 0 { return } o := orm.NewOrm() lastId, err = o.InsertMulti(num, items) return }