Skip to content

Commit 4d3d836

Browse files
committed
refactor: @query를 사용하는 JPA Repository 메서드에 @param 어노테이션 추가
1 parent fb6f19e commit 4d3d836

5 files changed

Lines changed: 12 additions & 9 deletions

File tree

storage/src/main/java/com/mangoboss/storage/attendance/AttendanceJpaRepository.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ SELECT DATE(s.workDate) AS date,
3131
GROUP BY DATE(s.workDate)
3232
ORDER BY DATE(s.workDate)
3333
""")
34-
List<WorkDotProjection> findWorkDotProjections(Long storeId, LocalDate start, LocalDate end);
34+
List<WorkDotProjection> findWorkDotProjections(@Param("storeId") Long storeId, @Param("start") LocalDate start, @Param("end") LocalDate end);
3535

3636
@Query("""
3737
SELECT f AS staff,
@@ -45,7 +45,7 @@ ORDER BY DATE(s.workDate)
4545
AND s.workDate BETWEEN :start AND :end
4646
GROUP BY f.id
4747
""")
48-
List<StaffAttendanceCountProjection> findAttendanceCountsByStoreId(Long storeId, LocalDate start, LocalDate end);
48+
List<StaffAttendanceCountProjection> findAttendanceCountsByStoreId(@Param("storeId") Long storeId, @Param("start") LocalDate start, @Param("end") LocalDate end);
4949

5050
@Query("""
5151
SELECT a FROM AttendanceEntity a

storage/src/main/java/com/mangoboss/storage/notification/DeviceTokenJpaRepository.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import org.springframework.data.jpa.repository.JpaRepository;
44
import org.springframework.data.jpa.repository.Modifying;
55
import org.springframework.data.jpa.repository.Query;
6+
import org.springframework.data.repository.query.Param;
67

78
import java.util.List;
89

@@ -14,5 +15,5 @@ public interface DeviceTokenJpaRepository extends JpaRepository<DeviceTokenEntit
1415

1516
@Modifying
1617
@Query("UPDATE DeviceTokenEntity d SET d.isDeleted = false, d.modifiedAt = CURRENT_TIMESTAMP WHERE d.userId = :userId AND d.tokenValue = :tokenValue")
17-
void updateIsDeletedFalseAndModifiedAt(Long userId, String tokenValue);
18+
void updateIsDeletedFalseAndModifiedAt(@Param("userId") Long userId, @Param("tokenValue") String tokenValue);
1819
}

storage/src/main/java/com/mangoboss/storage/payroll/PayslipJpaRepository.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,5 +31,5 @@ List<PayslipEntity> findAllByPayslipState(
3131
FROM PayslipEntity s
3232
WHERE s.id = :id AND s.payroll.staffId = :staffId
3333
""")
34-
Optional<PayslipEntity> findByIdAndStaffId(Long id, Long staffId);
34+
Optional<PayslipEntity> findByIdAndStaffId(@Param("id") Long id, @Param("staffId") Long staffId);
3535
}

storage/src/main/java/com/mangoboss/storage/schedule/RegularGroupJpaRepository.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import org.springframework.data.jpa.repository.JpaRepository;
44
import org.springframework.data.jpa.repository.Query;
5+
import org.springframework.data.repository.query.Param;
56

67
import java.time.LocalDate;
78
import java.util.List;
@@ -12,5 +13,5 @@ public interface RegularGroupJpaRepository extends JpaRepository<RegularGroupEnt
1213
FROM RegularGroupEntity r JOIN ScheduleEntity s ON r.id = s.regularGroup.id
1314
WHERE r.staff.id = :staffId AND r.endDate >= :date AND s.workDate >= :date
1415
""")
15-
List<RegularGroupEntity> findActiveOrUpcomingByStaffId(Long staffId, LocalDate date);
16+
List<RegularGroupEntity> findActiveOrUpcomingByStaffId(@Param("staffId") Long staffId, @Param("date") LocalDate date);
1617
}

storage/src/main/java/com/mangoboss/storage/schedule/ScheduleJpaRepository.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import com.mangoboss.storage.schedule.projection.ScheduleForNotificationProjection;
44
import org.springframework.data.jpa.repository.JpaRepository;
55
import org.springframework.data.jpa.repository.Query;
6+
import org.springframework.data.repository.query.Param;
67

78
import java.time.LocalDate;
89
import java.time.LocalDateTime;
@@ -16,7 +17,7 @@ public interface ScheduleJpaRepository extends JpaRepository<ScheduleEntity, Lon
1617
"WHERE f.store.id = :storeId " +
1718
"AND s.workDate = :date " +
1819
"ORDER BY s.startTime ASC ")
19-
List<ScheduleEntity> findAllByStoreIdAndWorkDate(Long storeId, LocalDate date);
20+
List<ScheduleEntity> findAllByStoreIdAndWorkDate(@Param("storeId") Long storeId, @Param("date") LocalDate date);
2021

2122
void deleteAllByRegularGroupIdAndWorkDateAfter(Long regularGroupId, LocalDate date);
2223

@@ -36,7 +37,7 @@ public interface ScheduleJpaRepository extends JpaRepository<ScheduleEntity, Lon
3637
AND (a.clockOutStatus is NULL OR a is NULL)
3738
"""
3839
)
39-
List<ScheduleForNotificationProjection> findAllSchedulesWithoutClockOut(LocalDateTime standardTime);
40+
List<ScheduleForNotificationProjection> findAllSchedulesWithoutClockOut(@Param("standardTime") LocalDateTime standardTime);
4041

4142
Boolean existsByRegularGroupId(Long regularGroupId);
4243

@@ -48,7 +49,7 @@ SELECT CASE WHEN COUNT(s) > 0 THEN TRUE ELSE FALSE END
4849
AND s.startTime <= :endTime
4950
AND s.endTime >= :startTime
5051
""")
51-
Boolean existsOverlappingSchedule(Long staffId, LocalDate workDate, LocalDateTime startTime, LocalDateTime endTime);
52+
Boolean existsOverlappingSchedule(@Param("staffId") Long staffId, @Param("workDate") LocalDate workDate, @Param("startTime") LocalDateTime startTime, @Param("endTime") LocalDateTime endTime);
5253

5354
@Query("""
5455
SELECT s AS schedule, f.name AS staffName, st.boss.id AS bossId, st.id AS storeId
@@ -64,5 +65,5 @@ AND NOT EXISTS (
6465
AND n.metaId = s.id
6566
)
6667
""")
67-
List<ScheduleForNotificationProjection> findLateSchedulesWithoutAlarm(LocalDateTime standardTime);
68+
List<ScheduleForNotificationProjection> findLateSchedulesWithoutAlarm(@Param("standardTime") LocalDateTime standardTime);
6869
}

0 commit comments

Comments
 (0)