From 4d2d0486e038866cc6c755e5103134e83487901a Mon Sep 17 00:00:00 2001 From: NitiwatOwen Date: Wed, 27 Dec 2023 21:50:49 +0700 Subject: [PATCH] chore: rename sign in request dto --- src/app/dto/auth.dto.go | 2 +- src/app/handler/auth/auth.handler.go | 4 ++-- src/app/handler/auth/auth.handler_test.go | 4 ++-- src/app/service/auth/auth.service.go | 2 +- src/app/service/auth/auth.service_test.go | 4 ++-- src/docs/docs.go | 4 ++-- src/docs/swagger.json | 4 ++-- src/docs/swagger.yaml | 4 ++-- src/mocks/service/auth/auth.mock.go | 2 +- src/pkg/service/auth/auth.service.go | 2 +- 10 files changed, 16 insertions(+), 16 deletions(-) diff --git a/src/app/dto/auth.dto.go b/src/app/dto/auth.dto.go index 1db7f9c..1ca0eab 100644 --- a/src/app/dto/auth.dto.go +++ b/src/app/dto/auth.dto.go @@ -26,7 +26,7 @@ type SignupResponse struct { Lastname string `json:"lastname"` } -type SignIn struct { +type SignInRequest struct { Email string `json:"email" validate:"required,email"` Password string `json:"password" validate:"required,gte=6,lte=30"` } diff --git a/src/app/handler/auth/auth.handler.go b/src/app/handler/auth/auth.handler.go index 830c87e..92bfa5e 100644 --- a/src/app/handler/auth/auth.handler.go +++ b/src/app/handler/auth/auth.handler.go @@ -79,7 +79,7 @@ func (h *Handler) Signup(c router.IContext) { // SignIn is a function that authenticate user with email and password // @Summary Sign in user // @Description Return the credential of user including access token and refresh token -// @Param signIn body dto.SignIn true "signIn request dto" +// @Param signIn body dto.SignInRequest true "signIn request dto" // @Tags auth // @Accept json // @Produce json @@ -90,7 +90,7 @@ func (h *Handler) Signup(c router.IContext) { // @Failure 503 {object} dto.ResponseServiceDownErr "Service is down" // @Router /v1/auth/signin [post] func (h *Handler) SignIn(c router.IContext) { - request := &dto.SignIn{} + request := &dto.SignInRequest{} err := c.Bind(request) if err != nil { c.JSON(http.StatusBadRequest, dto.ResponseErr{ diff --git a/src/app/handler/auth/auth.handler_test.go b/src/app/handler/auth/auth.handler_test.go index 69a1f25..31a081a 100644 --- a/src/app/handler/auth/auth.handler_test.go +++ b/src/app/handler/auth/auth.handler_test.go @@ -18,7 +18,7 @@ import ( type AuthHandlerTest struct { suite.Suite signupRequest *dto.SignupRequest - signInRequest *dto.SignIn + signInRequest *dto.SignInRequest bindErr error validateErr []*dto.BadReqErrResponse } @@ -29,7 +29,7 @@ func TestAuthHandler(t *testing.T) { func (t *AuthHandlerTest) SetupTest() { signupRequest := &dto.SignupRequest{} - signInRequest := &dto.SignIn{} + signInRequest := &dto.SignInRequest{} bindErr := errors.New("Binding request failed") validateErr := []*dto.BadReqErrResponse{ { diff --git a/src/app/service/auth/auth.service.go b/src/app/service/auth/auth.service.go index 7691bc0..e5ea5f0 100644 --- a/src/app/service/auth/auth.service.go +++ b/src/app/service/auth/auth.service.go @@ -63,7 +63,7 @@ func (s *Service) Signup(request *dto.SignupRequest) (*dto.SignupResponse, *dto. }, nil } -func (s *Service) SignIn(signIn *dto.SignIn) (*dto.Credential, *dto.ResponseErr) { +func (s *Service) SignIn(signIn *dto.SignInRequest) (*dto.Credential, *dto.ResponseErr) { ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second) defer cancel() diff --git a/src/app/service/auth/auth.service_test.go b/src/app/service/auth/auth.service_test.go index 8ef218b..eb964ad 100644 --- a/src/app/service/auth/auth.service_test.go +++ b/src/app/service/auth/auth.service_test.go @@ -17,7 +17,7 @@ import ( type AuthServiceTest struct { suite.Suite signupRequestDto *dto.SignupRequest - signInDto *dto.SignIn + signInDto *dto.SignInRequest token string } @@ -32,7 +32,7 @@ func (t *AuthServiceTest) SetupTest() { Firstname: faker.FirstName(), Lastname: faker.LastName(), } - signInDto := &dto.SignIn{ + signInDto := &dto.SignInRequest{ Email: faker.Email(), Password: faker.Password(), } diff --git a/src/docs/docs.go b/src/docs/docs.go index fe58d6c..83c7f8d 100644 --- a/src/docs/docs.go +++ b/src/docs/docs.go @@ -38,7 +38,7 @@ const docTemplate = `{ "in": "body", "required": true, "schema": { - "$ref": "#/definitions/dto.SignIn" + "$ref": "#/definitions/dto.SignInRequest" } } ], @@ -240,7 +240,7 @@ const docTemplate = `{ } } }, - "dto.SignIn": { + "dto.SignInRequest": { "type": "object", "required": [ "email", diff --git a/src/docs/swagger.json b/src/docs/swagger.json index f1f1566..4fff186 100644 --- a/src/docs/swagger.json +++ b/src/docs/swagger.json @@ -34,7 +34,7 @@ "in": "body", "required": true, "schema": { - "$ref": "#/definitions/dto.SignIn" + "$ref": "#/definitions/dto.SignInRequest" } } ], @@ -236,7 +236,7 @@ } } }, - "dto.SignIn": { + "dto.SignInRequest": { "type": "object", "required": [ "email", diff --git a/src/docs/swagger.yaml b/src/docs/swagger.yaml index 4c8d9b3..41f5c09 100644 --- a/src/docs/swagger.yaml +++ b/src/docs/swagger.yaml @@ -72,7 +72,7 @@ definitions: example: 503 type: integer type: object - dto.SignIn: + dto.SignInRequest: properties: email: type: string @@ -133,7 +133,7 @@ paths: name: signIn required: true schema: - $ref: '#/definitions/dto.SignIn' + $ref: '#/definitions/dto.SignInRequest' produces: - application/json responses: diff --git a/src/mocks/service/auth/auth.mock.go b/src/mocks/service/auth/auth.mock.go index c63de50..43dd28f 100644 --- a/src/mocks/service/auth/auth.mock.go +++ b/src/mocks/service/auth/auth.mock.go @@ -51,7 +51,7 @@ func (mr *MockServiceMockRecorder) RefreshToken(arg0 interface{}) *gomock.Call { } // SignIn mocks base method. -func (m *MockService) SignIn(arg0 *dto.SignIn) (*dto.Credential, *dto.ResponseErr) { +func (m *MockService) SignIn(arg0 *dto.SignInRequest) (*dto.Credential, *dto.ResponseErr) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "SignIn", arg0) ret0, _ := ret[0].(*dto.Credential) diff --git a/src/pkg/service/auth/auth.service.go b/src/pkg/service/auth/auth.service.go index 0075e41..7c52aec 100644 --- a/src/pkg/service/auth/auth.service.go +++ b/src/pkg/service/auth/auth.service.go @@ -7,7 +7,7 @@ import ( type Service interface { Signup(*dto.SignupRequest) (*dto.SignupResponse, *dto.ResponseErr) - SignIn(*dto.SignIn) (*dto.Credential, *dto.ResponseErr) + SignIn(*dto.SignInRequest) (*dto.Credential, *dto.ResponseErr) SignOut(string) (bool, *dto.ResponseErr) Validate(string) (*dto.TokenPayloadAuth, *dto.ResponseErr) RefreshToken(string) (*auth_proto.Credential, *dto.ResponseErr)