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

Add Contacts #25

Merged
merged 1 commit into from
May 12, 2024
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
17 changes: 8 additions & 9 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,27 +6,26 @@ toolchain go1.21.5

require (
github.com/bxcodec/faker/v3 v3.8.1
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/pkg/errors v0.9.1
github.com/rs/zerolog v1.31.0
github.com/spf13/viper v1.18.1
github.com/stretchr/testify v1.8.4
google.golang.org/grpc v1.61.1
google.golang.org/grpc v1.63.2
gorm.io/driver/postgres v1.5.4
gorm.io/gorm v1.25.5
)

require (
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
github.com/golang/protobuf v1.5.3 // indirect
github.com/mattn/go-colorable v0.1.13 // indirect
github.com/mattn/go-isatty v0.0.19 // indirect
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
github.com/stretchr/objx v0.5.0 // indirect
golang.org/x/net v0.19.0 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20231120223509-83a465c0220f // indirect
google.golang.org/protobuf v1.32.0 // indirect
golang.org/x/net v0.21.0 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240227224415-6ceb2ff114de // indirect
google.golang.org/protobuf v1.34.1 // indirect
)

require (
Expand All @@ -49,9 +48,9 @@ require (
github.com/subosito/gotenv v1.6.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/sys v0.15.0 // indirect
golang.org/x/sys v0.17.0 // indirect
golang.org/x/text v0.14.0 // indirect
gopkg.in/ini.v1 v1.67.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
Expand Down
51 changes: 20 additions & 31 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,16 @@ github.com/frankban/quicktest v1.14.6/go.mod h1:4ptaffx2x8+WTWXmUCuVU6aPUX1/Mz7z
github.com/fsnotify/fsnotify v1.7.0 h1:8JEhPFa5W2WU7YfeZzPNqzMP6Lwt7L2715Ggo0nosvA=
github.com/fsnotify/fsnotify v1.7.0/go.mod h1:40Bi/Hjc2AVfZrqy+aj+yEI+/bRxZnMJyTJwOpGvigM=
github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA=
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.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38=
github.com/google/go-cmp v0.5.9/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/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek=
github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps=
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.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
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/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/jackc/pgpassfile v1.0.0 h1:/6Hmqy13Ss2zCq62VdNG8tM1wchn8zjSGOBJ6icpsIM=
github.com/jackc/pgpassfile v1.0.0/go.mod h1:CEx0iS5ambNFdcRtxPj5JhEz+xB6uRky5eyVu/W2HEg=
github.com/jackc/pgservicefile v0.0.0-20221227161230-091c0ba34f0a h1:bbPeKD0xmW/Y25WS6cokEszi5g+S0QxI/d45PkRi7Nk=
Expand Down Expand Up @@ -91,30 +85,25 @@ go.uber.org/atomic v1.9.0 h1:ECmE8Bn/WFTYwEW/bpKD3M8VtR/zQVbavAoalC1PYyE=
go.uber.org/atomic v1.9.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc=
go.uber.org/multierr v1.9.0 h1:7fIwc/ZtS0q++VgcfqFDxSBZVv/Xo49/SYnDFupUwlI=
go.uber.org/multierr v1.9.0/go.mod h1:X2jQV1h+kxSjClGpnseKVIxpmcjrj7MNnI0bnlfKTVQ=
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/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/sys v0.0.0-20220811171246-fbc7d0a398ab/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.15.0 h1:h48lPFYpsTvQJZF4EKyI4aLHaev3CxivZmv7yZig9pc=
golang.org/x/sys v0.15.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/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ=
golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/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.60.1 h1:26+wFr+cNqSGFcOXcabYC0lUVJVRa2Sb2ortSK7VrEU=
google.golang.org/grpc v1.60.1/go.mod h1:OlCHIeLYqSSsLi6i49B5QGdzaMZK9+M7LXN2FKz4eGM=
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-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=
Expand Down
4 changes: 2 additions & 2 deletions src/app/model/pet/pet.model.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ type Pet struct {
IsVaccinated bool `json:"is_vaccinated"`
IsVisible bool `json:"is_visible"`
Origin string `json:"origin" gorm:"tinytext"`
Address string `json:"address" gorm:"tinytext"`
Owner string `json:"owner" gorm:"tinytext"`
Contact string `json:"contact" gorm:"tinytext"`
AdoptBy string `json:"adopt_by" gorm:"tinytext"`
Tel string `json:"tel" gorm:"tinytext"`
}
2 changes: 1 addition & 1 deletion src/app/service/pet/pet.service.go
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ func (s *Service) AdoptPet(ctx context.Context, req *proto.AdoptPetRequest) (res
if err != nil {
return nil, status.Error(codes.Internal, "error converting dto to raw")
}
pet.AdoptBy = req.UserId
pet.Owner = req.UserId

err = s.repository.Update(req.PetId, pet)
if err != nil {
Expand Down
28 changes: 14 additions & 14 deletions src/app/service/pet/pet.service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,9 @@ func (t *PetServiceTest) SetupTest() {
IsVaccinated: true,
IsVisible: true,
Origin: faker.Paragraph(),
Address: faker.Paragraph(),
Owner: faker.Paragraph(),
Contact: faker.Paragraph(),
AdoptBy: "",
Tel: "",
}
var images []*img_proto.Image
var imageUrls []string
Expand Down Expand Up @@ -108,7 +108,7 @@ 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,
Images: t.Images,
}
Expand All @@ -132,7 +132,7 @@ 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,
}

Expand All @@ -156,7 +156,7 @@ 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,
}

Expand All @@ -176,7 +176,7 @@ func (t *PetServiceTest) SetupTest() {
IsVaccinated: t.Pet.IsVaccinated,
IsVisible: t.Pet.IsVaccinated,
Origin: t.Pet.Origin,
Address: t.Pet.Address,
Owner: t.Pet.Owner,
Contact: t.Pet.Contact,
},
}
Expand All @@ -198,7 +198,7 @@ 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,
},
}
Expand Down Expand Up @@ -228,14 +228,14 @@ 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: faker.UUIDDigit(),
Tel: t.Pet.Tel,
}

