From b162022d399117a8c16ab72dc9364f9fa65db863 Mon Sep 17 00:00:00 2001 From: shanshanzhong Date: Thu, 28 May 2026 23:15:13 -0700 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D:=20=E9=82=80=E8=AF=B7?= =?UTF-8?q?=E5=88=97=E8=A1=A8=20UNIX=5FTIMESTAMP=20=E5=9C=A8=20DATETIME(N)?= =?UTF-8?q?=20=E4=B8=8A=E8=BF=94=E5=9B=9E=E5=B0=8F=E6=95=B0=E5=AF=BC?= =?UTF-8?q?=E8=87=B4=20Scan=20int64=20=E5=A4=B1=E8=B4=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit MySQL DATETIME 带小数秒精度时, UNIX_TIMESTAMP() 返回 "1779966403.631" 形式的 DECIMAL, Go 端 int64 字段无法 Scan, 触发 100 条 Scan error, 前端拿到的 invited_at/created_at 全为 0。 改用 CAST(UNIX_TIMESTAMP(...) AS SIGNED) 在 SQL 层截断转 BIGINT, 与 getInviteRecordsLogic / getInviteSalesLogic 的现有约定一致。 --- internal/logic/admin/invite/getInviteManageListLogic.go | 2 +- internal/logic/admin/user/getAdminUserInviteListLogic.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/internal/logic/admin/invite/getInviteManageListLogic.go b/internal/logic/admin/invite/getInviteManageListLogic.go index a4be828..070cc15 100644 --- a/internal/logic/admin/invite/getInviteManageListLogic.go +++ b/internal/logic/admin/invite/getInviteManageListLogic.go @@ -48,7 +48,7 @@ func (l *GetInviteManageListLogic) GetInviteManageList(req *types.GetInviteManag var rows []inviteRow if err = applyInviteManageFilters(l.svcCtx.DB.WithContext(l.ctx). Table("user invitee"). - Select("invitee.id as invitee_id, invitee.avatar as invitee_avatar, invitee.enable as invitee_enable, UNIX_TIMESTAMP(invitee.created_at) as invited_at, invitee.referer_id as inviter_id"). + Select("invitee.id as invitee_id, invitee.avatar as invitee_avatar, invitee.enable as invitee_enable, CAST(UNIX_TIMESTAMP(invitee.created_at) AS SIGNED) as invited_at, invitee.referer_id as inviter_id"). Where("invitee.referer_id > 0 AND invitee.deleted_at IS NULL"), req). Order("invitee.created_at DESC"). Limit(req.Size). diff --git a/internal/logic/admin/user/getAdminUserInviteListLogic.go b/internal/logic/admin/user/getAdminUserInviteListLogic.go index 8d1aca2..7c94d91 100644 --- a/internal/logic/admin/user/getAdminUserInviteListLogic.go +++ b/internal/logic/admin/user/getAdminUserInviteListLogic.go @@ -49,7 +49,7 @@ func (l *GetAdminUserInviteListLogic) GetAdminUserInviteList(req *types.GetAdmin var rows []InvitedUser err = applyAdminUserInviteFilters(l.svcCtx.DB.WithContext(l.ctx). Table("user u"). - Select("u.id, u.avatar, u.enable, UNIX_TIMESTAMP(u.created_at) as created_at, COALESCE((SELECT uam.auth_identifier FROM user_auth_methods uam WHERE uam.user_id = u.id ORDER BY uam.id ASC LIMIT 1), '') as identifier"). + Select("u.id, u.avatar, u.enable, CAST(UNIX_TIMESTAMP(u.created_at) AS SIGNED) as created_at, COALESCE((SELECT uam.auth_identifier FROM user_auth_methods uam WHERE uam.user_id = u.id ORDER BY uam.id ASC LIMIT 1), '') as identifier"). Where("u.referer_id = ? AND u.deleted_at IS NULL", req.UserId), req). Order("u.created_at DESC"). Limit(req.Size).