feat: get user/staff profile
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
package staffrepository
|
||||
|
||||
import (
|
||||
"errors"
|
||||
authdomain "legalgo-BE-go/internal/domain/auth"
|
||||
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
func (sr *StaffRepository) GetStaffByID(ID string) (*authdomain.Staff, error) {
|
||||
var staff authdomain.Staff
|
||||
|
||||
if ID == "" {
|
||||
return nil, errors.New("id is required")
|
||||
}
|
||||
|
||||
if err := sr.DB.Where("id = ? ", ID).First(&staff).Error; err != nil {
|
||||
if errors.Is(err, gorm.ErrRecordNotFound) {
|
||||
return nil, errors.New("staff not found")
|
||||
}
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &staff, nil
|
||||
}
|
||||
Reference in New Issue
Block a user