Skip to content

Commit

Permalink
fix: pet utils
Browse files Browse the repository at this point in the history
  • Loading branch information
macgeargear committed Jan 23, 2024
1 parent 18d52eb commit 77e1225
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions src/app/utils/pet/pet.utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -147,10 +147,11 @@ func FindAllDtoToProto(in *dto.FindAllPetRequest) *petproto.FindAllPetRequest {
Gender: in.Gender,
Color: in.Color,
Pattern: in.Pattern,
Age: in.Age,
Origin: in.Origin,
PageSize: int32(in.PageSize),
Page: int32(in.Page),
MaxAge: int32(in.MaxAge),
MinAge: int32(in.MinAge),
}
}

Expand All @@ -170,7 +171,8 @@ func QueriesToFindAllDto(queries map[string]string) (*dto.FindAllPetRequest, err
Gender: "",
Color: "",
Pattern: "",
Age: "",
MinAge: 0,
MaxAge: 0,
Origin: "",
PageSize: 0,
Page: 0,
Expand All @@ -188,8 +190,18 @@ func QueriesToFindAllDto(queries map[string]string) (*dto.FindAllPetRequest, err
request.Color = v
case "pattern":
request.Pattern = v
case "age":
request.Age = v
case "minAge":
minAge, err := strconv.Atoi(v)
if err != nil {
return nil, errors.New("error parsing minAge")
}
request.MinAge = minAge
case "maxAge":
maxAge, err := strconv.Atoi(v)
if err != nil {
return nil, errors.New("error parsing maxAge")
}
request.MaxAge = maxAge
case "origin":
request.Origin = v
case "pageSize":
Expand Down

0 comments on commit 77e1225

Please sign in to comment.