From f9b63a31927210aaad28eaea1e1478e974ecfe6e Mon Sep 17 00:00:00 2001 From: ganger Date: Fri, 31 May 2024 23:47:49 +0300 Subject: [PATCH] bobik --- internal/pkg/adverts/delivery/http/http.go | 45 ++++++++++++++-------- 1 file changed, 28 insertions(+), 17 deletions(-) diff --git a/internal/pkg/adverts/delivery/http/http.go b/internal/pkg/adverts/delivery/http/http.go index a24a905..dd7b8f0 100644 --- a/internal/pkg/adverts/delivery/http/http.go +++ b/internal/pkg/adverts/delivery/http/http.go @@ -616,18 +616,11 @@ func (h *AdvertsClientHandler) UpdateAdvertById(w http.ResponseWriter, r *http.R mater = genAdverts.MaterialBuilding_MATERIAL_FOAM_CONCRETE_BLOCK } - resp, err := h.client.UpdateAdvertById(r.Context(), &genAdverts.UpdateAdvertByIdRequest{ - Id: advertId, - AdvertType: data.TypeAdvert, - TypeSale: data.TypeSale, - Title: data.Title, - Description: data.Description, - Price: data.Price, - IsAgent: data.IsAgent, - Address: &genAdverts.AddressData{Province: data.Address.Province, - Town: data.Address.Town, Street: data.Address.Street, House: data.Address.House, - Metro: data.Address.Metro, AddressPoint: data.Address.AddressPoint}, - HouseProp: &genAdverts.HouseProperties{ + var houseProp *genAdverts.HouseProperties + var flatProp *genAdverts.FlatProperties + + if data.HouseProperties != nil { + houseProp = &genAdverts.HouseProperties{ CeilingHeight: data.HouseProperties.CeilingHeight, SquareArea: data.HouseProperties.SquareArea, SquareHouse: data.HouseProperties.SquareHouse, @@ -636,8 +629,11 @@ func (h *AdvertsClientHandler) UpdateAdvertById(w http.ResponseWriter, r *http.R Cottage: data.HouseProperties.Cottage, StatusHome: statusHome, Floor: int32(data.HouseProperties.Floor), - }, - FlatProperties: &genAdverts.FlatProperties{ + } + } + + if data.FlatProperties != nil { + flatProp = &genAdverts.FlatProperties{ Floor: int32(data.FlatProperties.Floor), CeilingHeight: data.FlatProperties.CeilingHeight, SquareGeneral: data.FlatProperties.SquareGeneral, @@ -645,9 +641,24 @@ func (h *AdvertsClientHandler) UpdateAdvertById(w http.ResponseWriter, r *http.R SquareResidential: data.FlatProperties.SquareResidential, Apartment: data.FlatProperties.Apartment, FloorGeneral: int32(data.FlatProperties.FloorGeneral), - }, - YearCreation: int32(data.YearCreation), - Material: mater, + } + } + + resp, err := h.client.UpdateAdvertById(r.Context(), &genAdverts.UpdateAdvertByIdRequest{ + Id: advertId, + AdvertType: data.TypeAdvert, + TypeSale: data.TypeSale, + Title: data.Title, + Description: data.Description, + Price: data.Price, + IsAgent: data.IsAgent, + Address: &genAdverts.AddressData{Province: data.Address.Province, + Town: data.Address.Town, Street: data.Address.Street, House: data.Address.House, + Metro: data.Address.Metro, AddressPoint: data.Address.AddressPoint}, + HouseProp: houseProp, + FlatProperties: flatProp, + YearCreation: int32(data.YearCreation), + Material: mater, }) if err != nil {