-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: Unify project packages (#130)
* refactor(accounts): Use a single file for all domain errors * refactor(accounts): Use a single file for all requests schemas * refactor(accounts): Remove http prefix from controllers and routes files * refactor(courses): Update files names * chore(labs): Track responses folder Add an empty .gitkeep file to track the folder * refactor(lang): Update files names and track requests folder * refactor(rubrics): Use a single file for all domain errors * refactor(rubrics): Remove http prefix from controllers and routes files * refactor(session): Use a single file for all dtos * refactor(session): Use a single file for all domain errors * refactor(session): Remove http prefix from controllers and routes files * refactor(session): Use a single file for all requests and track responses folder * refactor: Replace snake case imports with camel case Use golang naming convention
- Loading branch information
1 parent
7d538f4
commit 1511156
Showing
40 changed files
with
279 additions
and
301 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package errors | ||
|
||
import ( | ||
"fmt" | ||
"net/http" | ||
) | ||
|
||
type EmailAlreadyInUseError struct { | ||
Email string | ||
} | ||
|
||
func (err EmailAlreadyInUseError) Error() string { | ||
return fmt.Sprintf("Email %s is already in use", err.Email) | ||
} | ||
|
||
func (err EmailAlreadyInUseError) StatusCode() int { | ||
return http.StatusConflict | ||
} | ||
|
||
type InstitutionalIdAlreadyInUseError struct { | ||
InstitutionalId string | ||
} | ||
|
||
func (err InstitutionalIdAlreadyInUseError) Error() string { | ||
return fmt.Sprintf("Institutional ID %s is already in use", err.InstitutionalId) | ||
} | ||
|
||
func (err InstitutionalIdAlreadyInUseError) StatusCode() int { | ||
return http.StatusConflict | ||
} | ||
|
||
type UserNotFoundError struct { | ||
Uuuid string | ||
} | ||
|
||
func (err UserNotFoundError) Error() string { | ||
return fmt.Sprintf("User with UUID %s not found", err.Uuuid) | ||
} | ||
|
||
func (err UserNotFoundError) StatusCode() int { | ||
return http.StatusNotFound | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
package requests | ||
|
||
import "github.com/UPB-Code-Labs/main-api/src/accounts/domain/dtos" | ||
|
||
type RegisterAdminRequest struct { | ||
FullName string `json:"full_name" validate:"required,min=4,max=255"` | ||
Email string `json:"email" validate:"required,email"` | ||
Password string `json:"password" validate:"required,min=8,max=255,secure_password"` | ||
} | ||
|
||
func (request *RegisterAdminRequest) ToDTO() *dtos.RegisterUserDTO { | ||
return &dtos.RegisterUserDTO{ | ||
FullName: request.FullName, | ||
Email: request.Email, | ||
Password: request.Password, | ||
} | ||
} | ||
|
||
type RegisterTeacherRequest struct { | ||
FullName string `json:"full_name" validate:"required,min=4,max=255"` | ||
Email string `json:"email" validate:"required,email,institutional_email"` | ||
Password string `json:"password" validate:"required,min=8,max=255,secure_password"` | ||
} | ||
|
||
func (request *RegisterTeacherRequest) ToDTO() *dtos.RegisterUserDTO { | ||
return &dtos.RegisterUserDTO{ | ||
FullName: request.FullName, | ||
Email: request.Email, | ||
Password: request.Password, | ||
} | ||
} | ||
|
||
type RegisterUserRequest struct { | ||
FullName string `json:"full_name" validate:"required,min=4,max=255"` | ||
Email string `json:"email" validate:"required,email,institutional_email"` | ||
InstitutionalId string `json:"institutional_id" validate:"required,numeric,min=6,max=9"` | ||
Password string `json:"password" validate:"required,min=8,max=255,secure_password"` | ||
} | ||
|
||
func (request *RegisterUserRequest) ToDTO() *dtos.RegisterUserDTO { | ||
return &dtos.RegisterUserDTO{ | ||
FullName: request.FullName, | ||
Email: request.Email, | ||
InstitutionalId: request.InstitutionalId, | ||
Password: request.Password, | ||
} | ||
} |
17 changes: 0 additions & 17 deletions
17
src/accounts/infrastructure/requests/register_admin_request.go
This file was deleted.
Oops, something went wrong.
17 changes: 0 additions & 17 deletions
17
src/accounts/infrastructure/requests/register_teacher_request.go
This file was deleted.
Oops, something went wrong.
19 changes: 0 additions & 19 deletions
19
src/accounts/infrastructure/requests/register_user_request.go
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
Oops, something went wrong.