敏捷工具
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

33 lines
942 B

2 years ago
  1. package com.whn.hellospring.repository;
  2. import com.whn.hellospring.model.CoffeeDO;
  3. import org.apache.ibatis.annotations.Delete;
  4. import org.springframework.data.jpa.repository.JpaRepository;
  5. import org.springframework.data.jpa.repository.Modifying;
  6. import org.springframework.data.jpa.repository.Query;
  7. import org.springframework.transaction.annotation.Transactional;
  8. import java.util.List;
  9. /**
  10. * 咖啡
  11. */
  12. public interface CoffeeRepository extends JpaRepository<CoffeeDO, Long> {
  13. /**
  14. * 获取一个订单下的所有咖啡
  15. */
  16. @Query(value = "SELECT * FROM t_coffee where order_id_fk=?1", nativeQuery = true)
  17. List<CoffeeDO> selectCoffeeListWithOrder(Long order_id_fk);
  18. /**
  19. * 删除一个订单下的咖啡
  20. */
  21. @Transactional //事务
  22. @Modifying //更新
  23. @Query(value = "delete FROM T_COFFEE where order_id_fk=?1", nativeQuery = true)
  24. int deleteCoffeeByOrderId(Long order_id_fk);
  25. }