excel_info.go 2.5 KB

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