shaoyongjun 6e10b20670 to:sync
2024-10-03 01:09:14 +08:00

52 lines
1.0 KiB
Go

package dto
import (
"github.com/golang-jwt/jwt/v5"
"time"
)
type UserVO struct {
Sn string `json:"sn"`
Token string `json:"token"`
Platform string `json:"platform"`
Account *string `json:"Account"`
Nickname *string `json:"nickname"`
Avatar *string `json:"avatar"`
}
type LoginTokenVo struct {
jwt.RegisteredClaims
Sn string `json:"sn"`
AccessToken string `json:"accessToken"`
Platform string `json:"platform"`
}
func (vo *LoginTokenVo) SetExtByPlatform(platform string) *LoginTokenVo {
switch platform {
case "web":
{
vo.Platform = "web"
vo.ExpiresAt = jwt.NewNumericDate(time.Now().Add(time.Hour * 24 * 7))
}
case "android":
{
vo.Platform = "android"
vo.ExpiresAt = jwt.NewNumericDate(time.Now().Add(time.Hour * 24 * 30))
}
case "ios":
{
vo.Platform = "ios"
vo.ExpiresAt = jwt.NewNumericDate(time.Now().Add(time.Hour * 24 * 30))
}
default:
{
vo.Platform = "web"
vo.ExpiresAt = jwt.NewNumericDate(time.Now().Add(time.Hour * 7 * 30))
}
}
return vo
}