分销商城(微商城)接口项目

qiniiu_api_controller.go 647B

123456789101112131415161718192021222324252627282930313233343536
  1. package controllers
  2. import (
  3. "XT/enums"
  4. "XT/service"
  5. "fmt"
  6. "github.com/astaxie/beego"
  7. )
  8. type QiNiuApiController struct {
  9. BaseAPIController
  10. // beego.Controller
  11. }
  12. func QiniuApiRegistRouters() {
  13. beego.Router("/api/qiniu/uptoken", &QiNiuApiController{}, "get:GetQNUpToken")
  14. }
  15. func (c *QiNiuApiController) GetQNUpToken() {
  16. redisClient := service.RedisClient()
  17. defer redisClient.Close()
  18. token, err := redisClient.Get("qn_token").Result()
  19. if err != nil {
  20. defer fmt.Println(err)
  21. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGetQiniuUpToken)
  22. return
  23. }
  24. c.ServeSuccessJSON(map[string]interface{}{
  25. "uptoken": token,
  26. })
  27. return
  28. }