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

31 lines
692 B
Go
Raw Permalink Normal View History

2022-01-25 17:03:14 +08:00
package model
import (
"context"
"git.icechen.cn/monorepo/backend/pkg/orm"
"time"
)
type Token struct {
Tokenid string `json:"tokenid" gorm:"column:tokenid"` // token 唯一id
OpenID string `json:"openId" gorm:"column:openId"`
TypeID string `json:"typeId" gorm:"column:typeId"`
ExpireTime time.Time `json:"expire_time" gorm:"column:expire_time"`
Level int `json:"level" gorm:"column:level"`
}
func (m *Token) TableName() string {
return "token"
}
func NewToken(ctx context.Context, token *Token) error {
db, err := orm.GetContextDB(ctx)
if err != nil {
return err
}
if err = db.Create(token).Error; err != nil {
return err
}
return nil
}