excel_edb_mapping.go 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. package excel
  2. import (
  3. "eta_gn/eta_index_lib/global"
  4. "time"
  5. )
  6. // ExcelEdbMapping excel与指标的关系表
  7. type ExcelEdbMapping struct {
  8. ExcelEdbMappingId int `gorm:"primaryKey;autoIncrement;column:excel_edb_mapping_id"`
  9. ExcelInfoId int `gorm:"column:excel_info_id" description:"excel的id"`
  10. Source int `gorm:"column:source" description:"表格来源,1:excel插件的表格,2:自定义表格,3:混合表格,4:自定义分析,默认:1"`
  11. EdbInfoId int `gorm:"column:edb_info_id" description:"计算指标id"`
  12. CreateTime time.Time `gorm:"column:create_time" description:"创建时间"`
  13. ModifyTime time.Time `gorm:"column:modify_time" description:"修改时间"`
  14. }
  15. // Add 添加excel与指标的关系
  16. func (e *ExcelEdbMapping) Add() (err error) {
  17. err = global.DEFAULT_DmSQL.Create(e).Error
  18. return
  19. }
  20. type ExcelEdbMappingItem struct {
  21. EdbInfoId int `description:"指标id"`
  22. UniqueCode string `description:"唯一编码"`
  23. EdbName string `description:"指标名称"`
  24. ClassifyId int `description:"分类id"`
  25. Frequency string `description:"频度"`
  26. Unit string `description:"单位"`
  27. CalculateFormula string `json:"-"`
  28. DateSequenceStr string `description:"日期序列公式"`
  29. DataSequenceStr string `description:"数据序列公式"`
  30. }
  31. // CalculateFormula 计算公式
  32. type CalculateFormula struct {
  33. DateSequenceStr string `json:"DateSequenceStr"`
  34. DataSequenceStr string `json:"DataSequenceStr"`
  35. }
  36. // GetExcelEdbMappingByEdbInfoId 根据指标id获取配置关系
  37. func GetExcelEdbMappingByEdbInfoId(edbInfoId int) (item *ExcelEdbMapping, err error) {
  38. sql := ` SELECT * FROM excel_edb_mapping WHERE 1=1 AND edb_info_id = ? `
  39. err = global.DEFAULT_DmSQL.Raw(sql, edbInfoId).First(&item).Error
  40. return
  41. }