Ejemplo n.º 1
0
 @Override
 public BlogTO getBlog(Integer id) {
   return Optional.ofNullable(blogRepository.findOne(id))
       .map(blog -> this.setVoteCounter(blog))
       .map(blog -> blogConverter.convertEntityIntoTO(blog, new BlogTO()))
       .orElseThrow(() -> new IllegalArgumentException("There's no blog with the ID" + id));
 }
Ejemplo n.º 2
0
 @Override
 public BlogTO updateBlog(BlogTO blogTO) {
   BlogDO blogDO = blogRepository.findOne(blogTO.getId());
   blogConverter.convertTOIntoEntity(blogTO, blogDO);
   return blogConverter.convertEntityIntoTO(blogRepository.save(blogDO), blogTO);
 }