dev fix add count
Test Workflow / test (push) Has been cancelled

This commit is contained in:
2026-04-28 16:37:00 +07:00
parent a87567e45d
commit e5d4ec2f07
2 changed files with 64 additions and 29 deletions
@@ -118,6 +118,42 @@ public class ViolationService {
return new PageImpl<>(dtoList, pageable, violations.getTotalElements());
}
public List<FileViolationSummaryDTO> getFileViolationsSummary(Long userId) {
List<FileEntity> userFiles = fileEntityService.getAllUserFiles(userId);
List<Violation> violations = violationRepository.findByFileEntityInAndStatusNot( userFiles,
ViolationStatus.NOT_OWNER_FILE.name());
Map<String, List<Violation>> violationsByFileId = violations.stream()
.collect(Collectors.groupingBy(v -> v.getFileEntity().getId()));
List<FileViolationSummaryDTO> dtoList = violationsByFileId.entrySet().stream()
.map(entry -> {
List<Violation> fileViolations = entry.getValue();
FileEntity file = fileViolations.get(0).getFileEntity();
LocalDateTime latestDate = fileViolations.stream()
.map(Violation::getCreatedDate)
.max(LocalDateTime::compareTo)
.orElse(null);
return FileViolationSummaryDTO.builder()
.fileId(file.getId())
.supportId(file.getSupportId())
.fileName(file.getOriginalFileName())
.fileSize(file.getFileSize())
.mimeType(file.getMimeType())
.status(file.getStatus())
.createdAt(file.getCreatedAt())
.violationCount(fileViolations.size())
.latestViolationDate(latestDate)
.build();
})
.collect(Collectors.toList());
return dtoList;
}
@Transactional
public void changeStatus(ViolationStatus status, Long violationId) {
Violation violation = violationRepository.findById(violationId).orElseThrow();