| | |
| | | import me.zhengjie.modules.salary.domain.Salary; |
| | | import org.springframework.data.jpa.repository.JpaRepository; |
| | | import org.springframework.data.jpa.repository.JpaSpecificationExecutor; |
| | | import org.springframework.data.jpa.repository.Modifying; |
| | | import org.springframework.data.jpa.repository.Query; |
| | | |
| | | import java.sql.Timestamp; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * @website https://eladmin.vip |
| | |
| | | * @date 2023-01-03 |
| | | **/ |
| | | public interface SalaryRepository extends JpaRepository<Salary, Long>, JpaSpecificationExecutor<Salary> { |
| | | |
| | | /** |
| | | * 根据用户ID和工资年月查询 |
| | | * @param userId |
| | | * @param salaryYearMonth |
| | | * @return |
| | | */ |
| | | List<Salary> findByUserIdAndSalaryYearMonth(Long userId, Timestamp salaryYearMonth); |
| | | |
| | | /** |
| | | * 根据用户ID和工资年月删除 |
| | | * @param userId |
| | | * @param salaryYearMonth |
| | | */ |
| | | @Modifying |
| | | @Query(value = "DELETE FROM salary WHERE user_id = ?1 AND salary_year_month LIKE CONCAT(?2, '%')",nativeQuery = true) |
| | | void deleteByUserIdAndSalaryYearMonth(Long userId, String salaryYearMonth); |
| | | |
| | | /** |
| | | * 查询 |
| | | * @param userId |
| | | * @param salaryYearMonth |
| | | */ |
| | | @Query(value = "SELECT * FROM salary WHERE user_id = ?1 AND salary_year_month LIKE CONCAT(?2, '%')",nativeQuery = true) |
| | | List<Salary> findByUserIdAndYearMonth(Long userId, String salaryYearMonth); |
| | | } |