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