fix: DispatchHistoryRepository 쿼리 메소드 누락 수정 및 ReportService 알림 발행 통일
This commit is contained in:
@@ -17,6 +17,8 @@ public interface DispatchHistoryRepository extends JpaRepository<DispatchHistory
|
||||
|
||||
List<DispatchHistory> findByEndDateIsNull();
|
||||
|
||||
List<DispatchHistory> findByEmployee_EmpIdAndEndDateIsNull(Long empId);
|
||||
|
||||
@Query("SELECT DISTINCT dh.employee FROM DispatchHistory dh WHERE dh.individualTech LIKE %:keyword%")
|
||||
List<Employee> findEmployeesByIndividualTechContaining(@Param("keyword") String keyword);
|
||||
|
||||
|
||||
@@ -47,6 +47,7 @@ public class ReportService {
|
||||
private final TicketRepository ticketRepository;
|
||||
private final NotificationRepository notificationRepository;
|
||||
private final WeeklyPlanRepository weeklyPlanRepository;
|
||||
private final com.srsystem.listener.NotificationPublisher notificationPublisher;
|
||||
|
||||
public Page<WorkReportResponse> getReports(ReportStatus status, String type, LocalDate targetDate, Long userId, Pageable pageable) {
|
||||
Page<Report> reports;
|
||||
@@ -159,7 +160,7 @@ public class ReportService {
|
||||
|
||||
Report updated = reportRepository.save(report);
|
||||
|
||||
// Send notification for approval or rejection
|
||||
// Send notification for approval or rejection via NotificationPublisher
|
||||
if (request.status() == ReportStatus.REJECTED || request.status() == ReportStatus.APPROVED) {
|
||||
String type = request.status() == ReportStatus.APPROVED ? "REPORT_APPROVED" : "REPORT_REJECTED";
|
||||
String title = request.status() == ReportStatus.APPROVED ? "업무 보고서 승인 완료" : "업무 보고서 반려 안내";
|
||||
@@ -167,15 +168,13 @@ public class ReportService {
|
||||
? String.format("%s 일자 보고서가 승인되었습니다.", report.getTargetDate())
|
||||
: String.format("%s 일자 보고서가 반려되었습니다. 사유: %s", report.getTargetDate(), request.reviewComment());
|
||||
|
||||
Notification notification = Notification.builder()
|
||||
.user(report.getUser())
|
||||
.type(type)
|
||||
.title(title)
|
||||
.message(message)
|
||||
.linkUrl("/work-reports")
|
||||
.isRead('N')
|
||||
.build();
|
||||
notificationRepository.save(notification);
|
||||
notificationPublisher.publish(new com.srsystem.dto.NotificationEvent(
|
||||
type,
|
||||
title,
|
||||
message,
|
||||
"/work-reports",
|
||||
report.getUser().getEmpId()
|
||||
));
|
||||
}
|
||||
|
||||
return toWorkReportResponse(updated);
|
||||
|
||||
Reference in New Issue
Block a user