t.AdoptByReq = &proto.AdoptPetRequest{
PetId: t.ChangeAdoptBy.ID.String(),
UserId: t.ChangeAdoptBy.AdoptBy,
UserId: t.ChangeAdoptBy.Owner,
}

}
Expand Down Expand Up @@ -379,7 +379,7 @@ func createPets() []*pet.Pet {
IsVaccinated: true,
IsVisible: true,
Origin: faker.Paragraph(),
Address: faker.Paragraph(),
Owner: faker.Paragraph(),
Contact: faker.Paragraph(),
}
result = append(result, r)
Expand Down Expand Up @@ -408,7 +408,7 @@ func (t *PetServiceTest) createPetsDto(in []*pet.Pet, imagesList [][]*img_proto.
IsVaccinated: p.IsVaccinated,
IsVisible: p.IsVisible,
Origin: p.Origin,
Address: p.Address,
Owner: p.Owner,
Contact: p.Contact,
}

Expand Down Expand Up @@ -438,7 +438,7 @@ func (t *PetServiceTest) TestCreateSuccess() {
IsVaccinated: t.Pet.IsVaccinated,
IsVisible: t.Pet.IsVisible,
Origin: t.Pet.Origin,
Address: t.Pet.Address,
Owner: t.Pet.Owner,
Contact: t.Pet.Contact,
}

Expand Down Expand Up @@ -475,7 +475,7 @@ func (t *PetServiceTest) TestCreateInternalErr() {
IsVaccinated: t.Pet.IsVaccinated,
IsVisible: t.Pet.IsVisible,
Origin: t.Pet.Origin,
Address: t.Pet.Address,
Owner: t.Pet.Owner,
Contact: t.Pet.Contact,
}

Expand Down
8 changes: 4 additions & 4 deletions src/app/utils/pet/pet.utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,9 +112,9 @@ func RawToDto(in *pet.Pet, images []*imageProto.Image) *proto.Pet {
IsVaccinated: in.IsVaccinated,
IsVisible: in.IsVisible,
Origin: in.Origin,
Address: in.Address,
Owner: in.Owner,
Contact: in.Contact,
AdoptBy: in.AdoptBy,
Tel: in.Tel,
}
}

Expand Down Expand Up @@ -163,9 +163,9 @@ func DtoToRaw(in *proto.Pet) (res *pet.Pet, err error) {
IsVaccinated: in.IsVaccinated,
IsVisible: in.IsVisible,
Origin: in.Origin,
Address: in.Address,
Owner: in.Owner,
Contact: in.Contact,
AdoptBy: in.AdoptBy,
Tel: in.Tel,
}, nil
}

Expand Down
Loading
Loading