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