class AffiliationServiceImpl extends BaseTransactionalService implements AffiliationService {

    @Override
    public ServiceResult<AffiliationListResource> getUserAffiliations(long userId) {
        return find(userRepository.findById(userId), notFoundError(User.class, userId)).andOnSuccess(user ->
                            serviceSuccess(new AffiliationListResource(
                                    simpleMap(user.getAffiliations(), affiliationMapper::mapToResource)
                            ))
        );
    }

}