Interface ProductRepo
- All Superinterfaces:
org.springframework.data.repository.CrudRepository<ProductEntity,,Integer> JpaRepository<ProductEntity,,Integer> org.springframework.data.repository.ListCrudRepository<ProductEntity,,Integer> org.springframework.data.repository.ListPagingAndSortingRepository<ProductEntity,,Integer> org.springframework.data.repository.PagingAndSortingRepository<ProductEntity,,Integer> org.springframework.data.repository.query.QueryByExampleExecutor<ProductEntity>,org.springframework.data.repository.Repository<ProductEntity,Integer>
- Author:
- Liang123456123
-
Method Summary
Modifier and TypeMethodDescriptionorg.springframework.data.domain.Page<ProductEntity> findByProductNameContaining(String productName, org.springframework.data.domain.Pageable pageable) org.springframework.data.domain.Page<ProductEntity> findProductsByFilter(Integer categoryId, Integer minPrice, Integer maxPrice, String productName, org.springframework.data.domain.Pageable pageable) findRecommendedProductsByTag(Integer tagId, Integer currentProductId) Methods inherited from interface org.springframework.data.repository.CrudRepository
count, delete, deleteAll, deleteAll, deleteAllById, deleteById, existsById, findById, saveMethods inherited from interface org.springframework.data.jpa.repository.JpaRepository
deleteAllByIdInBatch, deleteAllInBatch, deleteAllInBatch, deleteInBatch, findAll, findAll, flush, getById, getOne, getReferenceById, saveAllAndFlush, saveAndFlushMethods inherited from interface org.springframework.data.repository.ListCrudRepository
findAll, findAllById, saveAllMethods inherited from interface org.springframework.data.repository.ListPagingAndSortingRepository
findAllMethods inherited from interface org.springframework.data.repository.PagingAndSortingRepository
findAllMethods inherited from interface org.springframework.data.repository.query.QueryByExampleExecutor
count, exists, findAll, findBy, findOne
-
Method Details
-
findByProductNameContaining
org.springframework.data.domain.Page<ProductEntity> findByProductNameContaining(String productName, org.springframework.data.domain.Pageable pageable) -
findProductsByFilter
@Query("SELECT p FROM ProductEntity p WHERE (:categoryId IS NULL OR p.productCategory.categoryId = :categoryId) AND (:minPrice IS NULL OR p.price >= :minPrice) AND (:maxPrice IS NULL OR p.price <= :maxPrice) AND (p.status = 1 OR p.status = 2) AND (:productName IS NULL OR p.productName LIKE %:productName%)") org.springframework.data.domain.Page<ProductEntity> findProductsByFilter(@Param("categoryId") Integer categoryId, @Param("minPrice") Integer minPrice, @Param("maxPrice") Integer maxPrice, @Param("productName") String productName, org.springframework.data.domain.Pageable pageable) -
findRecommendedProductsByTag
@Query("SELECT p FROM ProductEntity p WHERE p.productTag.tagId = :tagId AND p.productID != :currentProductId AND p.status = 1 ORDER BY p.createdDate DESC LIMIT 3") List<ProductEntity> findRecommendedProductsByTag(@Param("tagId") Integer tagId, @Param("currentProductId") Integer currentProductId)
-