backend/app/brahma/api/murder/internal/service/token.go

27 lines
441 B
Go
Raw Permalink Normal View History

2022-01-25 17:03:14 +08:00
package service
import (
"context"
"git.icechen.cn/monorepo/backend/app/brahma/api/murder/internal/model"
"time"
)
func generateToken(ctx context.Context, user *model.User) error {
m := new(model.Token)
m.OpenID = user.Openid
m.TypeID = user.Typeid
m.Level = 1
if user.AvatarUrl == "" {
m.Level = 0
}
m.ExpireTime = time.Now().Add(8 * time.Hour)
err := model.NewToken(ctx, m)
if err != nil {
return err
}
return nil
}