fe_calendar_matter.go 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. package fe_calendar
  2. import (
  3. "eta_gn/eta_task/global"
  4. "fmt"
  5. "strings"
  6. "time"
  7. )
  8. const (
  9. MatterTypeFree = 1 // 事项类型-自定义事项
  10. MatterTypeEdb = 2 // 事项类型-基础指标
  11. MatterTypePredict = 3 // 事项类型-预测指标
  12. )
  13. type FeCalendarMatter struct {
  14. FeCalendarMatterId int `gorm:"column:fe_calendar_matter_id;primaryKey"` // `orm:"column(fe_calendar_matter_id);pk" description:"事项ID"`
  15. ChartPermissionId int `description:"品种ID"`
  16. ChartPermissionName string `description:"品种名称"`
  17. MatterMonth string `description:"事项年月:格式2006-01"`
  18. MatterDate time.Time `description:"事项日期"`
  19. Title string `description:"标题"`
  20. MatterType int `description:"事项类型:1-自定义事项;2-基础指标;3-预测指标"`
  21. EdbInfoId int `description:"指标ID"`
  22. EdbUniqueCode string `description:"指标唯一编码"`
  23. EdbCode string `description:"指标编码"`
  24. FontColor string `description:"字体颜色"`
  25. FillingColor string `description:"填充颜色"`
  26. FontBold int `description:"字体加粗:0-否;1-是"`
  27. Sort int `description:"排序"`
  28. SysUserId int `description:"创建人ID"`
  29. SysUserName string `description:"创建人姓名"`
  30. CreateTime time.Time `description:"创建时间"`
  31. ModifyTime time.Time `description:"更新时间"`
  32. }
  33. var FeCalendarMatterCols = struct {
  34. FeCalendarMatterId string
  35. ChartPermissionId string
  36. ChartPermissionName string
  37. MatterMonth string
  38. MatterDate string
  39. Title string
  40. MatterType string
  41. EdbInfoId string
  42. EdbUniqueCode string
  43. EdbCode string
  44. FontColor string
  45. FillingColor string
  46. FontBold string
  47. Sort string
  48. SysUserId string
  49. SysUserName string
  50. CreateTime string
  51. ModifyTime string
  52. }{
  53. FeCalendarMatterId: "fe_calendar_matter_id",
  54. ChartPermissionId: "chart_permission_id",
  55. ChartPermissionName: "chart_permission_name",
  56. MatterMonth: "matter_month",
  57. MatterDate: "matter_date",
  58. Title: "title",
  59. MatterType: "matter_type",
  60. EdbInfoId: "edb_info_id",
  61. EdbUniqueCode: "edb_unique_code",
  62. EdbCode: "edb_code",
  63. FontColor: "font_color",
  64. FillingColor: "filling_color",
  65. FontBold: "font_bold",
  66. Sort: "sort",
  67. SysUserId: "sys_user_id",
  68. SysUserName: "sys_user_name",
  69. CreateTime: "create_time",
  70. ModifyTime: "modify_time",
  71. }
  72. func (m *FeCalendarMatter) TableName() string {
  73. return "fe_calendar_matter"
  74. }
  75. func (m *FeCalendarMatter) PrimaryId() string {
  76. return FeCalendarMatterCols.FeCalendarMatterId
  77. }
  78. func (m *FeCalendarMatter) GetItemByCondition(condition string, pars []interface{}, orderRule string) (item *FeCalendarMatter, err error) {
  79. order := ``
  80. if orderRule != "" {
  81. order = ` ORDER BY ` + orderRule
  82. }
  83. sql := fmt.Sprintf(`SELECT * FROM %s WHERE 1=1 %s %s LIMIT 1`, m.TableName(), condition, order)
  84. err = global.DmSQL["data"].Raw(sql, pars...).First(&item).Error
  85. return
  86. }
  87. func (m *FeCalendarMatter) GetCountByCondition(condition string, pars []interface{}) (count int, err error) {
  88. sql := fmt.Sprintf(`SELECT COUNT(1) FROM %s WHERE 1=1 %s`, m.TableName(), condition)
  89. err = global.DmSQL["data"].Raw(sql, pars...).Scan(&count).Error
  90. return
  91. }
  92. func (m *FeCalendarMatter) GetPageItemsByCondition(condition string, pars []interface{}, fieldArr []string, orderRule string, startSize, pageSize int) (items []*FeCalendarMatter, err error) {
  93. fields := strings.Join(fieldArr, ",")
  94. if len(fieldArr) == 0 {
  95. fields = `*`
  96. }
  97. order := fmt.Sprintf(`ORDER BY %s DESC`, FeCalendarMatterCols.CreateTime)
  98. if orderRule != "" {
  99. order = ` ORDER BY ` + orderRule
  100. }
  101. sql := fmt.Sprintf(`SELECT %s FROM %s WHERE 1=1 %s %s LIMIT ?,?`, fields, m.TableName(), condition, order)
  102. pars = append(pars, startSize, pageSize)
  103. err = global.DmSQL["data"].Raw(sql, pars...).Find(&items).Error
  104. return
  105. }