push.go 898 B

1234567891011121314151617181920212223242526272829303132
  1. package api
  2. import (
  3. "crazy-fox-backend-api/model"
  4. "crazy-fox-backend-api/service"
  5. "crazy-fox-backend-api/utils"
  6. "crazy-fox-backend-api/utils/answer"
  7. "github.com/gin-gonic/gin"
  8. )
  9. // pushApi 推送配置
  10. type pushApi struct{}
  11. func (Api *pushApi) Config(c *gin.Context) {
  12. pushShowConfig := model.PushShowConfig{
  13. List: service.Push.PushConfig(),
  14. LangList: service.Push.PushLangConfig(),
  15. }
  16. answer.OkWithDetailed(pushShowConfig, "获取成功", c)
  17. }
  18. func (Api *pushApi) SaveContent(c *gin.Context) {
  19. var pushConf model.PushRepoConfig
  20. if err := c.ShouldBindWith(&pushConf, utils.HandleBinding(c.Request.Method, c.ContentType())); err != nil {
  21. answer.FailWithMessage("请求参数结构体接收失败", err, c)
  22. }
  23. if err := service.Push.SaveConfig(pushConf); err != nil {
  24. answer.FailWithMessage("保存失败", err, c)
  25. }
  26. answer.OkWithDetailed(pushConf, "保存成功", c)
  27. }