Skip to content

Commit

Permalink
Merge branch 'dev' into gear/joh-35-image-endpoints
Browse files Browse the repository at this point in the history
  • Loading branch information
macgeargear authored Jan 10, 2024
2 parents dceec6a + b36ef41 commit f64d628
Show file tree
Hide file tree
Showing 35 changed files with 1,220 additions and 279 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
-
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.3.1
github.com/pkg/errors v0.9.1
github.com/rs/zerolog v1.31.0
github.com/spf13/viper v1.18.2
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.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/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
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"`
}
15 changes: 11 additions & 4 deletions src/app/dto/pet.dto.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ type PetResponse struct {
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"`
Expand All @@ -37,15 +39,18 @@ type CreatePetRequest struct {
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:"1"`
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:"1"`
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"`

Address string `json:"address"`
Contact string `json:"contact"`
AdoptBy string `json:"adopt_by"`
Expand All @@ -57,7 +62,7 @@ type ChangeViewPetRequest struct {
}

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

type AdoptByRequest struct {
Expand All @@ -75,6 +80,8 @@ type UpdatePetRequest struct {
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"`
Expand All @@ -92,5 +99,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"`
}
19 changes: 3 additions & 16 deletions src/app/handler/like/like.handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import (
"github.com/isd-sgcu/johnjud-gateway/src/app/dto"
"github.com/isd-sgcu/johnjud-gateway/src/app/router"
"github.com/isd-sgcu/johnjud-gateway/src/app/validator"
likeConst "github.com/isd-sgcu/johnjud-gateway/src/constant/like"
likeSvc "github.com/isd-sgcu/johnjud-gateway/src/pkg/service/like"
)

Expand Down Expand Up @@ -38,11 +37,7 @@ func (h *Handler) FindByUserId(c router.IContext) {
return
}

c.JSON(http.StatusOK, dto.ResponseSuccess{
StatusCode: http.StatusOK,
Message: likeConst.FindLikeSuccessMessage,
Data: response,
})
c.JSON(http.StatusOK, response)
return
}

Expand Down Expand Up @@ -77,11 +72,7 @@ func (h *Handler) Create(c router.IContext) {
return
}

c.JSON(http.StatusCreated, dto.ResponseSuccess{
StatusCode: http.StatusCreated,
Message: likeConst.CreateLikeSuccessMessage,
Data: response,
})
c.JSON(http.StatusCreated, response)
return
}

Expand All @@ -102,10 +93,6 @@ func (h *Handler) Delete(c router.IContext) {
return
}

c.JSON(http.StatusOK, dto.ResponseSuccess{
StatusCode: http.StatusOK,
Message: likeConst.DelteLikeSuccessMessage,
Data: res,
})
c.JSON(http.StatusOK, res)
return
}
19 changes: 3 additions & 16 deletions src/app/handler/like/like.handler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import (
errConst "github.com/isd-sgcu/johnjud-gateway/src/app/constant"
"github.com/isd-sgcu/johnjud-gateway/src/app/dto"
utils "github.com/isd-sgcu/johnjud-gateway/src/app/utils/like"
likeConst "github.com/isd-sgcu/johnjud-gateway/src/constant/like"
routerMock "github.com/isd-sgcu/johnjud-gateway/src/mocks/router"
likeMock "github.com/isd-sgcu/johnjud-gateway/src/mocks/service/like"
validatorMock "github.com/isd-sgcu/johnjud-gateway/src/mocks/validator"
Expand Down Expand Up @@ -74,11 +73,7 @@ func (t *LikeHandlerTest) SetupTest() {

func (t *LikeHandlerTest) TestFindLikesSuccess() {
findLikeResponse := utils.ProtoToDtoList(t.Likes)
expectedResponse := dto.ResponseSuccess{
StatusCode: http.StatusOK,
Message: likeConst.FindLikeSuccessMessage,
Data: findLikeResponse,
}
expectedResponse := findLikeResponse

controller := gomock.NewController(t.T())

Expand Down Expand Up @@ -147,11 +142,7 @@ func (t *LikeHandlerTest) TestFindLikeInternalError() {

func (t *LikeHandlerTest) TestCreateSuccess() {
createLikeResponse := utils.ProtoToDto(t.Like)
expectedResponse := dto.ResponseSuccess{
StatusCode: http.StatusCreated,
Message: likeConst.CreateLikeSuccessMessage,
Data: createLikeResponse,
}
expectedResponse := createLikeResponse

controller := gomock.NewController(t.T())

Expand Down Expand Up @@ -208,11 +199,7 @@ func (t *LikeHandlerTest) TestDeleteSuccess() {
deleteResponse := &dto.DeleteLikeResponse{
Success: true,
}
expectedResponse := dto.ResponseSuccess{
StatusCode: http.StatusOK,
Message: likeConst.DelteLikeSuccessMessage,
Data: deleteResponse,
}
expectedResponse := deleteResponse

controller := gomock.NewController(t.T())

Expand Down
31 changes: 5 additions & 26 deletions src/app/handler/pet/pet.handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import (
"github.com/isd-sgcu/johnjud-gateway/src/app/dto"
"github.com/isd-sgcu/johnjud-gateway/src/app/router"
"github.com/isd-sgcu/johnjud-gateway/src/app/validator"
petconst "github.com/isd-sgcu/johnjud-gateway/src/constant/pet"
imageSvc "github.com/isd-sgcu/johnjud-gateway/src/pkg/service/image"
likeSvc "github.com/isd-sgcu/johnjud-gateway/src/pkg/service/like"
petSvc "github.com/isd-sgcu/johnjud-gateway/src/pkg/service/pet"
Expand Down Expand Up @@ -169,11 +168,7 @@ func (h *Handler) Create(c router.IContext) {
return
}

c.JSON(http.StatusCreated, dto.ResponseSuccess{
StatusCode: http.StatusCreated,
Message: petconst.CreatePetSuccessMessage,
Data: response,
})
c.JSON(http.StatusCreated, response)
return
}

Expand Down Expand Up @@ -232,11 +227,7 @@ func (h *Handler) Update(c router.IContext) {
return
}

c.JSON(http.StatusOK, dto.ResponseSuccess{
StatusCode: http.StatusOK,
Message: petconst.UpdatePetSuccessMessage,
Data: pet,
})
c.JSON(http.StatusOK, pet)
return
}

Expand Down Expand Up @@ -295,11 +286,7 @@ func (h *Handler) ChangeView(c router.IContext) {
return
}

c.JSON(http.StatusOK, dto.ResponseSuccess{
StatusCode: http.StatusOK,
Message: petconst.ChangeViewPetSuccessMessage,
Data: res,
})
c.JSON(http.StatusOK, res)
return
}

Expand Down Expand Up @@ -332,11 +319,7 @@ func (h *Handler) Delete(c router.IContext) {
return
}

c.JSON(http.StatusOK, dto.ResponseSuccess{
StatusCode: http.StatusOK,
Message: petconst.DeletePetSuccessMessage,
Data: res,
})
c.JSON(http.StatusOK, res)
return
}

Expand Down Expand Up @@ -394,10 +377,6 @@ func (h *Handler) Adopt(c router.IContext) {
return
}

c.JSON(http.StatusOK, dto.ResponseSuccess{
StatusCode: http.StatusOK,
Message: petconst.AdoptPetSuccessMessage,
Data: res,
})
c.JSON(http.StatusOK, res)
return
}
Loading

0 comments on commit f64d628

Please sign in to comment.