authserver.go 474 B

12345678910111213141516171819202122232425262728
  1. package server
  2. import (
  3. "fmt"
  4. "net/http"
  5. "strconv"
  6. "time"
  7. )
  8. type AuthServer struct {
  9. }
  10. func NewAuthLogic() *AuthServer {
  11. return &AuthServer{}
  12. }
  13. func (l *AuthServer) GetChatUserId(r *http.Request) int64 {
  14. query := r.URL.Query()
  15. if query != nil && query["userId"] != nil {
  16. var uid = fmt.Sprintf("%v", query["userId"])
  17. atoi, err := strconv.Atoi(uid)
  18. if err != nil {
  19. return time.Now().UnixMilli()
  20. }
  21. return int64(atoi)
  22. }
  23. return time.Now().UnixMilli()
  24. }