feat: get user/staff profile

This commit is contained in:
ericprd
2025-02-27 18:59:58 +08:00
parent 290c0edff7
commit 5fb0764630
19 changed files with 426 additions and 4 deletions
+18
View File
@@ -0,0 +1,18 @@
package authsvc
import authdomain "legalgo-BE-go/internal/domain/auth"
func (as *AuthSvc) GetStaffProfile(id string) (*authdomain.StaffProfile, error) {
staff, err := as.staffRepo.GetStaffByID(id)
if err != nil {
return nil, err
}
profile := &authdomain.StaffProfile{
ID: staff.ID,
Username: staff.Username,
Email: staff.Email,
}
return profile, nil
}
+12
View File
@@ -0,0 +1,12 @@
package authsvc
import authdomain "legalgo-BE-go/internal/domain/auth"
func (as *AuthSvc) GetUserProfile(id string) (*authdomain.UserProfile, error) {
user, err := as.userRepo.GetUserByID(id)
if err != nil {
return nil, err
}
return user, nil
}
+5 -1
View File
@@ -17,9 +17,13 @@ type AuthSvc struct {
type AuthIntf interface {
LoginAsStaff(authdomain.LoginReq) (string, error)
LoginAsUser(authdomain.LoginReq) (string, error)
RegisterUser(authdomain.RegisterUserReq) (string, error)
GetUserProfile(string) (*authdomain.UserProfile, error)
LoginAsUser(authdomain.LoginReq) (string, error)
RegisterStaff(authdomain.RegisterStaffReq) (string, error)
UpdateStaff(authdomain.Staff) error
GetStaffProfile(string) (*authdomain.StaffProfile, error)
}
func New(
+1
View File
@@ -23,6 +23,7 @@ func (a *AuthSvc) RegisterStaff(spec authdomain.RegisterStaffReq) (string, error
ID: uuid.NewString(),
Email: spec.Email,
Password: hashedPwd,
Username: spec.Username,
}
_, err = a.staffRepo.Create(&user)
+15
View File
@@ -0,0 +1,15 @@
package authsvc
import authdomain "legalgo-BE-go/internal/domain/auth"
func (as *AuthSvc) UpdateStaff(spec authdomain.Staff) error {
if _, err := as.staffRepo.GetStaffByID(spec.ID); err != nil {
return err
}
if err := as.staffRepo.Update(spec); err != nil {
return err
}
return nil
}