ct int64로 변경
This commit is contained in:
@ -6,6 +6,7 @@ import (
|
||||
"encoding/hex"
|
||||
"errors"
|
||||
"math/rand"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
@ -20,18 +21,17 @@ type Authorization struct {
|
||||
Platform string `bson:"p" json:"p"`
|
||||
Uid string `bson:"u" json:"u"`
|
||||
Alias string `bson:"al" json:"al"`
|
||||
CreatedTime primitive.DateTime `bson:"ct" json:"ct"`
|
||||
CreatedTime int64 `bson:"ct" json:"ct"`
|
||||
}
|
||||
|
||||
func (auth *Authorization) ToStrings() []string {
|
||||
ct, _ := auth.CreatedTime.MarshalJSON()
|
||||
return []string{
|
||||
"a", auth.Account.Hex(),
|
||||
"p", auth.Platform,
|
||||
"u", auth.Uid,
|
||||
"al", auth.Alias,
|
||||
"inv", auth.invalidated,
|
||||
"ct", string(ct),
|
||||
"ct", strconv.FormatInt(auth.CreatedTime, 10),
|
||||
}
|
||||
}
|
||||
|
||||
@ -41,15 +41,14 @@ func (auth *Authorization) Valid() bool {
|
||||
|
||||
func MakeAuthrizationFromStringMap(src map[string]string) Authorization {
|
||||
accid, _ := primitive.ObjectIDFromHex(src["a"])
|
||||
var datetime primitive.DateTime
|
||||
datetime.UnmarshalJSON([]byte(src["ct"]))
|
||||
ct, _ := strconv.ParseInt(src["ct"], 10, 0)
|
||||
return Authorization{
|
||||
Account: accid,
|
||||
Platform: src["p"],
|
||||
Uid: src["u"],
|
||||
Alias: src["al"],
|
||||
invalidated: src["inv"],
|
||||
CreatedTime: datetime,
|
||||
CreatedTime: ct,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user