base_from_icpi.go 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. package data_manage
  2. import (
  3. "github.com/beego/beego/v2/client/orm"
  4. "time"
  5. )
  6. type BaseFromIcpiIndex struct {
  7. BaseFromIcpiIndexId int `orm:"column(base_from_icpi_index_id);pk"`
  8. BaseFromIcpiClassifyId int `description:"分类id"`
  9. IndexCode string `description:"指标编码"`
  10. IndexName string `description:"指标名称"`
  11. Frequency string `description:"频度"`
  12. StartDate time.Time `description:"开始日期"`
  13. EndDate time.Time `description:"结束日期"`
  14. CreateTime time.Time `description:"创建时间"`
  15. ModifyTime time.Time `description:"修改时间"`
  16. }
  17. func GetBaseFromIcpiIndexMaxDate() (max_date time.Time, err error) {
  18. o := orm.NewOrm()
  19. sql := ` SELECT max(a.data_time)as max_date FROM base_from_icpi_data as a `
  20. err = o.Raw(sql).QueryRow(&max_date)
  21. return
  22. }
  23. type IcpiIndexResp struct {
  24. Ret int
  25. Msg string
  26. ErrMsg string
  27. ErrCode string
  28. Data []*BaseFromIcpiIndex
  29. }
  30. func GetBaseFromIcpiIndexAll(dateStr string) (list []*BaseFromIcpiIndex, err error) {
  31. o := orm.NewOrm()
  32. sql := `SELECT * FROM base_from_icpi_index WHERE end_date>=?`
  33. _, err = o.Raw(sql, dateStr).QueryRows(&list)
  34. return
  35. }
  36. func (obj *BaseFromIcpiIndex) AddBaseFromIcpiIndex(item *BaseFromIcpiIndex) (lastId int64, err error) {
  37. o := orm.NewOrm()
  38. lastId, err = o.Insert(item)
  39. return
  40. }
  41. type BaseFromIcpiClassify struct {
  42. BaseFromIcpiClassifyId int `orm:"column(base_from_icpi_classify_id);pk"`
  43. ClassifyName string `description:"分类名称"`
  44. ClassifyNameEn string `description:"英文名称"`
  45. ParentId int `description:"上级id"`
  46. CreateTime string `description:"创建时间"`
  47. ModifyTime string `description:"修改时间"`
  48. }
  49. type IcpiClassifyResp struct {
  50. Ret int
  51. Msg string
  52. ErrMsg string
  53. ErrCode string
  54. Data []*BaseFromIcpiClassify
  55. }
  56. func GetBaseFromIcpiClassifyAll() (list []*BaseFromIcpiClassify, err error) {
  57. o := orm.NewOrm()
  58. sql := `SELECT * FROM base_from_icpi_classify `
  59. _, err = o.Raw(sql).QueryRows(&list)
  60. return
  61. }
  62. func AddBaseFromIcpiClassify(item *BaseFromIcpiClassify) (lastId int64, err error) {
  63. o := orm.NewOrm()
  64. lastId, err = o.Insert(item)
  65. return
  66. }