init
This commit is contained in:
30
app/service/session.go
Normal file
30
app/service/session.go
Normal file
@ -0,0 +1,30 @@
|
||||
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{}
|
||||
}
|
Reference in New Issue
Block a user