123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687 |
- package controllers
- import (
- "encoding/json"
- "eta/eta_forum_hub/models"
- "eta/eta_forum_hub/services"
- )
- // ChartThemeController
- // @Description: 图表主题配置模块
- type ChartThemeController struct {
- BaseAuthController
- }
- // Save
- // @Title 新增或编辑主题
- // @Description
- // @Param request body request.DeleteThemeConfReq true "type json string"
- // @Success 200 Ret=200 添加成功
- // @router /theme/save [post]
- func (c *ChartThemeController) Save() {
- br := new(models.BaseResponse).Init()
- defer func() {
- c.Data["json"] = br
- c.ServeJSON()
- }()
- var req models.ChartTheme
- err := json.Unmarshal(c.Ctx.Input.RequestBody, &req)
- if err != nil {
- br.Msg = "参数解析异常!"
- br.ErrMsg = "参数解析失败,Err:" + err.Error()
- return
- }
- if req.ChartThemeTypeId <= 0 {
- br.Msg = "请选择图表类型"
- br.IsSendEmail = false
- return
- }
- // 添加入库
- err = services.AddOrUpdateChartTheme(req)
- if err != nil {
- br.Msg = "添加失败"
- br.ErrMsg = "添加失败,Err:" + err.Error()
- return
- }
- br.Ret = 200
- br.Success = true
- br.Msg = "添加成功"
- }
- // ThemeTypeSave
- // @Title 新增或编辑主题类型
- // @Description
- // @Param request body request.DeleteThemeConfReq true "type json string"
- // @Success 200 Ret=200 添加成功
- // @router /theme/type/save [post]
- func (c *ChartThemeController) ThemeTypeSave() {
- br := new(models.BaseResponse).Init()
- defer func() {
- c.Data["json"] = br
- c.ServeJSON()
- }()
- var req models.ChartThemeType
- err := json.Unmarshal(c.Ctx.Input.RequestBody, &req)
- if err != nil {
- br.Msg = "参数解析异常!"
- br.ErrMsg = "参数解析失败,Err:" + err.Error()
- return
- }
- // 添加入库
- err = services.AddOrUpdateChartThemeType(req)
- if err != nil {
- br.Msg = "添加失败"
- br.ErrMsg = "添加失败,Err:" + err.Error()
- return
- }
- br.Ret = 200
- br.Success = true
- br.Msg = "添加成功"
- }
|