chores: refactor struct and structure project

This commit is contained in:
ericprd
2025-03-05 21:21:44 +08:00
parent 13a8481f22
commit 567e0e32ca
103 changed files with 1125 additions and 731 deletions
+5 -3
View File
@@ -4,12 +4,13 @@ import (
"errors"
authdomain "legalgo-BE-go/internal/domain/auth"
staffdomain "legalgo-BE-go/internal/domain/staff"
"legalgo-BE-go/internal/utilities/utils"
"github.com/google/uuid"
)
func (a *AuthSvc) RegisterStaff(spec authdomain.RegisterStaffReq) (string, error) {
func (a *impl) RegisterStaff(spec staffdomain.StaffRegister) (string, error) {
_, err := a.staffRepo.GetStaffByEmail(spec.Email)
if err == nil {
return "", errors.New("this email address is already in use")
@@ -19,7 +20,7 @@ func (a *AuthSvc) RegisterStaff(spec authdomain.RegisterStaffReq) (string, error
return "", err
}
staff := authdomain.Staff{
staff := staffdomain.Staff{
ID: uuid.NewString(),
Email: spec.Email,
Password: hashedPwd,
@@ -27,7 +28,7 @@ func (a *AuthSvc) RegisterStaff(spec authdomain.RegisterStaffReq) (string, error
ProfilePicture: spec.ProfilePicture,
}
_, err = a.staffRepo.Create(&staff)
err = a.staffRepo.Create(staff)
if err != nil {
return "", errors.New(err.Error())
}
@@ -35,6 +36,7 @@ func (a *AuthSvc) RegisterStaff(spec authdomain.RegisterStaffReq) (string, error
authToken := authdomain.AuthToken{
Email: staff.Email,
SessionID: uuid.NewString(),
Role: "staff",
}
token, err := utils.GenerateToken(authToken)