qiniiu_api_controller.go 720B

12345678910111213141516171819202122232425262728293031323334353637
  1. package controllers
  2. import (
  3. "Xcx_New/enums"
  4. "Xcx_New/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. fmt.Print("token------------------------------------", token)
  20. if err != nil {
  21. defer fmt.Println(err)
  22. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGetQiniuUpToken)
  23. return
  24. }
  25. c.ServeSuccessJSON(map[string]interface{}{
  26. "uptoken": token,
  27. })
  28. return
  29. }