From f6383ae6955e8da839a0ed13cf3219f06f607626 Mon Sep 17 00:00:00 2001 From: Idhibhat Pankam Date: Sun, 12 May 2024 17:54:23 +0700 Subject: [PATCH] feat: add owner, tel in pet --- go.mod | 17 +++++------ go.sum | 39 ++++++++++--------------- src/app/dto/pet.dto.go | 11 +++---- src/app/handler/pet/pet.handler_test.go | 8 ++--- src/app/service/pet/pet.service_test.go | 20 ++++++------- src/app/utils/pet/pet.utils.go | 16 +++++----- 6 files changed, 52 insertions(+), 59 deletions(-) diff --git a/go.mod b/go.mod index 3a00ffe..99ce8ee 100644 --- a/go.mod +++ b/go.mod @@ -11,13 +11,13 @@ require ( github.com/go-playground/validator/v10 v10.16.0 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.6.1 + github.com/google/uuid v1.6.0 + github.com/isd-sgcu/johnjud-go-proto v0.7.1 github.com/rs/zerolog v1.31.0 github.com/spf13/viper v1.18.1 github.com/stretchr/testify v1.8.4 github.com/swaggo/swag v1.16.2 - google.golang.org/grpc v1.61.1 + google.golang.org/grpc v1.63.2 ) require ( @@ -30,7 +30,6 @@ require ( github.com/go-openapi/jsonreference v0.20.4 // indirect github.com/go-openapi/spec v0.20.13 // indirect github.com/go-openapi/swag v0.22.7 // indirect - github.com/golang/protobuf v1.5.3 // indirect github.com/hashicorp/hcl v1.0.0 // indirect github.com/josharian/intern v1.0.0 // indirect github.com/klauspost/compress v1.17.4 // indirect @@ -58,14 +57,14 @@ require ( github.com/valyala/tcplisten v1.0.0 // indirect go.uber.org/atomic v1.9.0 // indirect go.uber.org/multierr v1.9.0 // indirect - golang.org/x/crypto v0.16.0 // indirect + golang.org/x/crypto v0.19.0 // indirect golang.org/x/exp v0.0.0-20230905200255-921286631fa9 // indirect - golang.org/x/net v0.19.0 // indirect - golang.org/x/sys v0.16.0 // indirect + golang.org/x/net v0.21.0 // indirect + golang.org/x/sys v0.17.0 // indirect golang.org/x/text v0.14.0 // indirect golang.org/x/tools v0.16.1 // indirect - google.golang.org/genproto/googleapis/rpc v0.0.0-20231120223509-83a465c0220f // indirect - google.golang.org/protobuf v1.32.0 // indirect + google.golang.org/genproto/googleapis/rpc v0.0.0-20240227224415-6ceb2ff114de // indirect + google.golang.org/protobuf v1.34.1 // indirect gopkg.in/ini.v1 v1.67.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect ) diff --git a/go.sum b/go.sum index 9663fd7..5604213 100644 --- a/go.sum +++ b/go.sum @@ -55,19 +55,15 @@ github.com/gofiber/fiber/v2 v2.52.0 h1:S+qXi7y+/Pgvqq4DrSmREGiFwtB7Bu6+QFLuIHYw/ github.com/gofiber/fiber/v2 v2.52.0/go.mod h1:KEOE+cXMhXG0zHc9d8+E38hoX+ZN7bhOtgeF2oT6jrQ= github.com/golang/mock v1.6.0 h1:ErTB+efbowRARo13NNdxyJji2egdxLGQhRaY+DUumQc= github.com/golang/mock v1.6.0/go.mod h1:p6yTPP+5HYm5mzsMV8JkE6ZKdX+/wYM6Hr+LicevLPs= -github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= -github.com/golang/protobuf v1.5.3 h1:KhyjKVUg7Usr/dYsdSqoFveMYd5ko72D+zANwlG1mmg= -github.com/golang/protobuf v1.5.3/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= -github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= -github.com/google/uuid v1.5.0 h1:1p67kYwdtXjb0gL0BPiP1Av9wiZPo5A8z2cWkTZ+eyU= -github.com/google/uuid v1.5.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= +github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY= 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.6.1 h1:9gGBsMOONhuIsSEavMb9FiD7d+naX26niSQPwQGHOM0= -github.com/isd-sgcu/johnjud-go-proto v0.6.1/go.mod h1:0728XfYpZw/4K/+NmXsyVt1z7Cxwbc4nxLg7LpowIE4= +github.com/isd-sgcu/johnjud-go-proto v0.7.1 h1:sdwyEvFcGoLmoypjOuZRgQZGeuX9jcXdiPcUWJw3VoA= +github.com/isd-sgcu/johnjud-go-proto v0.7.1/go.mod h1:C1oOvRz1bYqX2EGG3Iy+1mbB9buvhwudR/hYwWKkAwE= 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= @@ -177,8 +173,8 @@ golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACk golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/crypto v0.0.0-20220214200702-86341886e292/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= -golang.org/x/crypto v0.16.0 h1:mMMrFzRSCF0GvB7Ne27XVtVAaXLrPmgPC7/v0tkwHaY= -golang.org/x/crypto v0.16.0/go.mod h1:gCAAfMLgwOJRpTjQ2zCCt2OcSfYMTeZVSRtQlPC7Nq4= +golang.org/x/crypto v0.19.0 h1:ENy+Az/9Y1vSrlrvBSyna3PITt4tiZLf7sgCjZBX7Wo= +golang.org/x/crypto v0.19.0/go.mod h1:Iy9bg/ha4yyC70EfRS8jz+B6ybOBKMaSxLj6P6oBDfU= golang.org/x/exp v0.0.0-20230905200255-921286631fa9 h1:GoHiUyI/Tp2nVkLI2mCxVkOjsbSXD66ic0XW0js0R9g= golang.org/x/exp v0.0.0-20230905200255-921286631fa9/go.mod h1:S2oDrQGGwySpoQPVqRShND87VCbxmc6bL1Yd2oYrm6k= golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= @@ -196,8 +192,8 @@ golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qx golang.org/x/net v0.0.0-20220225172249-27dd8689420f/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= golang.org/x/net v0.7.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= -golang.org/x/net v0.19.0 h1:zTwKpTd2XuCqf8huc7Fo2iSy+4RHPd10s4KzeTnVr1c= -golang.org/x/net v0.19.0/go.mod h1:CfAk/cbD4CthTvqiEl8NpboMuiuOYsAr/7NOjZJtv1U= +golang.org/x/net v0.21.0 h1:AQyQV4dYCvJ7vGmJyKki9+PBdyvhkSd8EIx/qb0AYv4= +golang.org/x/net v0.21.0/go.mod h1:bIjVDfnllIU7BJ2DNgfnXvpSvtn8VRwhlsaeUTyUS44= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= @@ -218,8 +214,8 @@ golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.16.0 h1:xWw16ngr6ZMtmxDyKyIgsE93KNKz5HKmMa3b8ALHidU= -golang.org/x/sys v0.16.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.17.0 h1:25cE3gD+tdBA7lp7QfhuV+rJiE9YXTcS3VG1SqssI/Y= +golang.org/x/sys v0.17.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k= @@ -240,16 +236,13 @@ golang.org/x/tools v0.16.1 h1:TLyB3WofjdOEepBHAU20JdNC1Zbg87elYofWYAY5oZA= golang.org/x/tools v0.16.1/go.mod h1:kYVVN6I1mBNoB1OX+noeBjbRk4IUEPa7JJ+TJMEooJ0= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -google.golang.org/genproto/googleapis/rpc v0.0.0-20231120223509-83a465c0220f h1:ultW7fxlIvee4HYrtnaRPon9HpEgFk5zYpmfMgtKB5I= -google.golang.org/genproto/googleapis/rpc v0.0.0-20231120223509-83a465c0220f/go.mod h1:L9KNLi232K1/xB6f7AlSX692koaRnKaWSR0stBki0Yc= -google.golang.org/grpc v1.61.1 h1:kLAiWrZs7YeDM6MumDe7m3y4aM6wacLzM1Y/wiLP9XY= -google.golang.org/grpc v1.61.1/go.mod h1:VUbo7IFqmF1QtCAstipjG0GIoq49KvMe9+h1jFLBNJs= -google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= -google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= -google.golang.org/protobuf v1.32.0 h1:pPC6BG5ex8PDFnkbrGU3EixyhKcQ2aDuBS36lqK/C7I= -google.golang.org/protobuf v1.32.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos= +google.golang.org/genproto/googleapis/rpc v0.0.0-20240227224415-6ceb2ff114de h1:cZGRis4/ot9uVm639a+rHCUaG0JJHEsdyzSQTMX+suY= +google.golang.org/genproto/googleapis/rpc v0.0.0-20240227224415-6ceb2ff114de/go.mod h1:H4O17MA/PE9BsGx3w+a+W2VOLLD1Qf7oJneAoU6WktY= +google.golang.org/grpc v1.63.2 h1:MUeiw1B2maTVZthpU5xvASfTh3LDbxHd6IJ6QQVU+xM= +google.golang.org/grpc v1.63.2/go.mod h1:WAX/8DgncnokcFUldAxq7GeB5DXHDbMF+lLvDomNkRA= +google.golang.org/protobuf v1.34.1 h1:9ddQBjfCyZPOHPUiPxpYESBLc+T8P3E+Vo4IbKZgFWg= +google.golang.org/protobuf v1.34.1/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= diff --git a/src/app/dto/pet.dto.go b/src/app/dto/pet.dto.go index 8894c88..337faad 100644 --- a/src/app/dto/pet.dto.go +++ b/src/app/dto/pet.dto.go @@ -19,9 +19,9 @@ type PetResponse struct { IsVaccinated *bool `json:"is_vaccinated"` IsVisible *bool `json:"is_visible"` Origin string `json:"origin"` - Address string `json:"address"` + Owner string `json:"owner"` Contact string `json:"contact"` - AdoptBy string `json:"adopt_by"` + Tel string `json:"tel"` Images []*ImageResponse `json:"images"` } @@ -66,8 +66,9 @@ type CreatePetRequest struct { IsVisible *bool `json:"is_visible" validate:"required"` Origin string `json:"origin" validate:"required"` Address string `json:"address"` + Owner string `json:"owner"` Contact string `json:"contact"` - AdoptBy string `json:"adopt_by"` + Tel string `json:"tel"` Images []string `json:"images"` } @@ -101,9 +102,9 @@ type UpdatePetRequest struct { IsVaccinated *bool `json:"is_vaccinated"` IsVisible *bool `json:"is_visible"` Origin string `json:"origin"` - Address string `json:"address"` + Owner string `json:"owner"` Contact string `json:"contact"` - AdoptBy string `json:"adopt_by"` + Tel string `json:"tel"` Images []string `json:"images"` } type DeleteRequest struct { diff --git a/src/app/handler/pet/pet.handler_test.go b/src/app/handler/pet/pet.handler_test.go index aa337d2..ca4f694 100644 --- a/src/app/handler/pet/pet.handler_test.go +++ b/src/app/handler/pet/pet.handler_test.go @@ -84,9 +84,9 @@ func (t *PetHandlerTest) SetupTest() { IsVaccinated: true, IsVisible: true, Origin: faker.Paragraph(), - Address: faker.Paragraph(), + Owner: faker.Paragraph(), Contact: faker.Paragraph(), - AdoptBy: "", + Tel: "", } pets = append(pets, pet) @@ -117,9 +117,9 @@ func (t *PetHandlerTest) SetupTest() { IsVaccinated: &t.Pet.IsVaccinated, IsVisible: &t.Pet.IsVisible, Origin: t.Pet.Origin, - Address: t.Pet.Address, + Owner: t.Pet.Owner, Contact: t.Pet.Contact, - AdoptBy: t.Pet.AdoptBy, + Tel: t.Pet.Tel, } t.QueriesMock = map[string]string{ diff --git a/src/app/service/pet/pet.service_test.go b/src/app/service/pet/pet.service_test.go index 3d4bdfe..1fe08a8 100644 --- a/src/app/service/pet/pet.service_test.go +++ b/src/app/service/pet/pet.service_test.go @@ -99,9 +99,9 @@ func (t *PetServiceTest) SetupTest() { IsVaccinated: true, IsVisible: true, Origin: faker.Paragraph(), - Address: faker.Paragraph(), + Owner: faker.Paragraph(), Contact: faker.Paragraph(), - AdoptBy: faker.UUIDDigit(), + Tel: faker.UUIDDigit(), } pets = append(pets, pet) @@ -140,9 +140,9 @@ func (t *PetServiceTest) SetupTest() { IsVaccinated: t.Pet.IsVaccinated, IsVisible: false, Origin: t.Pet.Origin, - Address: t.Pet.Address, + Owner: t.Pet.Owner, Contact: t.Pet.Contact, - AdoptBy: t.Pet.AdoptBy, + Tel: t.Pet.Tel, } t.PetDto = utils.ProtoToDto(t.Pet, utils.ImageProtoToDto(t.Pet.Images)) @@ -174,9 +174,9 @@ func (t *PetServiceTest) SetupTest() { IsVaccinated: &t.Pet.IsVaccinated, IsVisible: &t.Pet.IsVisible, Origin: t.Pet.Origin, - Address: t.Pet.Address, + Owner: t.Pet.Owner, Contact: t.Pet.Contact, - AdoptBy: t.Pet.AdoptBy, + Tel: t.Pet.Tel, } t.UpdatePetDto = &dto.UpdatePetRequest{ @@ -194,9 +194,9 @@ func (t *PetServiceTest) SetupTest() { IsVaccinated: &t.Pet.IsVaccinated, IsVisible: &t.Pet.IsVisible, Origin: t.Pet.Origin, - Address: t.Pet.Address, + Owner: t.Pet.Owner, Contact: t.Pet.Contact, - AdoptBy: t.Pet.AdoptBy, + Tel: t.Pet.Tel, } t.FindAllPetReq = utils.FindAllDtoToProto(t.FindAllPetDto, true) @@ -214,11 +214,11 @@ func (t *PetServiceTest) SetupTest() { t.AdoptReq = &petproto.AdoptPetRequest{ PetId: t.Pet.Id, - UserId: t.Pet.AdoptBy, + UserId: t.Pet.Owner, } t.AdoptDto = &dto.AdoptByRequest{ - UserID: t.Pet.AdoptBy, + UserID: t.Pet.Owner, } t.FindAllImageReq = &imgproto.FindAllImageRequest{} diff --git a/src/app/utils/pet/pet.utils.go b/src/app/utils/pet/pet.utils.go index 54b5205..e0a02fd 100644 --- a/src/app/utils/pet/pet.utils.go +++ b/src/app/utils/pet/pet.utils.go @@ -71,9 +71,9 @@ func ProtoToDto(in *petproto.Pet, images []*dto.ImageResponse) *dto.PetResponse IsVaccinated: &in.IsVaccinated, IsVisible: &in.IsVisible, Origin: in.Origin, - Address: in.Address, + Owner: in.Owner, Contact: in.Contact, - AdoptBy: in.AdoptBy, + Tel: in.Tel, Images: images, } return pet @@ -96,9 +96,9 @@ func CreateDtoToProto(in *dto.CreatePetRequest) *petproto.CreatePetRequest { IsVaccinated: *in.IsVaccinated, IsVisible: *in.IsVisible, Origin: in.Origin, - Address: in.Address, + Owner: in.Owner, Contact: in.Contact, - AdoptBy: in.AdoptBy, + Tel: in.Tel, }, } } @@ -134,9 +134,9 @@ func UpdateDtoToProto(id string, in *dto.UpdatePetRequest) *petproto.UpdatePetRe IsVaccinated: isVaccinated, IsVisible: isVisible, Origin: in.Origin, - Address: in.Address, + Owner: in.Owner, Contact: in.Contact, - AdoptBy: in.AdoptBy, + Tel: in.Tel, }, } @@ -164,9 +164,9 @@ func ProtoToDtoList(in []*petproto.Pet, imagesList map[string][]*imgproto.Image, IsVaccinated: &p.IsVaccinated, IsVisible: &p.IsVisible, Origin: p.Origin, - Address: p.Address, + Owner: p.Owner, Contact: p.Contact, - AdoptBy: p.AdoptBy, + Tel: p.Tel, Images: ImageProtoToDto(imagesList[p.Id]), } resp = append(resp, pet)