model.go 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. package fe_calendar_matter
  2. import (
  3. "fmt"
  4. "hongze/hongze_yb/global"
  5. "hongze/hongze_yb/utils"
  6. )
  7. type FeCalendarMatterItem struct {
  8. FeCalendarMatterId int `description:"事项ID" json:"fe_calendar_matter_id"`
  9. ChartPermissionId int `description:"品种ID" json:"chart_permission_id"`
  10. ChartPermissionName string `description:"品种名称" json:"chart_permission_name"`
  11. MatterDate string `description:"事项日期" json:"matter_date"`
  12. Title string `description:"标题" json:"title"`
  13. MatterType int `description:"事项类型:1-自定义事项;2-基础指标;3-预测指标" json:"matter_type"`
  14. EdbInfoId int `description:"指标ID" json:"edb_info_id"`
  15. EdbUniqueCode string `description:"指标唯一编码" json:"edb_unique_code"`
  16. EdbCode string `description:"指标编码" json:"edb_code"`
  17. FontColor string `description:"字体颜色" json:"font_color"`
  18. FillingColor string `description:"填充颜色" json:"filling_color"`
  19. FontBold int `description:"字体加粗:0-否;1-是" json:"font_bold"`
  20. Sort int `description:"排序" json:"sort"`
  21. }
  22. func FormatFeCalendarMatter2Item(origin *FeCalendarMatter) (item *FeCalendarMatterItem) {
  23. if origin == nil {
  24. return
  25. }
  26. item = new(FeCalendarMatterItem)
  27. item.FeCalendarMatterId = origin.FeCalendarMatterId
  28. item.ChartPermissionId = origin.ChartPermissionId
  29. item.ChartPermissionName = origin.ChartPermissionName
  30. item.MatterDate = utils.TimeTransferString(utils.FormatDate, origin.MatterDate)
  31. item.Title = origin.Title
  32. item.MatterType = origin.MatterType
  33. item.EdbInfoId = origin.EdbInfoId
  34. item.EdbUniqueCode = origin.EdbUniqueCode
  35. item.EdbCode = origin.EdbCode
  36. item.FontColor = origin.FontColor
  37. item.FillingColor = origin.FillingColor
  38. item.FontBold = origin.FontBold
  39. item.Sort = origin.Sort
  40. return
  41. }
  42. // FeCalendarMatterListItem 事项列表
  43. type FeCalendarMatterListItem struct {
  44. Date string `description:"日期" json:"date"`
  45. Matters []*FeCalendarMatterItem `description:"日期事项" json:"matters"`
  46. }
  47. func (m *FeCalendarMatter) GetItemByCondition(cond string, pars []interface{}) (item *FeCalendarMatter, err error) {
  48. err = global.MYSQL["data"].Where(cond, pars...).First(&item).Error
  49. return
  50. }
  51. func (m *FeCalendarMatter) GetItemsByCondition(cond string, pars []interface{}, fieldArr []string, orderRule string) (items []*FeCalendarMatter, err error) {
  52. order := fmt.Sprintf(`%s DESC`, FeCalendarMatterColumns.CreateTime)
  53. if orderRule != "" {
  54. order = orderRule
  55. }
  56. err = global.MYSQL["data"].Where(cond, pars...).Order(order).Find(&items).Error
  57. return
  58. }
  59. func (m *FeCalendarMatter) GetLastestMonthItemByPermissionId(permissionId int) (item *FeCalendarMatter, err error) {
  60. err = global.MYSQL["data"].Where("chart_permission_id = ?", permissionId).Order("matter_date DESC").First(&item).Error
  61. return
  62. }