Skip to content

Commit

Permalink
fix: add if error for DtoToRaw in pet srv
Browse files Browse the repository at this point in the history
  • Loading branch information
bookpanda committed Dec 24, 2023
1 parent 6854ed9 commit 38b89e3
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions src/app/service/pet/pet.service.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,10 @@ func (s *Service) Delete(ctx context.Context, req *proto.DeletePetRequest) (*pro
}

func (s *Service) Update(_ context.Context, req *proto.UpdatePetRequest) (res *proto.UpdatePetResponse, err error) {
raw, _ := DtoToRaw(req.Pet)
raw, err := DtoToRaw(req.Pet)
if err != nil {
return nil, status.Error(codes.Internal, "error converting dto to raw")
}

err = s.repository.Update(req.Pet.Id, raw)
if err != nil {
Expand All @@ -72,7 +75,10 @@ func (s *Service) ChangeView(_ context.Context, req *proto.ChangeViewPetRequest)
if err != nil {
return nil, status.Error(codes.NotFound, "pet not found")
}
pet, _ := DtoToRaw(petData.Pet)
pet, err := DtoToRaw(petData.Pet)
if err != nil {
return nil, status.Error(codes.Internal, "error converting dto to raw")
}
pet.IsVisible = req.Visible

err = s.repository.Update(req.Id, pet)
Expand Down Expand Up @@ -107,7 +113,11 @@ func (s Service) FindOne(_ context.Context, req *proto.FindOnePetRequest) (res *
}

func (s *Service) Create(_ context.Context, req *proto.CreatePetRequest) (res *proto.CreatePetResponse, err error) {
raw, _ := DtoToRaw(req.Pet)
raw, err := DtoToRaw(req.Pet)
if err != nil {
return nil, status.Error(codes.Internal, "error converting dto to raw")
}

imgUrls := []string{}

err = s.repository.Create(raw)
Expand Down

0 comments on commit 38b89e3

Please sign in to comment.