@Service
public class CategoryService {

    @Autowired
    private AccountRepository accountRepository;

    @Override
	public List<RoleAssociationDTO> findAllCategoryByIdContract(String contractName, String role) {
	
		List<ViewCategoriesAssociationEntity> lst = viewCategoriesAssociationRepository.findAllByContractAndRole(contractName, role);
		
		List<RoleAssociationDTO> out = new ArrayList<>(); 
		for (ViewCategoriesAssociationEntity x: lst) {
			RoleAssociationDTO radto = new RoleAssociationDTO();
			
			AccountsEntity acc = accountRepository.findByEmail(x.getEmail()).orElseThrow(() -> new ServiceException(Messages.ACCOUNT_NOT_FOUND));
			
			
			radto.setId(x.getId());
			radto.setName(x.getName());
			radto.setSurname(x.getSurname());
			radto.setEmail(x.getEmail());
			radto.setCategory(x.getCategories());
			if (acc.getImage() != null) {
				String s = new String(acc.getImage(), StandardCharsets.UTF_8);
				radto.setImage(s);
			}
			out.add(radto);
		}
		
		
		return out;
	}
}

Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: