Skip to content

Commit

Permalink
bobik
Browse files Browse the repository at this point in the history
  • Loading branch information
vovangy committed May 31, 2024
1 parent 58dda24 commit f9b63a3
Showing 1 changed file with 28 additions and 17 deletions.
45 changes: 28 additions & 17 deletions internal/pkg/adverts/delivery/http/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -636,18 +629,36 @@ 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,
RoomCount: int32(data.FlatProperties.RoomCount),
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 {
Expand Down

0 comments on commit f9b63a3

Please sign in to comment.