31 lines
636 B
Go
31 lines
636 B
Go
package service
|
|
|
|
import (
|
|
"Edu/utils"
|
|
"encoding/json"
|
|
)
|
|
|
|
type Session struct {
|
|
ID uint64 `json:"id"` // 用户ID
|
|
OpenID string `json:"open_id"`
|
|
Token string `json:"token"` // token
|
|
Name string `json:"name"` // 名称
|
|
SessionKey string `json:"session_key"` // 用户信息
|
|
}
|
|
|
|
func (this *Session) MarshalBinary() ([]byte, error) {
|
|
return json.Marshal(this)
|
|
}
|
|
|
|
func (this *Session) UnmarshalBinary(data []byte) error {
|
|
return utils.FromJSONBytes(data, this)
|
|
}
|
|
|
|
func (this *Session) IDToString() string {
|
|
return utils.UintToString(this.ID)
|
|
}
|
|
|
|
func NewSession() *Session {
|
|
return &Session{}
|
|
}
|