refactor: remove google/uuid from register_candidate.go
- IDs are now auto-generated by DB SERIAL columns - No need to generate UUID in application code - Let repository handle ID assignment from DB response - Removed unused import
This commit is contained in:
parent
568b4ebb88
commit
7310627bee
1 changed files with 6 additions and 7 deletions
|
|
@ -5,7 +5,6 @@ import (
|
|||
"errors"
|
||||
"fmt"
|
||||
|
||||
"github.com/google/uuid"
|
||||
"github.com/rede5/gohorsejobs/backend/internal/core/domain/entity"
|
||||
"github.com/rede5/gohorsejobs/backend/internal/core/dto"
|
||||
"github.com/rede5/gohorsejobs/backend/internal/core/ports"
|
||||
|
|
@ -39,21 +38,21 @@ func (uc *RegisterCandidateUseCase) Execute(ctx context.Context, input dto.Regis
|
|||
}
|
||||
|
||||
// 3. Create Candidate's Personal Tenant/Workspace
|
||||
candidateTenantID := uuid.New().String()
|
||||
// NOTE: ID is empty - will be auto-generated by DB (SERIAL)
|
||||
candidateCompany := entity.NewCompany(
|
||||
candidateTenantID,
|
||||
"", // DB generates SERIAL id
|
||||
fmt.Sprintf("Candidate - %s", input.Name),
|
||||
nil, // No document for candidates
|
||||
nil, // No contact - will use user's contact info
|
||||
)
|
||||
|
||||
_, err = uc.companyRepo.Save(ctx, candidateCompany)
|
||||
savedCompany, err := uc.companyRepo.Save(ctx, candidateCompany)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to create candidate workspace: %w", err)
|
||||
}
|
||||
|
||||
// 4. Create User Entity
|
||||
user := entity.NewUser(uuid.New().String(), candidateTenantID, input.Name, input.Email)
|
||||
// 4. Create User Entity - ID is auto-generated by DB
|
||||
user := entity.NewUser("", savedCompany.ID, input.Name, input.Email)
|
||||
user.PasswordHash = hashed
|
||||
|
||||
// Set Metadata
|
||||
|
|
@ -75,7 +74,7 @@ func (uc *RegisterCandidateUseCase) Execute(ctx context.Context, input dto.Regis
|
|||
roles[i] = r.Name
|
||||
}
|
||||
|
||||
// 4. Generate Token (Auto-login)
|
||||
// 5. Generate Token (Auto-login)
|
||||
token, err := uc.authService.GenerateToken(saved.ID, saved.TenantID, roles)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
|
|
|||
Loading…
Reference in a new issue