feat(api): standardize timestamp field across log structures

This commit is contained in:
Chang lue Tsen 2025-08-26 14:39:54 -04:00
parent 88cbfbb7d6
commit 82fd674ae4
23 changed files with 78 additions and 78 deletions

View File

@ -41,7 +41,7 @@ type (
UserAgent string `json:"user_agent"` UserAgent string `json:"user_agent"`
ClientIP string `json:"client_ip"` ClientIP string `json:"client_ip"`
UserSubscribeId int64 `json:"user_subscribe_id"` UserSubscribeId int64 `json:"user_subscribe_id"`
SubscribedAt int64 `json:"subscribed_at"` Timestamp int64 `json:"timestamp"`
} }
FilterSubscribeLogRequest { FilterSubscribeLogRequest {
FilterLogParams FilterLogParams
@ -57,7 +57,7 @@ type (
LoginIP string `json:"login_ip"` LoginIP string `json:"login_ip"`
UserAgent string `json:"user_agent"` UserAgent string `json:"user_agent"`
Success bool `json:"success"` Success bool `json:"success"`
LoginTime int64 `json:"login_time"` Timestamp int64 `json:"timestamp"`
} }
FilterLoginLogRequest { FilterLoginLogRequest {
FilterLogParams FilterLogParams
@ -68,12 +68,12 @@ type (
List []LoginLog `json:"list"` List []LoginLog `json:"list"`
} }
RegisterLog { RegisterLog {
UserId int64 `json:"user_id"` UserId int64 `json:"user_id"`
AuthMethod string `json:"auth_method"` AuthMethod string `json:"auth_method"`
Identifier string `json:"identifier"` Identifier string `json:"identifier"`
RegisterIP string `json:"register_ip"` RegisterIP string `json:"register_ip"`
UserAgent string `json:"user_agent"` UserAgent string `json:"user_agent"`
RegisterTime int64 `json:"register_time"` Timestamp int64 `json:"timestamp"`
} }
FilterRegisterLogRequest { FilterRegisterLogRequest {
FilterLogParams FilterLogParams
@ -88,7 +88,7 @@ type (
UserId int64 `json:"user_id"` UserId int64 `json:"user_id"`
UserSubscribeId int64 `json:"user_subscribe_id"` UserSubscribeId int64 `json:"user_subscribe_id"`
OrderNo string `json:"order_no,omitempty"` OrderNo string `json:"order_no,omitempty"`
ResetAt int64 `json:"reset_at"` Timestamp int64 `json:"timestamp"`
} }
FilterResetSubscribeLogRequest { FilterResetSubscribeLogRequest {
FilterLogParams FilterLogParams
@ -156,7 +156,7 @@ type (
Amount int64 `json:"amount"` Amount int64 `json:"amount"`
Balance int64 `json:"balance"` Balance int64 `json:"balance"`
Remark string `json:"remark,omitempty"` Remark string `json:"remark,omitempty"`
CreatedAt int64 `json:"created_at"` Timestamp int64 `json:"timestamp"`
} }
FilterGiftLogRequest { FilterGiftLogRequest {
FilterLogParams FilterLogParams

View File

@ -515,7 +515,7 @@ type (
Token string `json:"token"` Token string `json:"token"`
IP string `json:"ip"` IP string `json:"ip"`
UserAgent string `json:"user_agent"` UserAgent string `json:"user_agent"`
CreatedAt int64 `json:"created_at"` Timestamp int64 `json:"timestamp"`
} }
UserLoginLog { UserLoginLog {
Id int64 `json:"id"` Id int64 `json:"id"`
@ -523,7 +523,7 @@ type (
LoginIP string `json:"login_ip"` LoginIP string `json:"login_ip"`
UserAgent string `json:"user_agent"` UserAgent string `json:"user_agent"`
Success bool `json:"success"` Success bool `json:"success"`
CreatedAt int64 `json:"created_at"` Timestamp int64 `json:"timestamp"`
} }
MessageLog { MessageLog {
Id int64 `json:"id"` Id int64 `json:"id"`
@ -750,7 +750,7 @@ type (
Type uint16 `json:"type"` Type uint16 `json:"type"`
UserSubscribeId int64 `json:"user_subscribe_id"` UserSubscribeId int64 `json:"user_subscribe_id"`
OrderNo string `json:"order_no,omitempty"` OrderNo string `json:"order_no,omitempty"`
ResetAt int64 `json:"reset_at"` Timestamp int64 `json:"timestamp"`
} }
BalanceLog { BalanceLog {
Type uint16 `json:"type"` Type uint16 `json:"type"`
@ -765,7 +765,7 @@ type (
UserId int64 `json:"user_id"` UserId int64 `json:"user_id"`
Amount int64 `json:"amount"` Amount int64 `json:"amount"`
OrderNo string `json:"order_no"` OrderNo string `json:"order_no"`
CreatedAt int64 `json:"created_at"` Timestamp int64 `json:"timestamp"`
} }
) )

View File

@ -51,7 +51,7 @@ func (l *FilterCommissionLogLogic) FilterCommissionLog(req *types.FilterCommissi
Type: content.Type, Type: content.Type,
Amount: content.Amount, Amount: content.Amount,
OrderNo: content.OrderNo, OrderNo: content.OrderNo,
CreatedAt: content.CreatedAt, Timestamp: content.Timestamp,
}) })
} }
return &types.FilterCommissionLogResponse{ return &types.FilterCommissionLogResponse{

View File

@ -57,7 +57,7 @@ func (l *FilterGiftLogLogic) FilterGiftLog(req *types.FilterGiftLogRequest) (res
Amount: content.Amount, Amount: content.Amount,
Balance: content.Balance, Balance: content.Balance,
Remark: content.Remark, Remark: content.Remark,
CreatedAt: content.CreatedAt, Timestamp: content.Timestamp,
}) })
} }

