util.go 708 B

1234567891011121314151617181920212223242526
  1. package util
  2. import (
  3. "bp.jydev.jianyu360.cn/SocialPlatform/messageCenter/entity"
  4. "fmt"
  5. "github.com/zeromicro/go-zero/core/logx"
  6. "net/http"
  7. )
  8. func GetTouristCookieInfo(r *http.Request) (sessionId, trustedId string, err error) {
  9. cn, ce := r.Cookie(entity.CookieName)
  10. ti, te := r.Cookie(entity.JYTrustedId)
  11. if ce != nil || cn == nil || cn.Value == "" { //session
  12. err = fmt.Errorf("当用户信息有误")
  13. logx.Error("当前用户没有session信息")
  14. return
  15. }
  16. if te != nil || ti == nil || ti.Value == "" { //不存在信用标识
  17. err = fmt.Errorf("当用户信息有误")
  18. logx.Error("当前用户没有JYTrustedIdn信息")
  19. return
  20. }
  21. sessionId = cn.Value
  22. trustedId = ti.Value
  23. return
  24. }