完成Bean改造
This commit is contained in:
@@ -2,7 +2,12 @@ package net.alawn.bill.repository;
|
||||
|
||||
import net.alawn.bill.entity.po.Book;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.Modifying;
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
import org.springframework.stereotype.Repository;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Author: Alawn
|
||||
@@ -10,7 +15,13 @@ import org.springframework.stereotype.Repository;
|
||||
* @Date: Create in 11:14 2019-05-23
|
||||
*/
|
||||
|
||||
@Transactional
|
||||
@Repository
|
||||
public interface BookRepo extends JpaRepository<Book, Long> {
|
||||
|
||||
List<Book> findByUserId(long userId);
|
||||
|
||||
@Modifying
|
||||
@Query(value = "update t_bill_books set total_amount = (select sum(amount) from t_bill_items where book_id = ?1) where id = ?1",nativeQuery = true)
|
||||
void sumAmount(long bookId);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user