123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109 |
- package services
- import (
- "eta/eta_forum_hub/models"
- "eta/eta_forum_hub/utils"
- "fmt"
- "time"
- )
- func AddOrUpdateChartTheme(req models.ChartTheme) (err error) {
- // 查询主题信息是否存在
- chartTheme := new(models.ChartTheme)
- if req.ChartThemeId > 0 {
- var e error
- chartTheme, e = models.GetChartThemeId(req.ChartThemeId)
- if e != nil && e.Error() != utils.ErrNoRow() {
- err = fmt.Errorf("查询主题信息失败 %v", e)
- return
- }
- if e == nil {
- if chartTheme.BusinessCode != chartTheme.BusinessCode {
- err = fmt.Errorf("更新主题信息失败")
- }
- chartTheme.ChartThemeName = req.ChartThemeName
- chartTheme.ChartThemeTypeId = req.ChartThemeTypeId
- chartTheme.Config = req.Config
- chartTheme.ChartImage = req.ChartImage
- chartTheme.IsDelete = req.IsDelete
- chartTheme.SysUserId = req.SysUserId
- chartTheme.SysUserRealName = req.SysUserRealName
- chartTheme.ModifyTime = time.Now()
- // 添加入库
- err = chartTheme.Update([]string{})
- if err != nil {
- err = fmt.Errorf("添加或更新图表主题失败,%v", err)
- return
- }
- return
- }
- }
- chartTheme = &models.ChartTheme{
- ChartThemeId: req.ChartThemeId,
- ChartThemeName: req.ChartThemeName,
- ChartThemeTypeId: req.ChartThemeTypeId,
- Config: req.Config,
- ChartImage: req.ChartImage,
- IsDelete: req.IsDelete,
- SysUserId: req.SysUserId,
- SysUserRealName: req.SysUserRealName,
- ModifyTime: time.Now(),
- CreateTime: time.Now(),
- BusinessCode: req.BusinessCode,
- }
- // 添加入库
- err = chartTheme.Add()
- if err != nil {
- err = fmt.Errorf("添加或更新图表主题失败,%v", err)
- return
- }
- return
- }
- func AddOrUpdateChartThemeType(req models.ChartThemeType) (err error) {
- // 查询主题信息是否存在
- chartThemeType := new(models.ChartThemeType)
- if req.ChartThemeTypeId > 0 {
- var e error
- chartThemeType, e = models.GetChartThemeTypeById(req.ChartThemeTypeId)
- if e != nil && e.Error() != utils.ErrNoRow() {
- err = fmt.Errorf("查询主题信息失败 %v", e)
- return
- }
- if e == nil {
- // 添加入库
- chartThemeType.ChartTypeName = req.ChartTypeName
- chartThemeType.ChartType = req.ChartType
- chartThemeType.DefaultChartThemeId = req.DefaultChartThemeId
- chartThemeType.ChartSource = req.ChartSource
- chartThemeType.ModifyTime = time.Now()
- err = chartThemeType.Update([]string{})
- if err != nil {
- err = fmt.Errorf("添加或更新图表主题失败,%v", err)
- return
- }
- return
- }
- }
- chartThemeType = &models.ChartThemeType{
- ChartTypeName: req.ChartTypeName,
- ChartType: req.ChartType,
- ChartSource: req.ChartSource,
- DefaultChartThemeId: req.DefaultChartThemeId,
- ModifyTime: time.Now(),
- CreateTime: time.Now(),
- }
- // 添加入库
- err = chartThemeType.Add()
- if err != nil {
- err = fmt.Errorf("添加或更新图表主题失败,%v", err)
- return
- }
- return
- }
|