30 lines
904 B
Java
30 lines
904 B
Java
package org.hso.ecommerce.repos.shop;
|
|
|
|
import org.hso.ecommerce.entities.shop.Article;
|
|
import org.hso.ecommerce.entities.user.User;
|
|
import org.springframework.data.jpa.repository.JpaRepository;
|
|
import org.springframework.data.jpa.repository.Query;
|
|
import org.springframework.data.repository.query.Param;
|
|
import org.springframework.stereotype.Repository;
|
|
|
|
import java.util.List;
|
|
import java.util.Optional;
|
|
|
|
@Repository
|
|
public interface ArticleRepository extends JpaRepository<Article, Long> {
|
|
|
|
@Query("Select a FROM Article a where a.id = :articleId")
|
|
Article findArticleById(@Param("articleId") long articleId);
|
|
|
|
|
|
@Query("SELECT a from Article a join a.related ao where ao.should_be_advertised = true")
|
|
List<Article> getAdvertisedArticles();
|
|
|
|
|
|
@Query("SELECT c FROM User c WHERE c.email = :quantity")
|
|
List<Article> getLastOrderedArticles(@Param("quantity") String quantity);
|
|
|
|
|
|
}
|
|
|