base_from_gpr_risk.go 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  1. package data_manage
  2. import (
  3. "github.com/beego/beego/v2/client/orm"
  4. "github.com/rdlucklib/rdluck_tools/paging"
  5. "time"
  6. )
  7. type BaseFromGprRiskIndex struct {
  8. BaseFromGprRiskIndexId int `orm:"column(base_from_gpr_risk_index_id);pk"`
  9. ClassifyId int
  10. IndexCode string
  11. IndexName string
  12. Frequency string
  13. Unit string
  14. Sort int
  15. StartDate string `description:"开始日期"`
  16. EndDate string `description:"结束日期"`
  17. EndValue float64
  18. CreateTime time.Time
  19. ModifyTime time.Time
  20. }
  21. // BaseFromGprRiskClassify GprRisk原始数据分类表
  22. type BaseFromGprRiskClassify struct {
  23. ClassifyId int `orm:"column(classify_id);pk"`
  24. ClassifyName string `description:"分类名称"`
  25. ParentId int `description:"父级id"`
  26. SysUserId int `description:"创建人id"`
  27. SysUserRealName string `description:"创建人姓名"`
  28. Level int `description:"层级"`
  29. Sort int `description:"排序字段,越小越靠前,默认值:10"`
  30. ModifyTime time.Time `description:"修改时间"`
  31. CreateTime time.Time `description:"创建时间"`
  32. }
  33. func GetBaseFromGprRiskIndexMaxDate() (max_date time.Time, err error) {
  34. o := orm.NewOrm()
  35. sql := ` SELECT max(a.modify_time)as max_date FROM base_from_gpr_risk_data as a `
  36. err = o.Raw(sql).QueryRow(&max_date)
  37. return
  38. }
  39. type GprRiskIndexResp struct {
  40. Ret int
  41. Msg string
  42. ErrMsg string
  43. ErrCode string
  44. Data []*BaseFromGprRiskIndex
  45. }
  46. func GetBaseFromGprRiskIndexAll(dateStr string) (list []*BaseFromGprRiskIndex, err error) {
  47. o := orm.NewOrm()
  48. sql := `SELECT * FROM base_from_gpr_risk_index WHERE end_date>=?`
  49. _, err = o.Raw(sql, dateStr).QueryRows(&list)
  50. return
  51. }
  52. func (obj *BaseFromGprRiskIndex) AddBaseFromGprRiskIndex(item *BaseFromGprRiskIndex) (lastId int64, err error) {
  53. o := orm.NewOrm()
  54. lastId, err = o.Insert(item)
  55. return
  56. }
  57. func (obj *BaseFromGprRiskIndex) InsertOrUpdateBaseFromGprRiskIndex(item *BaseFromGprRiskIndex) (lastId int64, err error) {
  58. o := orm.NewOrm()
  59. lastId, err = o.InsertOrUpdate(item)
  60. return
  61. }
  62. type GprRiskClassifyResp struct {
  63. Ret int
  64. Msg string
  65. ErrMsg string
  66. ErrCode string
  67. Data []*BaseFromGprRiskClassify
  68. }
  69. func GetBaseFromGprRiskClassifyAll() (list []*BaseFromGprRiskClassify, err error) {
  70. o := orm.NewOrm()
  71. sql := `SELECT * FROM base_from_gpr_risk_classify `
  72. _, err = o.Raw(sql).QueryRows(&list)
  73. return
  74. }
  75. func AddBaseFromGprRiskClassify(item *BaseFromGprRiskClassify) (lastId int64, err error) {
  76. o := orm.NewOrm()
  77. lastId, err = o.Insert(item)
  78. return
  79. }
  80. func InsertOrUpdateBaseFromGprRiskClassify(item *BaseFromGprRiskClassify) (lastId int64, err error) {
  81. o := orm.NewOrm()
  82. lastId, err = o.InsertOrUpdate(item)
  83. return
  84. }
  85. // GetBaseFromComTradeMaxDate 获取GprRisk消费者指数最大数据
  86. func GetBaseFromGprRiskMaxDate() (max_date time.Time, err error) {
  87. o := orm.NewOrm()
  88. sql := ` SELECT max(a.modify_time)as max_date FROM base_from_gpr_risk_data as a `
  89. err = o.Raw(sql).QueryRow(&max_date)
  90. return
  91. }
  92. type BaseFromGprRiskData struct {
  93. BaseFromGprRiskDataId int `orm:"column(base_from_gpr_risk_data_id);pk"`
  94. BaseFromGprRiskIndexId int `description:"指标id"`
  95. IndexCode string `description:"指标编码"`
  96. DataTime string `description:"日期"`
  97. Value string `description:"值"`
  98. CreateTime time.Time `description:"创建时间"`
  99. ModifyTime time.Time `description:"修改时间"`
  100. }
  101. // GetAllComTradeDataList 获取GprRisk消费者指数数据
  102. func GetAllBaseFromGprRiskDataList(startDate string) (list []*BaseFromGprRiskData, err error) {
  103. o := orm.NewOrm()
  104. sql := `SELECT * FROM base_from_gpr_risk_data WHERE modify_time>=? ORDER BY base_from_gpr_risk_data_id ASC `
  105. _, err = o.Raw(sql, startDate).QueryRows(&list)
  106. return
  107. }
  108. type BaseFromGprRiskDataResp struct {
  109. Ret int
  110. Msg string
  111. ErrMsg string
  112. ErrCode string
  113. Data BaseFromGprRiskDataIndexAndDataResp
  114. }
  115. // ComTradeIndexDataResp 分页列表响应体
  116. type BaseFromGprRiskDataIndexAndDataResp struct {
  117. List []*BaseFromGprRiskData
  118. Paging *paging.PagingItem `description:"分页数据"`
  119. }
  120. // MultiAddBaseFromComTradeData 批量添加数据
  121. func MultiAddBaseFromGprRiskDataIndex(items []*BaseFromGprRiskData) (lastId int64, err error) {
  122. num := len(items)
  123. if num <= 0 {
  124. return
  125. }
  126. o := orm.NewOrm()
  127. lastId, err = o.InsertMulti(num, items)
  128. return
  129. }