Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Gear/joh 71 johnjud gateway change find all pet request #29

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ require (
github.com/gofiber/fiber/v2 v2.52.0
github.com/golang/mock v1.6.0
github.com/google/uuid v1.5.0
github.com/isd-sgcu/johnjud-go-proto v0.5.0
github.com/isd-sgcu/johnjud-go-proto v0.5.2
github.com/rs/zerolog v1.31.0
github.com/spf13/viper v1.18.1
github.com/stretchr/testify v1.8.4
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ github.com/hashicorp/hcl v1.0.0 h1:0Anlzjpi4vEasTeNFn2mLJgTSwt0+6sfsiTG8qcWGx4=
github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ=
github.com/isd-sgcu/johnjud-go-proto v0.5.0 h1:GgqRzWjya5p1yhfU/kpX8i4WL42+qT2TkyXZmssH6B4=
github.com/isd-sgcu/johnjud-go-proto v0.5.0/go.mod h1:1OK6aiCgtXQiLhxp0r6iLEejYIRpckWQZDrCZ9Trbo4=
github.com/isd-sgcu/johnjud-go-proto v0.5.2 h1:LWhi7zaEeEOJ60nyCxxMeAr7Bvl9stWvQbaw0RWz/Cs=
github.com/isd-sgcu/johnjud-go-proto v0.5.2/go.mod h1:1OK6aiCgtXQiLhxp0r6iLEejYIRpckWQZDrCZ9Trbo4=
github.com/josharian/intern v1.0.0 h1:vlS4z54oSdjm0bgjRigI+G1HpF+tI+9rE5LLzOg8HmY=
github.com/josharian/intern v1.0.0/go.mod h1:5DoeVV0s6jJacbCEi61lwdGj/aVlrQvzHFFd8Hwg//Y=
github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU=
Expand Down
2 changes: 2 additions & 0 deletions src/app/dto/pet.dto.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ type FindAllPetRequest struct {
Color string `json:"color"`
Pattern string `json:"pattern"`
Age string `json:"age"`
MinAge int `json:"min_age"`
MaxAge int `json:"max_age"`
Origin string `json:"origin"`
PageSize int `json:"page_size"`
Page int `json:"page"`
Expand Down
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
Loading