Skip to content

Commit

Permalink
fix naming
Browse files Browse the repository at this point in the history
  • Loading branch information
donaderoyan committed May 27, 2024
1 parent 0673085 commit 186f5ec
Show file tree
Hide file tree
Showing 19 changed files with 72 additions and 72 deletions.
2 changes: 1 addition & 1 deletion controllers/auth/login/input.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package loginController
package login

type LoginInput struct {
Email string `json:"email" validate:"required,email"`
Expand Down
2 changes: 1 addition & 1 deletion controllers/auth/login/repository.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package loginController
package login

import (
"context"
Expand Down
2 changes: 1 addition & 1 deletion controllers/auth/login/repository_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package loginController
package login

import (
"context"
Expand Down
2 changes: 1 addition & 1 deletion controllers/auth/login/service.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package loginController
package login

import (
model "github.com/donaderoyan/talentgrowth-be/models"
Expand Down
2 changes: 1 addition & 1 deletion controllers/auth/register/input.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package registerController
package register

type RegisterInput struct {
FirstName string `json:"firstName" validate:"required,alpha"`
Expand Down
2 changes: 1 addition & 1 deletion controllers/auth/register/repository.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package registerController
package register

import (
"context"
Expand Down
2 changes: 1 addition & 1 deletion controllers/auth/register/repository_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package registerController
package register

import (
"context"
Expand Down
2 changes: 1 addition & 1 deletion controllers/auth/register/service.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package registerController
package register

import (
"time"
Expand Down
2 changes: 1 addition & 1 deletion controllers/user/profile/input.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package profileController
package profile

import model "github.com/donaderoyan/talentgrowth-be/models"

Expand Down
2 changes: 1 addition & 1 deletion controllers/user/profile/repository.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package profileController
package profile

import (
"context"
Expand Down
2 changes: 1 addition & 1 deletion controllers/user/profile/service.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package profileController
package profile

import (
"reflect"
Expand Down
14 changes: 7 additions & 7 deletions docs/docs.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ const docTemplate = `{
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/loginController.LoginInput"
"$ref": "#/definitions/login.LoginInput"
}
}
],
Expand Down Expand Up @@ -99,7 +99,7 @@ const docTemplate = `{
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/registerController.RegisterInput"
"$ref": "#/definitions/register.RegisterInput"
}
}
],
Expand Down Expand Up @@ -136,7 +136,7 @@ const docTemplate = `{
}
},
"/api/v1/user/profile/{id}": {
"put": {
"patch": {
"description": "Update the profile of a user by their ID",
"consumes": [
"application/json"
Expand All @@ -162,7 +162,7 @@ const docTemplate = `{
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/profileController.UpdateProfileInput"
"$ref": "#/definitions/profile.UpdateProfileInput"
}
}
],
Expand Down Expand Up @@ -193,7 +193,7 @@ const docTemplate = `{
}
},
"definitions": {
"loginController.LoginInput": {
"login.LoginInput": {
"type": "object",
"required": [
"email",
Expand Down Expand Up @@ -235,7 +235,7 @@ const docTemplate = `{
}
}
},
"profileController.UpdateProfileInput": {
"profile.UpdateProfileInput": {
"type": "object",
"required": [
"firstName",
Expand Down Expand Up @@ -276,7 +276,7 @@ const docTemplate = `{
}
}
},
"registerController.RegisterInput": {
"register.RegisterInput": {
"type": "object",
"required": [
"email",
Expand Down
14 changes: 7 additions & 7 deletions docs/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/loginController.LoginInput"
"$ref": "#/definitions/login.LoginInput"
}
}
],
Expand Down Expand Up @@ -91,7 +91,7 @@
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/registerController.RegisterInput"
"$ref": "#/definitions/register.RegisterInput"
}
}
],
Expand Down Expand Up @@ -128,7 +128,7 @@
}
},
"/api/v1/user/profile/{id}": {
"put": {
"patch": {
"description": "Update the profile of a user by their ID",
"consumes": [
"application/json"
Expand All @@ -154,7 +154,7 @@
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/profileController.UpdateProfileInput"
"$ref": "#/definitions/profile.UpdateProfileInput"
}
}
],
Expand Down Expand Up @@ -185,7 +185,7 @@
}
},
"definitions": {
"loginController.LoginInput": {
"login.LoginInput": {
"type": "object",
"required": [
"email",
Expand Down Expand Up @@ -227,7 +227,7 @@
}
}
},
"profileController.UpdateProfileInput": {
"profile.UpdateProfileInput": {
"type": "object",
"required": [
"firstName",
Expand Down Expand Up @@ -268,7 +268,7 @@
}
}
},
"registerController.RegisterInput": {
"register.RegisterInput": {
"type": "object",
"required": [
"email",
Expand Down
14 changes: 7 additions & 7 deletions docs/swagger.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
definitions:
loginController.LoginInput:
login.LoginInput:
properties:
email:
type: string
Expand Down Expand Up @@ -28,7 +28,7 @@ definitions:
- postalCode
- state
type: object
profileController.UpdateProfileInput:
profile.UpdateProfileInput:
properties:
address:
$ref: '#/definitions/model.Address'
Expand Down Expand Up @@ -56,7 +56,7 @@ definitions:
- lastName
- phone
type: object
registerController.RegisterInput:
register.RegisterInput:
properties:
email:
type: string
Expand Down Expand Up @@ -96,7 +96,7 @@ paths:
name: login
required: true
schema:
$ref: '#/definitions/loginController.LoginInput'
$ref: '#/definitions/login.LoginInput'
produces:
- application/json
responses:
Expand Down Expand Up @@ -135,7 +135,7 @@ paths:
name: register
required: true
schema:
$ref: '#/definitions/registerController.RegisterInput'
$ref: '#/definitions/register.RegisterInput'
produces:
- application/json
responses:
Expand Down Expand Up @@ -163,7 +163,7 @@ paths:
tags:
- Authentication
/api/v1/user/profile/{id}:
put:
patch:
consumes:
- application/json
description: Update the profile of a user by their ID
Expand All @@ -178,7 +178,7 @@ paths:
name: profile
required: true
schema:
$ref: '#/definitions/profileController.UpdateProfileInput'
$ref: '#/definitions/profile.UpdateProfileInput'
produces:
- application/json
responses:
Expand Down
16 changes: 8 additions & 8 deletions handlers/auth/login/login.go
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
package handlerLogin
package loginhandler

import (
"net/http"

loginController "github.com/donaderoyan/talentgrowth-be/controllers/auth/login"
login "github.com/donaderoyan/talentgrowth-be/controllers/auth/login"
util "github.com/donaderoyan/talentgrowth-be/utils"
"github.com/gin-gonic/gin"
)

type handler struct {
service loginController.Service
service login.Service
}

func NewHandlerLogin(service loginController.Service) *handler {
func NewHandlerLogin(service login.Service) *handler {
return &handler{service: service}
}

Expand All @@ -22,14 +22,14 @@ func NewHandlerLogin(service loginController.Service) *handler {
// @Tags Authentication
// @Accept json
// @Produce json
// @Param login body loginController.LoginInput true "Login Credentials"
// @Param login body login.LoginInput true "Login Credentials"
// @Success 200 {object} map[string]interface{} "Login successful, returns access token"
// @Failure 400 {object} map[string]interface{} "Bad request, invalid input"
// @Failure 404 {object} map[string]interface{} "User not found"
// @Failure 500 {object} map[string]interface{} "Internal server error"
// @Router /api/v1/login [post]
func (h *handler) LoginHandler(ctx *gin.Context) {
var input loginController.LoginInput
var input login.LoginInput

if err := ctx.ShouldBindJSON(&input); err != nil {
util.ErrorResponse(ctx, "Login failed", http.StatusBadRequest, http.MethodPost, err.Error())
Expand All @@ -44,10 +44,10 @@ func (h *handler) LoginHandler(ctx *gin.Context) {
resultLogin, errLogin := h.service.LoginService(&input)
if errLogin != nil {
switch errLogin.(type) {
case *loginController.UserLoginError:
case *login.UserLoginError:
util.ErrorResponse(ctx, "Login failed", http.StatusInternalServerError, http.MethodPost, errLogin.Error())
return
case *loginController.UserLoginNotFoundError:
case *login.UserLoginNotFoundError:
util.ErrorResponse(ctx, "Login failed", http.StatusNotFound, http.MethodPost, errLogin.Error())
return
default:
Expand Down
16 changes: 8 additions & 8 deletions handlers/auth/register/register.go
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
package handlerRegister
package registerhandler

import (
"net/http"

"github.com/gin-gonic/gin"

registerController "github.com/donaderoyan/talentgrowth-be/controllers/auth/register"
register "github.com/donaderoyan/talentgrowth-be/controllers/auth/register"
util "github.com/donaderoyan/talentgrowth-be/utils"
)

type handler struct {
service registerController.Service
service register.Service
}

func NewHandlerRegister(service registerController.Service) *handler {
func NewHandlerRegister(service register.Service) *handler {
return &handler{service: service}
}

Expand All @@ -23,14 +23,14 @@ func NewHandlerRegister(service registerController.Service) *handler {
// @Tags Authentication
// @Accept json
// @Produce json
// @Param register body registerController.RegisterInput true "Register Input"
// @Param register body register.RegisterInput true "Register Input"
// @Success 200 {object} map[string]interface{} "User registered successfully"
// @Failure 400 {object} map[string]interface{} "Bad request, invalid input"
// @Failure 409 {object} map[string]interface{} "Conflict, user already exists"
// @Failure 500 {object} map[string]interface{} "Internal server error"
// @Router /api/v1/register [post]
func (h *handler) RegisterHandler(ctx *gin.Context) {
var input registerController.RegisterInput
var input register.RegisterInput

if err := ctx.ShouldBindJSON(&input); err != nil {
util.ErrorResponse(ctx, "Register new account failed", http.StatusBadRequest, http.MethodPost, err.Error())
Expand All @@ -45,10 +45,10 @@ func (h *handler) RegisterHandler(ctx *gin.Context) {
responseData, errRegister := h.service.RegisterService(&input)
if errRegister != nil {
switch errRegister.(type) {
case *registerController.UserAlreadyExistsError:
case *register.UserAlreadyExistsError:
util.ErrorResponse(ctx, "Register new account failed", http.StatusBadRequest, http.MethodPost, errRegister.Error())
return
case *registerController.UserRegistrationError:
case *register.UserRegistrationError:
util.ErrorResponse(ctx, "Register new account failed", http.StatusForbidden, http.MethodPost, errRegister.Error())
return
default:
Expand Down
Loading

0 comments on commit 186f5ec

Please sign in to comment.