View File

@ -54,7 +54,7 @@ func (l *FilterLoginLogLogic) FilterLoginLog(req *types.FilterLoginLogRequest) (
LoginIP: item.LoginIP, LoginIP: item.LoginIP,
UserAgent: item.UserAgent, UserAgent: item.UserAgent,
Success: item.Success, Success: item.Success,
LoginTime: item.LoginTime, Timestamp: item.Timestamp,
}) })
} }

View File

@ -50,12 +50,12 @@ func (l *FilterRegisterLogLogic) FilterRegisterLog(req *types.FilterRegisterLogR
continue continue
} }
list = append(list, types.RegisterLog{ list = append(list, types.RegisterLog{
UserId: datum.ObjectID, UserId: datum.ObjectID,
AuthMethod: item.AuthMethod, AuthMethod: item.AuthMethod,
Identifier: item.Identifier, Identifier: item.Identifier,
RegisterIP: item.RegisterIP, RegisterIP: item.RegisterIP,
UserAgent: item.UserAgent, UserAgent: item.UserAgent,
RegisterTime: item.RegisterTime, Timestamp: item.Timestamp,
}) })
} }

View File

@ -55,7 +55,7 @@ func (l *FilterResetSubscribeLogLogic) FilterResetSubscribeLog(req *types.Filter
UserId: content.UserId, UserId: content.UserId,
UserSubscribeId: item.ObjectID, UserSubscribeId: item.ObjectID,
OrderNo: content.OrderNo, OrderNo: content.OrderNo,
ResetAt: content.ResetAt, Timestamp: content.Timestamp,
}) })
} }

View File

@ -53,7 +53,7 @@ func (l *FilterSubscribeLogLogic) FilterSubscribeLog(req *types.FilterSubscribeL
UserAgent: content.UserAgent, UserAgent: content.UserAgent,
ClientIP: content.ClientIP, ClientIP: content.ClientIP,
UserSubscribeId: content.UserSubscribeId, UserSubscribeId: content.UserSubscribeId,
SubscribedAt: datum.CreatedAt.UnixMilli(), Timestamp: datum.CreatedAt.UnixMilli(),
}) })
} }

View File

