Skip to content

Commit

Permalink
Merge pull request #35 from isd-sgcu/pet-svc/delete-cascade-img
Browse files Browse the repository at this point in the history
fix: updatepetproto add bool fields
  • Loading branch information
bookpanda authored Feb 17, 2024
2 parents d32347c + 507b44e commit 11d4613
Showing 1 changed file with 31 additions and 15 deletions.
46 changes: 31 additions & 15 deletions src/app/utils/pet/pet.utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,23 +104,39 @@ func CreateDtoToProto(in *dto.CreatePetRequest) *petproto.CreatePetRequest {
}

func UpdateDtoToProto(id string, in *dto.UpdatePetRequest) *petproto.UpdatePetRequest {
isSterile := false
if in.IsSterile != nil {
isSterile = *in.IsSterile
}
isVaccinated := false
if in.IsVaccinated != nil {
isVaccinated = *in.IsVaccinated
}
isVisible := false
if in.IsVisible != nil {
isVisible = *in.IsVisible
}

req := &petproto.UpdatePetRequest{
Pet: &petproto.Pet{
Id: id,
Type: in.Type,
Name: in.Name,
Birthdate: in.Birthdate,
Gender: string(in.Gender),
Color: in.Color,
Pattern: in.Pattern,
Habit: in.Habit,
Caption: in.Caption,
Images: []*imgproto.Image{},
Status: string(in.Status),
Origin: in.Origin,
Address: in.Address,
Contact: in.Contact,
AdoptBy: in.AdoptBy,
Id: id,
Type: in.Type,
Name: in.Name,
Birthdate: in.Birthdate,
Gender: string(in.Gender),
Color: in.Color,
Pattern: in.Pattern,
Habit: in.Habit,
Caption: in.Caption,
Images: []*imgproto.Image{},
Status: string(in.Status),
IsSterile: isSterile,
IsVaccinated: isVaccinated,
IsVisible: isVisible,
Origin: in.Origin,
Address: in.Address,
Contact: in.Contact,
AdoptBy: in.AdoptBy,
},
}

Expand Down

0 comments on commit 11d4613

Please sign in to comment.