scrm-go

qiniu_controller.go 681B

123456789101112131415161718192021222324252627282930313233343536
  1. package global
  2. import (
  3. base_ctl "SCRM/controllers"
  4. "SCRM/enums"
  5. base_service "SCRM/service"
  6. "fmt"
  7. "github.com/astaxie/beego"
  8. )
  9. type QiNiuApiController struct {
  10. base_ctl.BaseAPIController
  11. }
  12. func QiniuCtlRegistRouters() {
  13. beego.Router("/api/qiniu/uptoken", &QiNiuApiController{}, "get:GetQNUpToken")
  14. }
  15. func (c *QiNiuApiController) GetQNUpToken() {
  16. redisClient := base_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. }