@ -51,7 +51,7 @@ func (l *GetUserLoginLogsLogic) GetUserLoginLogs(req *types.GetUserLoginLogsRequ
LoginIP: content.LoginIP, LoginIP: content.LoginIP,
UserAgent: content.UserAgent, UserAgent: content.UserAgent,
Success: content.Success, Success: content.Success,
CreatedAt: datum.CreatedAt.UnixMilli(), Timestamp: datum.CreatedAt.UnixMilli(),
}) })
} }

View File

@ -50,7 +50,7 @@ func (l *GetUserSubscribeResetTrafficLogsLogic) GetUserSubscribeResetTrafficLogs
Id: item.Id, Id: item.Id,
Type: content.Type, Type: content.Type,
OrderNo: content.OrderNo, OrderNo: content.OrderNo,
ResetAt: content.ResetAt, Timestamp: content.Timestamp,
UserSubscribeId: item.ObjectID, UserSubscribeId: item.ObjectID,
}) })
} }

View File

@ -181,11 +181,11 @@ func (l *TelephoneUserRegisterLogic) TelephoneUserRegister(req *types.TelephoneR
// Register log // Register log
registerLog := log.Register{ registerLog := log.Register{
AuthMethod: "mobile", AuthMethod: "mobile",
Identifier: phoneNumber, Identifier: phoneNumber,
RegisterIP: req.IP, RegisterIP: req.IP,
UserAgent: req.UserAgent, UserAgent: req.UserAgent,
RegisterTime: time.Now().UnixMilli(), Timestamp: time.Now().UnixMilli(),
} }
content, _ = registerLog.Marshal() content, _ = registerLog.Marshal()
if err := l.svcCtx.LogModel.Insert(l.ctx, &log.SystemLog{ if err := l.svcCtx.LogModel.Insert(l.ctx, &log.SystemLog{

View File

@ -169,11 +169,11 @@ func (l *UserRegisterLogic) UserRegister(req *types.UserRegisterRequest) (resp *
// Register log // Register log
registerLog := log.Register{ registerLog := log.Register{
AuthMethod: "email", AuthMethod: "email",
Identifier: req.Email, Identifier: req.Email,
RegisterIP: req.IP, RegisterIP: req.IP,
UserAgent: req.UserAgent, UserAgent: req.UserAgent,
RegisterTime: time.Now().UnixMilli(), Timestamp: time.Now().UnixMilli(),
} }
content, _ = registerLog.Marshal() content, _ = registerLog.Marshal()
if err = l.svcCtx.LogModel.Insert(l.ctx, &log.SystemLog{ if err = l.svcCtx.LogModel.Insert(l.ctx, &log.SystemLog{

View File

@ -102,7 +102,7 @@ func (l *CloseOrderLogic) CloseOrder(req *types.CloseOrderRequest) error {
Amount: orderInfo.GiftAmount, Amount: orderInfo.GiftAmount,
Balance: deduction, Balance: deduction,
Remark: "Order cancellation refund", Remark: "Order cancellation refund",
CreatedAt: time.Now().UnixMilli(), Timestamp: time.Now().UnixMilli(),
} }
content, _ := giftLog.Marshal() content, _ := giftLog.Marshal()

View File

@ -204,7 +204,7 @@ func (l *PurchaseLogic) Purchase(req *types.PurchaseOrderRequest) (resp *types.P
Amount: orderInfo.GiftAmount, Amount: orderInfo.GiftAmount,
Balance: u.GiftAmount, Balance: u.GiftAmount,
Remark: "Purchase order deduction", Remark: "Purchase order deduction",
CreatedAt: time.Now().UnixMilli(), Timestamp: time.Now().UnixMilli(),
} }
content, _ := giftLog.Marshal() content, _ := giftLog.Marshal()

View File

@ -171,7 +171,7 @@ func (l *RenewalLogic) Renewal(req *types.RenewalOrderRequest) (resp *types.Rene
Amount: orderInfo.GiftAmount, Amount: orderInfo.GiftAmount,
Balance: u.GiftAmount, Balance: u.GiftAmount,
Remark: "Renewal order deduction", Remark: "Renewal order deduction",
CreatedAt: time.Now().UnixMilli(), Timestamp: time.Now().UnixMilli(),
} }
content, _ := giftLog.Marshal() content, _ := giftLog.Marshal()

View File

@ -112,7 +112,7 @@ func (l *ResetTrafficLogic) ResetTraffic(req *types.ResetTrafficOrderRequest) (r
Amount: orderInfo.GiftAmount, Amount: orderInfo.GiftAmount,
Balance: u.GiftAmount, Balance: u.GiftAmount,
Remark: "Renewal order deduction", Remark: "Renewal order deduction",
CreatedAt: time.Now().UnixMilli(), Timestamp: time.Now().UnixMilli(),
} }
content, _ := giftLog.Marshal() content, _ := giftLog.Marshal()

View File

@ -59,7 +59,7 @@ func (l *GetLoginLogLogic) GetLoginLog(req *types.GetLoginLogRequest) (resp *typ
LoginIP: content.LoginIP, LoginIP: content.LoginIP,
UserAgent: content.UserAgent, UserAgent: content.UserAgent,
Success: content.Success, Success: content.Success,
CreatedAt: datum.CreatedAt.UnixMilli(), Timestamp: datum.CreatedAt.UnixMilli(),
}) })
} }

View File

@ -60,7 +60,7 @@ func (l *GetSubscribeLogLogic) GetSubscribeLog(req *types.GetSubscribeLogRequest
Token: content.Token, Token: content.Token,
IP: content.ClientIP, IP: content.ClientIP,
UserAgent: content.UserAgent, UserAgent: content.UserAgent,
CreatedAt: item.CreatedAt.UnixMilli(), Timestamp: item.CreatedAt.UnixMilli(),
}) })
} }

