From 2f839ac85b85d6b8209e591418166215d3732dc8 Mon Sep 17 00:00:00 2001 From: laodaming <11058467+laudamine@user.noreply.gitee.com> Date: Tue, 5 Sep 2023 10:53:18 +0800 Subject: [PATCH] fix --- model/gmodel/fs_user_material_logic.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/model/gmodel/fs_user_material_logic.go b/model/gmodel/fs_user_material_logic.go index 55bf5b95..4128ddef 100644 --- a/model/gmodel/fs_user_material_logic.go +++ b/model/gmodel/fs_user_material_logic.go @@ -62,8 +62,10 @@ func (m *FsUserMaterialModel) FindLatestOne(ctx context.Context, userId int64, g var cond string if userId != 0 { cond = fmt.Sprintf("user_id = %d", userId) - } else { + } else if guestId != 0 { cond = fmt.Sprintf("guest_id = %d", guestId) + } else { + cond = fmt.Sprintf("user_id = %d and guest_id = %d", userId, guestId) } db := m.db.WithContext(ctx).Model(&FsUserMaterial{}). Where(cond). @@ -80,8 +82,10 @@ func (m *FsUserMaterialModel) GetListByUser(ctx context.Context, userId, guestId var cond string if userId != 0 { cond = fmt.Sprintf("user_id = %d", userId) - } else { + } else if guestId != 0 { cond = fmt.Sprintf("guest_id = %d", guestId) + } else { + cond = fmt.Sprintf("user_id = %d and guest_id = %d", userId, guestId) } err = m.db.WithContext(ctx).Model(&FsUserMaterial{}). Where(cond).Order("id DESC").Limit(limit).Find(&resp).Error