26 lines
489 B
Go
Raw Normal View History

package staffrepository
import (
"errors"
authdomain "legalgo-BE-go/internal/domain/auth"
"gorm.io/gorm"
)
2025-02-27 18:59:58 +08:00
func (sr *StaffRepository) GetStaffByID(ID string) (*authdomain.Staff, error) {
2025-02-24 19:47:40 +08:00
var staff authdomain.Staff
2025-02-27 18:59:58 +08:00
if ID == "" {
return nil, errors.New("id is required")
}
2025-03-01 19:00:12 +08:00
if err := sr.DB.First(&staff, "id = ? ", ID).Error; err != nil {
if errors.Is(err, gorm.ErrRecordNotFound) {
return nil, errors.New("staff not found")
}
return nil, err
}
return &staff, nil
}