diff --git a/server/info/internal/logic/addressupdatelogic.go b/server/info/internal/logic/addressupdatelogic.go index 572353bc..377021c2 100644 --- a/server/info/internal/logic/addressupdatelogic.go +++ b/server/info/internal/logic/addressupdatelogic.go @@ -40,6 +40,11 @@ func (l *AddressUpdateLogic) AddressUpdate(req *types.AddressRequest, userinfo * return resp.SetStatus(basic.CodeUnAuth) } + // 确认这个IsDefault的值范围 + if !auth.CheckValueRange(req.IsDefault, 0, 1) { + return resp.SetStatus(basic.CodeSafeValueRangeErr) // IsDefault值超出范围, 返回安全值范围错误 + } + now := time.Now().UTC() if req.AddressId == 0 { @@ -65,6 +70,10 @@ func (l *AddressUpdateLogic) AddressUpdate(req *types.AddressRequest, userinfo * return resp.SetStatusWithMessage(basic.CodeApiErr, err.Error()) } + if req.IsDefault > 0 { + l.svcCtx.AllModels.FsAddress.SettingUserDefaultAddress(l.ctx, userinfo.UserId, address.AddressId) + } + addresses, err := l.svcCtx.AllModels.FsAddress.GetUserAllAddress(l.ctx, userinfo.UserId) if err != nil { logx.Error(err)