View File

@ -58,7 +58,7 @@ func (l *QueryUserCommissionLogLogic) QueryUserCommissionLog(req *types.QueryUse
Type: content.Type, Type: content.Type,
Amount: content.Amount, Amount: content.Amount,
OrderNo: content.OrderNo, OrderNo: content.OrderNo,
CreatedAt: content.CreatedAt, Timestamp: content.Timestamp,
}) })
} }

View File

@ -123,7 +123,7 @@ type Login struct {
LoginIP string `json:"login_ip"` LoginIP string `json:"login_ip"`
UserAgent string `json:"user_agent"` UserAgent string `json:"user_agent"`
Success bool `json:"success"` Success bool `json:"success"`
LoginTime int64 `json:"login_time"` Timestamp int64 `json:"timestamp"`
} }
// Marshal implements the json.Marshaler interface for Login. // Marshal implements the json.Marshaler interface for Login.
@ -145,11 +145,11 @@ func (l *Login) Unmarshal(data []byte) error {
// Register represents a registration log entry. // Register represents a registration log entry.
type Register struct { type Register struct {
AuthMethod string `json:"auth_method"` AuthMethod string `json:"auth_method"`
Identifier string `json:"identifier"` Identifier string `json:"identifier"`
RegisterIP string `json:"register_ip"` RegisterIP string `json:"register_ip"`
UserAgent string `json:"user_agent"` UserAgent string `json:"user_agent"`
RegisterTime int64 `json:"register_time"` Timestamp int64 `json:"timestamp"`
} }
// Marshal implements the json.Marshaler interface for Register. // Marshal implements the json.Marshaler interface for Register.
@ -197,10 +197,10 @@ func (s *Subscribe) Unmarshal(data []byte) error {
// ResetSubscribe represents a reset subscription log entry. // ResetSubscribe represents a reset subscription log entry.
type ResetSubscribe struct { type ResetSubscribe struct {
Type uint16 `json:"type"` Type uint16 `json:"type"`
UserId int64 `json:"user_id"` UserId int64 `json:"user_id"`
OrderNo string `json:"order_no,omitempty"` OrderNo string `json:"order_no,omitempty"`
ResetAt int64 `json:"reset_at"` Timestamp int64 `json:"timestamp"`
} }
// Marshal implements the json.Marshaler interface for ResetSubscribe. // Marshal implements the json.Marshaler interface for ResetSubscribe.
@ -251,7 +251,7 @@ type Commission struct {
Type uint16 `json:"type"` Type uint16 `json:"type"`
Amount int64 `json:"amount"` Amount int64 `json:"amount"`
OrderNo string `json:"order_no"` OrderNo string `json:"order_no"`
CreatedAt int64 `json:"created_at"` Timestamp int64 `json:"timestamp"`
} }
// Marshal implements the json.Marshaler interface for Commission. // Marshal implements the json.Marshaler interface for Commission.
@ -279,7 +279,7 @@ type Gift struct {
Amount int64 `json:"amount"` Amount int64 `json:"amount"`
Balance int64 `json:"balance"` Balance int64 `json:"balance"`
Remark string `json:"remark,omitempty"` Remark string `json:"remark,omitempty"`
CreatedAt int64 `json:"created_at"` Timestamp int64 `json:"timestamp"`
} }
// Marshal implements the json.Marshaler interface for Gift. // Marshal implements the json.Marshaler interface for Gift.

