chart_theme.go 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. package models
  2. import (
  3. "github.com/beego/beego/v2/client/orm"
  4. "time"
  5. )
  6. // ChartTheme
  7. // @Description: 图表主题表
  8. type ChartTheme struct {
  9. ChartThemeId int `description:"图表主题类型ID" orm:"column(chart_theme_id);pk"`
  10. ChartThemeName string `description:"图表主题名称"`
  11. ChartThemeTypeId int `description:"图表主题类型ID"`
  12. ChartImage string `description:"缩略图"`
  13. Config string `description:"配置"`
  14. IsDelete int `description:"是否删除,0:未删除;1:已删除"`
  15. SysUserId int `description:"操作人"`
  16. SysUserRealName string `description:"操作人的真实名称"`
  17. IsSystemTheme int `description:"是否是系统主题,0:不是;1:是"`
  18. ModifyTime time.Time `description:"修改时间"`
  19. CreateTime time.Time `description:"创建时间"`
  20. BusinessCode string `description:"商家编码"`
  21. }
  22. // GetChartThemeId
  23. // @Description: 根据id获取主题
  24. // @author: Roc
  25. // @datetime 2023-12-14 16:05:36
  26. // @param chartThemeId int
  27. // @return item *ChartTheme
  28. // @return err error
  29. func GetChartThemeId(chartThemeId int) (item *ChartTheme, err error) {
  30. o := orm.NewOrm()
  31. sql := `SELECT * FROM chart_theme where chart_theme_id = ? AND is_delete = 0`
  32. err = o.Raw(sql, chartThemeId).QueryRow(&item)
  33. return
  34. }
  35. // Add
  36. // @Description: 添加
  37. // @author: Roc
  38. // @receiver m
  39. // @datetime 2023-12-14 16:11:10
  40. // @param cols []string
  41. // @return err error
  42. func (m *ChartTheme) Add() (err error) {
  43. o := orm.NewOrm()
  44. lastId, err := o.Insert(m)
  45. if err != nil {
  46. return
  47. }
  48. m.ChartThemeId = int(lastId)
  49. return
  50. }
  51. // Update
  52. // @Description: 更新
  53. // @author: Roc
  54. // @receiver m
  55. // @datetime 2023-12-14 16:11:10
  56. // @param cols []string
  57. // @return err error
  58. func (m *ChartTheme) Update(cols []string) (err error) {
  59. o := orm.NewOrm()
  60. _, err = o.Update(m, cols...)
  61. return
  62. }
  63. // GetChartThemeListByTypeId
  64. // @Description: 根据图表类型获取关联的图表主题列表
  65. // @author: Roc
  66. // @datetime 2023-12-13 17:39:48
  67. // @return list []*ChartTheme
  68. // @return err error
  69. func GetChartThemeListByTypeId(chartThemeTypeId int) (list []*ChartTheme, err error) {
  70. o := orm.NewOrm()
  71. sql := `SELECT * FROM chart_theme WHERE chart_theme_type_id = ? AND is_delete=0 ORDER BY chart_theme_id ASC `
  72. _, err = o.Raw(sql, chartThemeTypeId).QueryRows(&list)
  73. return
  74. }
  75. // GetAllChartThemeList
  76. // @Description: 获取所有图表主题列表
  77. // @author: Roc
  78. // @datetime 2023-12-13 17:39:48
  79. // @return list []*ChartTheme
  80. // @return err error
  81. func GetAllChartThemeList() (list []*ChartTheme, err error) {
  82. o := orm.NewOrm()
  83. sql := `SELECT * FROM chart_theme WHERE is_delete=0 ORDER BY chart_theme_id ASC `
  84. _, err = o.Raw(sql).QueryRows(&list)
  85. return
  86. }
  87. // ChartThemeItem
  88. // @Description: 图表主题配置
  89. type ChartThemeItem struct {
  90. ChartThemeId int `description:"图表主题类型ID" orm:"column(chart_theme_id);pk"`
  91. ChartThemeName string `description:"图表主题名称"`
  92. ChartThemeTypeId int `description:"图表主题类型ID"`
  93. Config string `description:"配置"`
  94. ChartImage string `description:"缩略图"`
  95. //IsDelete int `description:"是否删除,0:未删除;1:已删除"`
  96. IsSystemTheme int `description:"是否是系统主题,0:不是;1:是"`
  97. SysUserId int `description:"操作人"`
  98. SysUserRealName string `description:"操作人的真实名称"`
  99. ModifyTime time.Time `description:"修改时间"`
  100. CreateTime time.Time `description:"创建时间"`
  101. DefaultChartThemeId int `description:"默认使用的图表主题ID"`
  102. }
  103. // GetChartThemeItemList
  104. // @Description: 根据图表类型id获取配置列表
  105. // @author: Roc
  106. // @datetime 2023-12-14 14:26:35
  107. // @param chartThemeTypeId int
  108. // @return list []*ChartThemeConfig
  109. // @return err error
  110. func GetChartThemeItemList(chartThemeTypeId int) (list []*ChartThemeItem, err error) {
  111. o := orm.NewOrm()
  112. sql := `SELECT a.*,b.default_chart_theme_id FROM chart_theme a
  113. JOIN chart_theme_type b on a.chart_theme_type_id =b.chart_theme_type_id
  114. WHERE a.chart_theme_type_id = ? AND a.is_delete=0 ORDER BY a.chart_theme_id ASC `
  115. _, err = o.Raw(sql, chartThemeTypeId).QueryRows(&list)
  116. return
  117. }
  118. // GetSystemChartTheme
  119. // @Description: 根据图表类型id获取系统配置
  120. // @author: Roc
  121. // @datetime 2023-12-14 14:26:35
  122. // @param chartThemeTypeId int
  123. // @return item *ChartTheme
  124. // @return err error
  125. func GetSystemChartTheme(chartThemeTypeId int) (item *ChartTheme, err error) {
  126. o := orm.NewOrm()
  127. sql := `SELECT a.* FROM chart_theme a
  128. WHERE a.chart_theme_type_id = ? AND a.is_system_theme=1 ORDER BY a.chart_theme_id ASC `
  129. err = o.Raw(sql, chartThemeTypeId).QueryRow(&item)
  130. return
  131. }