This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
package ru.soune.nocopy.service.statistic;
|
||||
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
import ru.soune.nocopy.dto.statistic.ComplaintStatisticResponse;
|
||||
import ru.soune.nocopy.entity.complaint.ComplaintStatus;
|
||||
import ru.soune.nocopy.repository.ComplaintEntityRepository;
|
||||
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class ComplaintStatisticService {
|
||||
|
||||
private final ComplaintEntityRepository complaintEntityRepository;
|
||||
|
||||
public ComplaintStatisticResponse complaintStatistic() {
|
||||
|
||||
return ComplaintStatisticResponse.builder()
|
||||
.totalComplaints(complaintEntityRepository.getTotalComplaintsCount())
|
||||
.totalCancelled(complaintEntityRepository.getTotalComplaintsCountByStatus(ComplaintStatus.CANCELLED.name()))
|
||||
.totalCreated(complaintEntityRepository.getTotalComplaintsCountByStatus(ComplaintStatus.CREATED.name()))
|
||||
.totalCompleted(complaintEntityRepository.getTotalComplaintsCountByStatus(ComplaintStatus.COMPLETED.name()))
|
||||
.totalInWork(complaintEntityRepository.getTotalComplaintsCountByStatus(ComplaintStatus.IN_WORK.name()))
|
||||
.build();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user