excel_info.go 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. package excel
  2. import (
  3. "eta/eta_task/global"
  4. "eta/eta_task/utils"
  5. "fmt"
  6. "strings"
  7. "time"
  8. )
  9. // ExcelInfo excel表格详情表
  10. type ExcelInfo struct {
  11. ExcelInfoId int `gorm:"column:excel_info_id;primaryKey;autoIncrement"`
  12. Source int `description:"表格来源,1:excel插件的表格,2:自定义表格,3:混合表格,4:自定义分析,默认:1"`
  13. ExcelType int `description:"表格类型,1:指标列,2:日期列,默认:1"`
  14. ExcelName string `description:"表格名称"`
  15. UniqueCode string `description:"表格唯一编码"`
  16. ExcelClassifyId int `description:"表格分类id"`
  17. SysUserId int `description:"操作人id"`
  18. SysUserRealName string `description:"操作人真实姓名"`
  19. Content string `description:"表格内容"`
  20. ExcelImage string `description:"表格图片"`
  21. FileUrl string `description:"表格下载地址"`
  22. Sort int `description:"排序字段,数字越小越排前面"`
  23. IsDelete int `description:"是否删除,0:未删除,1:已删除"`
  24. ModifyTime time.Time `description:"最近修改日期"`
  25. CreateTime time.Time `description:"创建日期"`
  26. IsJoinPermission int `description:"是否加入权限管控,0:不加入;1:加入;默认:0"`
  27. ParentId int `description:"表格的父级id"`
  28. BalanceType int `description:"平衡表类型:0 动态表,1静态表"`
  29. UpdateUserId int `description:"更新人id"`
  30. UpdateUserRealName string `description:"更新人真实姓名"`
  31. RelExcelInfoId int `description:"平衡表里静态表关联的动态表excel id"`
  32. VersionName string `description:"静态表版本名称"`
  33. SourcesFrom string `description:"图表来源"`
  34. ExtraConfig string `description:"额外配置:如多空分析、相关性表格参数"`
  35. }
  36. func (m *ExcelInfo) TableName() string {
  37. return "excel_info"
  38. }
  39. func (m *ExcelInfo) GetItemsByCondition(condition string, pars []interface{}, fieldArr []string, orderRule string) (items []*ExcelInfo, err error) {
  40. o := global.DbMap[utils.DbNameIndex]
  41. fields := strings.Join(fieldArr, ",")
  42. if len(fieldArr) == 0 {
  43. fields = `*`
  44. }
  45. order := `ORDER BY create_time DESC`
  46. if orderRule != "" {
  47. order = ` ORDER BY ` + orderRule
  48. }
  49. sql := fmt.Sprintf(`SELECT %s FROM %s WHERE 1=1 %s %s`, fields, m.TableName(), condition, order)
  50. err = o.Raw(sql, pars...).Find(&items).Error
  51. return
  52. }