赵士淞
2023-01-04 52eff75ed0986a6851657c080da415de7c62be6f
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/system/repository/SysUserLevelWageRepository.java
@@ -20,6 +20,7 @@
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import java.sql.Timestamp;
import java.util.List;
/**
@@ -53,4 +54,12 @@
    @Query(value = "SELECT * FROM sys_user_level_wage WHERE user_id = ?1", nativeQuery = true)
    List<SysUserLevelWage> findByUserId(Long userId);
    /**
     * 根据用户ID、指定年月查询
     * @param userId
     * @param targetDate
     * @return
     */
    @Query(value = "SELECT * FROM sys_user_level_wage WHERE user_id = ?1 AND start_date <= ?2 AND (end_date IS NULL OR end_date >= ?2) ORDER BY start_date DESC, create_time DESC LIMIT 1", nativeQuery = true)
    SysUserLevelWage findTargetYearMonth(Long userId, String targetDate);
}