Skip to content

Commit

Permalink
Merge pull request #25 from isd-sgcu/dev
Browse files Browse the repository at this point in the history
Update main
  • Loading branch information
bookpanda authored Jan 14, 2024
2 parents 9ab026d + df69d94 commit e522307
Show file tree
Hide file tree
Showing 59 changed files with 4,679 additions and 534 deletions.
13 changes: 13 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
## Change made

- [ ]  New features
- [ ]  Bug fixes
- [ ]  Breaking changes
## Describe what you have done
-
### New Features
-
### Fix
-
### Others
-
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ mock-gen:
mockgen -source ./src/pkg/service/auth/auth.service.go -destination ./src/mocks/service/auth/auth.mock.go
mockgen -source ./src/pkg/service/user/user.service.go -destination ./src/mocks/service/user/user.mock.go
mockgen -source ./src/pkg/service/pet/pet.service.go -destination ./src/mocks/service/pet/pet.mock.go
mockgen -source ./src/pkg/service/like/like.service.go -destination ./src/mocks/service/like/like.mock.go
mockgen -source ./src/pkg/service/image/image.service.go -destination ./src/mocks/service/image/image.mock.go
mockgen -source ./src/app/validator/validator.go -destination ./src/mocks/validator/validator.mock.go
mockgen -source ./src/app/router/context.go -destination ./src/mocks/router/context.mock.go
Expand Down
4 changes: 2 additions & 2 deletions config/auth/config.example.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ app:
secret: <secret>

database:
host: localhost
host: local-db
port: 5432
name: johnjud_db
username: root
Expand All @@ -17,7 +17,7 @@ jwt:
issuer: <issuer>

redis:
host: localhost
host: local-cache
port: 6379
password: ""
dbnum: 0
10 changes: 7 additions & 3 deletions config/config.example.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ app:
debug: true

service:
auth: auth:3002
backend: backend:3003
file: file:3004
auth: localhost:3002
backend: localhost:3003
file: localhost:3004
# Production, when gateway in a container in same network
# auth: auth:3002
# backend: backend:3003
# file: file:3004
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.2.2
github.com/isd-sgcu/johnjud-go-proto v0.5.0
github.com/pkg/errors v0.9.1
github.com/rs/zerolog v1.31.0
github.com/spf13/viper v1.18.2
Expand Down
4 changes: 4 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,10 @@ 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.2.2 h1:TOAmbwy/I+8/J5LPZH0ZN7lSLczBiZe1fs88gH8XrhY=
github.com/isd-sgcu/johnjud-go-proto v0.2.2/go.mod h1:1OK6aiCgtXQiLhxp0r6iLEejYIRpckWQZDrCZ9Trbo4=
github.com/isd-sgcu/johnjud-go-proto v0.3.1 h1:WyWfzl+5nWOw3AmINtcTfojg4CJh8ZRNbZC6qA//OXU=
github.com/isd-sgcu/johnjud-go-proto v0.3.1/go.mod h1:1OK6aiCgtXQiLhxp0r6iLEejYIRpckWQZDrCZ9Trbo4=
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/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
5 changes: 4 additions & 1 deletion src/app/constant/error.constant.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ const UnauthorizedMessage = "Unauthorized"
const DuplicateEmailMessage = "Duplicate Email"
const InternalErrorMessage = "Internal Error"
const UnavailableServiceMessage = "Unavailable Service"
const InvalidIDMessage = "Invalid ID"
const InvalidArgumentMessage = "Invalid Argument"

const PetNotFoundMessage = "Pet not found"
const InvalidArgument = "Invalid Argument"
const UserNotFoundMessage = "User not found"
const ImageNotFoundMessage = "Image not found"
10 changes: 0 additions & 10 deletions src/app/dto/adopt.dto.go

This file was deleted.

6 changes: 0 additions & 6 deletions src/app/dto/common.dto.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,3 @@ type ResponseGatewayTimeoutErr struct {
Message string `json:"message" example:"Connection timeout"`
Data interface{} `json:"data"`
}

type ResponseSuccess struct {
StatusCode int `json:"status_code" example:"200"`
Message string `json:"message" example:"success"`
Data interface{} `json:"data"`
}
21 changes: 20 additions & 1 deletion src/app/dto/image.dto.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,26 @@
package dto

