From 8e207ef600192b800861174708b374de5fec46f1 Mon Sep 17 00:00:00 2001 From: laodaming <11058467+laudamine@user.noreply.gitee.com> Date: Tue, 11 Jul 2023 14:16:13 +0800 Subject: [PATCH] fix --- model/gmodel/fs_address_logic.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/model/gmodel/fs_address_logic.go b/model/gmodel/fs_address_logic.go index 1ce577dc..5e2190e1 100755 --- a/model/gmodel/fs_address_logic.go +++ b/model/gmodel/fs_address_logic.go @@ -52,12 +52,12 @@ func (a *FsAddressModel) CreateOne(ctx context.Context, address *FsAddress) (res func (a *FsAddressModel) UpdateAddAddress(ctx context.Context, address *FsAddress) (err error) { err = a.db.WithContext(ctx).Transaction(func(tx *gorm.DB) error { if *address.IsDefault > 0 { - err = tx.Where("user_id = ? and is_default = 1", address.UserId).Update("is_default", 0).Error + err = tx.Model(&FsAddress{}).Where("user_id = ? and is_default = 1 ", address.UserId).Update("is_default", 0).Error if err != nil { return err } } - return a.db.WithContext(ctx).Where("id = ? and user_id = ?", address.Id, address.UserId).Omit("id", "user_id").Updates(address).Error + return tx.Model(&FsAddress{}).Where("id = ? and user_id = ?", address.Id, address.UserId).Omit("id", "user_id").Updates(address).Error }) return err }