完成Bean改造

This commit is contained in:
2019-05-30 21:17:08 +08:00
parent 707ee18ba0
commit 9b5d2ec4e5
39 changed files with 949 additions and 405 deletions
@@ -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);
}