type ImageDto struct {
type ImageResponse struct {
Id string `json:"id"`
Url string `json:"url"`
ObjectKey string `json:"object_key"`
}

type UploadImageRequest struct {
Filename string `json:"filename" validate:"required"`
Data []byte `json:"data" validate:"required"`
PetId string `json:"pet_id" validate:"required"`
}

type DeleteImageResponse struct {
Success bool `json:"success"`
}

type AssignPetRequest struct {
Ids []string `json:"ids" validate:"required"`
PetId string `json:"pet_id" validate:"required"`
}

type AssignPetResponse struct {
Success bool `json:"success"`
}
25 changes: 19 additions & 6 deletions src/app/dto/like.dto.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,23 @@
package dto

import (
"github.com/google/uuid"
)
type LikeResponse struct {
UserID string `json:"user_id"`
PetID string `json:"pet_id"`
}

type FindLikeRequest struct {
UserID string `json:"user_id" validate:"required"`
}

type CreateLikeRequest struct {
UserID string `json:"user_id" validate:"required"`
PetID string `json:"pet_id" validate:"required"`
}

type DeleteLikeRequest struct {
Id string `json:"id" validate:"required"`
}

type LikeDto struct {
UserID uuid.UUID `json:"user_id" validate:"required"`
PetID uuid.UUID `json:"pet_id" validate:"required"`
type DeleteLikeResponse struct {
Success bool `json:"success"`
}
60 changes: 44 additions & 16 deletions src/app/dto/pet.dto.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,46 +4,65 @@ import (
"github.com/isd-sgcu/johnjud-gateway/src/constant/pet"
)

type ImageResponse struct {
Id string `json:"id"`
Url string `json:"url"`
}

type PetResponse struct {
Id string `json:"id"`
Type string `json:"type"`
Species string `json:"species"`
Name string `json:"name"`
Birthdate string `json:"birthdate"`
Gender pet.Gender `json:"gender"`
Color string `json:"color"`
Pattern string `json:"pattern"`
Habit string `json:"habit"`
Caption string `json:"caption"`
Status pet.Status `json:"status"`
IsSterile *bool `json:"is_sterile"`
IsVaccinated *bool `json:"is_vaccinated"`
IsVisible *bool `json:"is_visible"`
IsClubPet *bool `json:"is_club_pet"`
Background string `json:"background"`
Origin string `json:"origin"`
Address string `json:"address"`
Contact string `json:"contact"`
AdoptBy string `json:"adopt_by"`
Images []ImageResponse `json:"images"`
}

type FindAllPetRequest struct {
Search string `json:"search"`
Type string `json:"type"`
Gender string `json:"gender"`
Color string `json:"color"`
Pattern string `json:"pattern"`
Age string `json:"age"`
Origin string `json:"origin"`
PageSize int `json:"page_size"`
Page int `json:"page"`
}

type FindAllMetadata struct {
Page int `json:"page"`
TotalPages int `json:"total_pages"`
PageSize int `json:"page_size"`
Total int `json:"total"`
}

type FindAllPetResponse struct {
Pets []*PetResponse `json:"pets"`
Metadata *FindAllMetadata `json:"metadata"`
}

type CreatePetRequest struct {
Type string `json:"type" validate:"required"`
Species string `json:"species" validate:"required"`
Name string `json:"name" validate:"required"`
Birthdate string `json:"birthdate" validate:"required"`
Gender pet.Gender `json:"gender" validate:"required" example:"male"`
Color string `json:"color" validate:"required"`
Pattern string `json:"pattern" validate:"required"`
Habit string `json:"habit" validate:"required"`
Caption string `json:"caption"`
Status pet.Status `json:"status" validate:"required" example:"findhome"`
IsSterile *bool `json:"is_sterile" validate:"required"`
IsVaccinated *bool `json:"is_vaccinated" validate:"required"`
IsVisible *bool `json:"is_visible" validate:"required"`
IsClubPet *bool `json:"is_club_pet" validate:"required"`
Background string `json:"background"`
Origin string `json:"origin" validate:"required"`
Address string `json:"address"`
Contact string `json:"contact"`
AdoptBy string `json:"adopt_by"`
Expand All @@ -55,23 +74,32 @@ type ChangeViewPetRequest struct {
}

type ChangeViewPetResponse struct {
Success bool `json:"success" validate:"required"`
Success bool `json:"success"`
}

type AdoptByRequest struct {
UserID string `json:"user_id" validate:"required"`
PetID string `json:"pet_id" validate:"required"`
}

type AdoptByResponse struct {
Success bool `json:"success"`
}

type UpdatePetRequest struct {
Type string `json:"type"`
Species string `json:"species"`
Name string `json:"name"`
Birthdate string `json:"birthdate"`
Gender pet.Gender `json:"gender"`
Color string `json:"color"`
Pattern string `json:"pattern"`
Habit string `json:"habit"`
Caption string `json:"caption"`
Status pet.Status `json:"status"`
IsSterile *bool `json:"is_sterile"`
IsVaccinated *bool `json:"is_vaccinated"`
IsVisible *bool `json:"is_visible"`
IsClubPet *bool `json:"is_club_pet"`
Background string `json:"background"`
Origin string `json:"origin"`
Address string `json:"address"`
Contact string `json:"contact"`
AdoptBy string `json:"adopt_by"`
Expand All @@ -81,5 +109,5 @@ type DeleteRequest struct {
Id string `json:"id" validate:"required"`
}
type DeleteResponse struct {
Success bool `json:"success" validate:"required"`
Success bool `json:"success"`
}
15 changes: 10 additions & 5 deletions src/app/dto/user.dto.go
Original file line number Diff line number Diff line change
@@ -1,14 +1,19 @@
package dto

type UserDto struct {
type User struct {
Id string `json:"id"`
Email string `json:"email"`
Firstname string `json:"firstname"`
Lastname string `json:"lastname"`
}

type UpdateUserRequest struct {
Email string `json:"email" validate:"required,email"`
Password string `json:"password" validate:"required,gte=6,lte=30"`
Firstname string `json:"firstname" validate:"required"`
Lastname string `json:"lastname" validate:"required"`
}

type UpdateUserDto struct {
Password string `json:"password" validate:"required,gte=6,lte=30"`
Firstname string `json:"firstname" validate:"required"`
Lastname string `json:"lastname" validate:"required"`
type DeleteUserResponse struct {
Success bool `json:"success"`
}
Loading

0 comments on commit e522307

Please sign in to comment.