program.go 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. package devices
  2. import (
  3. "github.com/gin-gonic/gin"
  4. "go.uber.org/zap"
  5. "server/global"
  6. "server/model/common/response"
  7. "server/model/devices"
  8. )
  9. type ProgramApi struct{}
  10. func (pa *ProgramApi) CreateProgram(c *gin.Context) {
  11. var info devices.ProgramReq
  12. if err := c.ShouldBindJSON(&info); err != nil {
  13. global.GVA_LOG.Error("CreateProgram === ", zap.Error(err))
  14. response.FailWithMessage("参数错误", c)
  15. return
  16. }
  17. err := programService.CreateProgram(info)
  18. if err != nil {
  19. global.GVA_LOG.Error("CreateProgram === ", zap.Error(err))
  20. response.FailWithMessage("新增失败", c)
  21. return
  22. }
  23. response.Ok(c)
  24. }
  25. func (pa *ProgramApi) UpdateProgram(c *gin.Context) {
  26. var info devices.ProgramReq
  27. if err := c.ShouldBindJSON(&info); err != nil {
  28. global.GVA_LOG.Error("UpdateProgram === ", zap.Error(err))
  29. response.FailWithMessage("参数错误", c)
  30. return
  31. }
  32. err := programService.UpdateProgram(info)
  33. if err != nil {
  34. global.GVA_LOG.Error("UpdateProgram === ", zap.Error(err))
  35. response.FailWithMessage("更新失败", c)
  36. return
  37. }
  38. response.Ok(c)
  39. }