session.go 423 B

1234567891011121314151617181920212223242526272829303132
  1. /*
  2. @Time : 2019-07-12 16:24
  3. @Author : zr
  4. */
  5. package model
  6. import (
  7. model2 "github.com/ZR233/session/model"
  8. "strconv"
  9. "time"
  10. )
  11. type Session struct {
  12. Token string
  13. UserId int
  14. Channel string
  15. ExpireAt time.Time
  16. }
  17. func NewSession(s *model2.Session) *Session {
  18. userId, err := strconv.Atoi(s.UserId)
  19. if err != nil {
  20. panic(err)
  21. }
  22. s_ := &Session{
  23. s.Token,
  24. userId,
  25. s.Channel,
  26. s.ExpireAt,
  27. }
  28. return s_
  29. }