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