123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112 |
- package chart_theme
- import (
- "errors"
- "eta_gn/eta_api/global"
- "time"
- )
- // ChartTheme
- // @Description: 图表主题表
- type ChartTheme struct {
- ChartThemeId int `description:"图表主题类型ID" orm:"column(chart_theme_id);pk" gorm:"primaryKey" `
- ChartThemeName string `description:"图表主题名称"`
- ChartThemeTypeId int `description:"图表主题类型ID"`
- ChartImage string `description:"缩略图"`
- Config string `description:"配置"`
- IsDelete int `description:"是否删除,0:未删除;1:已删除"`
- SysUserId int `description:"操作人"`
- SysUserRealName string `description:"操作人的真实名称"`
- IsSystemTheme int `description:"是否是系统主题,0:不是;1:是"`
- ModifyTime time.Time `description:"修改时间"`
- CreateTime time.Time `description:"创建时间"`
- }
- // GetChartThemeId
- // @Description: 根据id获取主题
- // @author: Roc
- // @datetime 2023-12-14 16:05:36
- // @param chartThemeId int
- // @return item *ChartTheme
- // @return err error
- func GetChartThemeId(chartThemeId int) (item *ChartTheme, err error) {
- sql := `SELECT * FROM chart_theme where chart_theme_id = ? AND is_delete = 0`
- err = global.DmSQL["data"].Raw(sql, chartThemeId).First(&item).Error
- return
- return
- }
- // Add
- // @Description: 添加
- // @author: Roc
- // @receiver m
- // @datetime 2023-12-14 16:11:10
- // @param cols []string
- // @return err error
- func (m *ChartTheme) Add() (err error) {
- if m.ChartThemeId > 0 {
- err = errors.New("该配置已存在")
- return
- }
- err = global.DmSQL["data"].Create(m).Error
- return
- }
- // Update
- // @Description: 更新
- // @author: Roc
- // @receiver m
- // @datetime 2023-12-14 16:11:10
- // @param cols []string
- // @return err error
- func (m *ChartTheme) Update(cols []string) (err error) {
- err = global.DmSQL["data"].Select(cols).Updates(m).Error
- return
- }
- // ChartThemeItem
- // @Description: 图表主题配置
- type ChartThemeItem struct {
- ChartThemeId int `description:"图表主题类型ID" orm:"column(chart_theme_id);pk" gorm:"primaryKey" `
- ChartThemeName string `description:"图表主题名称"`
- ChartThemeTypeId int `description:"图表主题类型ID"`
- Config string `description:"配置"`
- ChartImage string `description:"缩略图"`
- IsSystemTheme int `description:"是否是系统主题,0:不是;1:是"`
- SysUserId int `description:"操作人"`
- SysUserRealName string `description:"操作人的真实名称"`
- ModifyTime time.Time `description:"修改时间"`
- CreateTime time.Time `description:"创建时间"`
- DefaultChartThemeId int `description:"默认使用的图表主题ID"`
- }
- // GetChartThemeItemList
- // @Description: 根据图表类型id获取配置列表
- // @author: Roc
- // @datetime 2023-12-14 14:26:35
- // @param chartThemeTypeId int
- // @return list []*ChartThemeConfig
- // @return err error
- func GetChartThemeItemList(chartThemeTypeId int) (list []*ChartThemeItem, err error) {
- sql := `SELECT a.*,b.default_chart_theme_id FROM chart_theme a
- JOIN chart_theme_type b on a.chart_theme_type_id =b.chart_theme_type_id
- WHERE a.chart_theme_type_id = ? AND a.is_delete=0 ORDER BY a.chart_theme_id ASC `
- err = global.DmSQL["data"].Raw(sql, chartThemeTypeId).Find(&list).Error
- return
- }
- // GetSystemChartTheme
- // @Description: 根据图表类型id获取系统配置
- // @author: Roc
- // @datetime 2023-12-14 14:26:35
- // @param chartThemeTypeId int
- // @return item *ChartTheme
- // @return err error
- func GetSystemChartTheme(chartThemeTypeId int) (item *ChartTheme, err error) {
- sql := `SELECT a.* FROM chart_theme a
- WHERE a.chart_theme_type_id = ? AND a.is_system_theme=1 ORDER BY a.chart_theme_id ASC `
- err = global.DmSQL["data"].Raw(sql, chartThemeTypeId).First(&item).Error
- return
- }
|