getConfig.go 478 B

12345678910111213141516171819202122232425262728
  1. package controller
  2. import (
  3. "github.com/gin-gonic/gin"
  4. "base-gin/service"
  5. "base-gin/utils/base"
  6. )
  7. type ConfigParam struct {
  8. Key string `form:"key" binding:"required"`
  9. }
  10. func GetConfig(c *gin.Context) {
  11. var input ConfigParam
  12. if err := c.ShouldBind(&input); err != nil {
  13. base.RenderJsonFail(c, err)
  14. return
  15. }
  16. ret, err := service.GetConfig(c, input.Key)
  17. if err != nil {
  18. base.RenderJsonFail(c, err)
  19. return
  20. }
  21. base.RenderJsonSucc(c, gin.H{"detail": ret})
  22. }