feat: get user/staff profile
This commit is contained in:
@@ -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
|
||||
}
|
||||
@@ -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
|
||||
}
|
||||
@@ -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(
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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
|
||||
}
|
||||
Reference in New Issue
Block a user