View File

@ -235,7 +235,7 @@ type CommissionLog struct {
UserId int64 `json:"user_id"` UserId int64 `json:"user_id"`
Amount int64 `json:"amount"` Amount int64 `json:"amount"`
OrderNo string `json:"order_no"` OrderNo string `json:"order_no"`
CreatedAt int64 `json:"created_at"` Timestamp int64 `json:"timestamp"`
} }
type Coupon struct { type Coupon struct {
@ -1109,7 +1109,7 @@ type GiftLog struct {
Amount int64 `json:"amount"` Amount int64 `json:"amount"`
Balance int64 `json:"balance"` Balance int64 `json:"balance"`
Remark string `json:"remark,omitempty"` Remark string `json:"remark,omitempty"`
CreatedAt int64 `json:"created_at"` Timestamp int64 `json:"timestamp"`
} }
type GoogleLoginCallbackRequest struct { type GoogleLoginCallbackRequest struct {
@ -1149,7 +1149,7 @@ type LoginLog struct {
LoginIP string `json:"login_ip"` LoginIP string `json:"login_ip"`
UserAgent string `json:"user_agent"` UserAgent string `json:"user_agent"`
Success bool `json:"success"` Success bool `json:"success"`
LoginTime int64 `json:"login_time"` Timestamp int64 `json:"timestamp"`
} }
type LoginResponse struct { type LoginResponse struct {
@ -1571,12 +1571,12 @@ type RegisterConfig struct {
} }
type RegisterLog struct { type RegisterLog struct {
UserId int64 `json:"user_id"` UserId int64 `json:"user_id"`
AuthMethod string `json:"auth_method"` AuthMethod string `json:"auth_method"`
Identifier string `json:"identifier"` Identifier string `json:"identifier"`
RegisterIP string `json:"register_ip"` RegisterIP string `json:"register_ip"`
UserAgent string `json:"user_agent"` UserAgent string `json:"user_agent"`
RegisterTime int64 `json:"register_time"` Timestamp int64 `json:"timestamp"`
} }
type RenewalOrderRequest struct { type RenewalOrderRequest struct {
@ -1604,7 +1604,7 @@ type ResetSubscribeLog struct {
UserId int64 `json:"user_id"` UserId int64 `json:"user_id"`
UserSubscribeId int64 `json:"user_subscribe_id"` UserSubscribeId int64 `json:"user_subscribe_id"`
OrderNo string `json:"order_no,omitempty"` OrderNo string `json:"order_no,omitempty"`
ResetAt int64 `json:"reset_at"` Timestamp int64 `json:"timestamp"`
} }
type ResetSubscribeTrafficLog struct { type ResetSubscribeTrafficLog struct {
@ -1612,7 +1612,7 @@ type ResetSubscribeTrafficLog struct {
Type uint16 `json:"type"` Type uint16 `json:"type"`
UserSubscribeId int64 `json:"user_subscribe_id"` UserSubscribeId int64 `json:"user_subscribe_id"`
OrderNo string `json:"order_no,omitempty"` OrderNo string `json:"order_no,omitempty"`
ResetAt int64 `json:"reset_at"` Timestamp int64 `json:"timestamp"`
} }
type ResetTrafficOrderRequest struct { type ResetTrafficOrderRequest struct {
@ -1906,7 +1906,7 @@ type SubscribeLog struct {
UserAgent string `json:"user_agent"` UserAgent string `json:"user_agent"`
ClientIP string `json:"client_ip"` ClientIP string `json:"client_ip"`
UserSubscribeId int64 `json:"user_subscribe_id"` UserSubscribeId int64 `json:"user_subscribe_id"`
SubscribedAt int64 `json:"subscribed_at"` Timestamp int64 `json:"timestamp"`
} }
type SubscribeSortRequest struct { type SubscribeSortRequest struct {
@ -2327,7 +2327,7 @@ type UserLoginLog struct {
LoginIP string `json:"login_ip"` LoginIP string `json:"login_ip"`
UserAgent string `json:"user_agent"` UserAgent string `json:"user_agent"`
Success bool `json:"success"` Success bool `json:"success"`
CreatedAt int64 `json:"created_at"` Timestamp int64 `json:"timestamp"`
} }
type UserLoginRequest struct { type UserLoginRequest struct {
@ -2407,7 +2407,7 @@ type UserSubscribeLog struct {
Token string `json:"token"` Token string `json:"token"`
IP string `json:"ip"` IP string `json:"ip"`
UserAgent string `json:"user_agent"` UserAgent string `json:"user_agent"`
CreatedAt int64 `json:"created_at"` Timestamp int64 `json:"timestamp"`
} }
type UserSubscribeTrafficLog struct { type UserSubscribeTrafficLog struct {

View File

@ -389,7 +389,7 @@ func (l *ActivateOrderLogic) handleCommission(ctx context.Context, userInfo *use
Type: commissionType, Type: commissionType,
Amount: amount, Amount: amount,
OrderNo: orderInfo.OrderNo, OrderNo: orderInfo.OrderNo,
CreatedAt: orderInfo.CreatedAt.UnixMilli(), Timestamp: orderInfo.CreatedAt.UnixMilli(),
} }
content, _ := commissionLog.Marshal() content, _ := commissionLog.Marshal()
@ -577,10 +577,10 @@ func (l *ActivateOrderLogic) ResetTraffic(ctx context.Context, orderInfo *order.
// insert reset traffic log // insert reset traffic log
resetLog := &log.ResetSubscribe{ resetLog := &log.ResetSubscribe{
Type: log.ResetSubscribeTypePaid, Type: log.ResetSubscribeTypePaid,
UserId: userInfo.Id, UserId: userInfo.Id,
OrderNo: orderInfo.OrderNo, OrderNo: orderInfo.OrderNo,
ResetAt: time.Now().UnixMilli(), Timestamp: time.Now().UnixMilli(),
} }
content, _ := resetLog.Marshal() content, _ := resetLog.Marshal()

View File

@ -602,9 +602,9 @@ func (l *ResetTrafficLogic) clearCache(ctx context.Context, list []*user.Subscri
// insertLog inserts a reset traffic log entry // insertLog inserts a reset traffic log entry
func (l *ResetTrafficLogic) insertLog(ctx context.Context, subId, userId int64) { func (l *ResetTrafficLogic) insertLog(ctx context.Context, subId, userId int64) {
trafficLog := log.ResetSubscribe{ trafficLog := log.ResetSubscribe{
Type: log.ResetSubscribeTypeAuto, Type: log.ResetSubscribeTypeAuto,
UserId: userId, UserId: userId,
ResetAt: time.Now().UnixMilli(), Timestamp: time.Now().UnixMilli(),
} }
content, _ := trafficLog.Marshal() content, _ := trafficLog.Marshal()
if err := l.svc.DB.WithContext(ctx).Model(&log.SystemLog{}).Create(&log.SystemLog{ if err := l.svc.DB.WithContext(ctx).Model(&log.SystemLog{}).Create(&log.SystemLog{