class RepositoryServiceImpl implements RepositoryService {

	@Override
	public List<Repository> findCanAccessRepositoriesByUserId(Integer userId) {
		List<Repository> projects = repositoryAuthorizationDao.findAllByUserId(userId).stream().flatMap(projectAuthoriation -> {
			return repositoryDao.findById(projectAuthoriation.getRepositoryId()).stream();
		}).sorted(Comparator.comparing(Repository::getLastActiveTime).reversed()).collect(Collectors.toList());
		
		projects.forEach(each -> {
			String loginName = userService.findById(each.getCreateUserId()).map(UserInfo::getLoginName).orElse(null);
			each.setCreateUserName(loginName);
		});
		
		return projects;
	}

}