Vertx repository refactor
This commit is contained in:
parent
9048d5215b
commit
df9953b6e6
|
@ -1,11 +1,7 @@
|
|||
package com.baeldung.vertxspring.repository;
|
||||
|
||||
import org.springframework.data.repository.CrudRepository;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import com.baeldung.vertxspring.entity.Article;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
|
||||
@Repository
|
||||
public interface ArticleRepository extends CrudRepository<Article, Long> {
|
||||
|
||||
public interface ArticleRepository extends JpaRepository<Article, Long> {
|
||||
}
|
||||
|
|
|
@ -1,25 +1,20 @@
|
|||
package com.baeldung.vertxspring.service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.baeldung.vertxspring.entity.Article;
|
||||
import com.baeldung.vertxspring.repository.ArticleRepository;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
public class ArticleService {
|
||||
|
||||
@Autowired
|
||||
ArticleRepository articleRepository;
|
||||
private ArticleRepository articleRepository;
|
||||
|
||||
public List<Article> getAllArticle() {
|
||||
List<Article> articles = new ArrayList<>();
|
||||
articleRepository.findAll()
|
||||
.forEach(articles::add);
|
||||
return articles;
|
||||
return articleRepository.findAll();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue