chart.go 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. package controllers
  2. import (
  3. "encoding/json"
  4. "hongze/hongze_open_api/models/request/chart"
  5. celuePushTable "hongze/hongze_open_api/models/tables/cygx/cygx_chart"
  6. "hongze/hongze_open_api/utils"
  7. "time"
  8. )
  9. // 图表模块
  10. type ChartController struct {
  11. BaseAuth
  12. }
  13. // ChartChange
  14. // @Title 图表变更通知的插入点接口
  15. // @Description 图表变更通知的插入点接口
  16. // @Param request body chart.CreatChartCeluePushReq true "type json string"
  17. // @Success 200 创建成功
  18. // @router /change [post]
  19. func (c *ChartController) ChartChange() {
  20. var req chart.CreatChartCeluePushReq
  21. err := json.Unmarshal(c.Ctx.Input.RequestBody, &req)
  22. if err != nil {
  23. c.FailWithMessage("参数解析异常")
  24. return
  25. }
  26. //appid权限校验
  27. appid := req.Appid
  28. if utils.RunMode == "release" && appid != utils.CLPT_APPID {
  29. c.FailWithMessage("无权限")
  30. return
  31. }
  32. chartId := req.ChartId
  33. action := req.Action
  34. if chartId < 0 {
  35. c.FailWithMessage("缺少 chart_id 参数")
  36. return
  37. }
  38. if action != "add" && action != "edit" && action != "move" {
  39. c.FailWithMessage("action参数类型错误")
  40. return
  41. }
  42. item := new(celuePushTable.CygxChartCeluePush)
  43. item.ChartId = chartId
  44. item.Action = action
  45. item.CreateTime = time.Now()
  46. item.ModifyTime = time.Now()
  47. err = celuePushTable.AddCygxChartCeluePush(item)
  48. if err != nil {
  49. c.OkWithMessage("创建失败")
  50. return
  51. }
  52. c.OkWithMessage("创建成功")
  53. }