generated from pkg/go-template
31 lines
692 B
Go
31 lines
692 B
Go
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
|
|
}
|