ct int64로 변경

This commit is contained in:
2025-08-19 08:23:07 +09:00
parent 887a28aef5
commit 8e691a4174

View File

@ -6,6 +6,7 @@ import (
"encoding/hex" "encoding/hex"
"errors" "errors"
"math/rand" "math/rand"
"strconv"
"strings" "strings"
"time" "time"
@ -17,21 +18,20 @@ type Authorization struct {
invalidated string invalidated string
// by authorization provider // by authorization provider
Platform string `bson:"p" json:"p"` Platform string `bson:"p" json:"p"`
Uid string `bson:"u" json:"u"` Uid string `bson:"u" json:"u"`
Alias string `bson:"al" json:"al"` Alias string `bson:"al" json:"al"`
CreatedTime primitive.DateTime `bson:"ct" json:"ct"` CreatedTime int64 `bson:"ct" json:"ct"`
} }
func (auth *Authorization) ToStrings() []string { func (auth *Authorization) ToStrings() []string {
ct, _ := auth.CreatedTime.MarshalJSON()
return []string{ return []string{
"a", auth.Account.Hex(), "a", auth.Account.Hex(),
"p", auth.Platform, "p", auth.Platform,
"u", auth.Uid, "u", auth.Uid,
"al", auth.Alias, "al", auth.Alias,
"inv", auth.invalidated, "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 { func MakeAuthrizationFromStringMap(src map[string]string) Authorization {
accid, _ := primitive.ObjectIDFromHex(src["a"]) accid, _ := primitive.ObjectIDFromHex(src["a"])
var datetime primitive.DateTime ct, _ := strconv.ParseInt(src["ct"], 10, 0)
datetime.UnmarshalJSON([]byte(src["ct"]))
return Authorization{ return Authorization{
Account: accid, Account: accid,
Platform: src["p"], Platform: src["p"],
Uid: src["u"], Uid: src["u"],
Alias: src["al"], Alias: src["al"],
invalidated: src["inv"], invalidated: src["inv"],
CreatedTime: datetime, CreatedTime: ct,
} }
} }