From eb223c2ecb302acec4adcbc0014bcdaaf10b9d8d Mon Sep 17 00:00:00 2001 From: backdev-1 Date: Wed, 22 Apr 2026 12:38:05 +0700 Subject: [PATCH] dev add new action --- .../dto/complaint/ComplaintResponse.java | 3 +++ .../nocopy/dto/complaint/LawCaseResponse.java | 3 +++ .../soune/nocopy/handler/LawCaseHandler.java | 19 ++++++++++++++++--- .../complaint/ComplaintEntityService.java | 4 +++- 4 files changed, 25 insertions(+), 4 deletions(-) diff --git a/src/main/java/ru/soune/nocopy/dto/complaint/ComplaintResponse.java b/src/main/java/ru/soune/nocopy/dto/complaint/ComplaintResponse.java index 1fe00ac..f3240a7 100644 --- a/src/main/java/ru/soune/nocopy/dto/complaint/ComplaintResponse.java +++ b/src/main/java/ru/soune/nocopy/dto/complaint/ComplaintResponse.java @@ -36,4 +36,7 @@ public class ComplaintResponse { @JsonProperty("not_moderated") private Boolean notModerated; + + @JsonProperty("file_id") + private String fileId; } diff --git a/src/main/java/ru/soune/nocopy/dto/complaint/LawCaseResponse.java b/src/main/java/ru/soune/nocopy/dto/complaint/LawCaseResponse.java index bee3ef9..1b9a1f2 100644 --- a/src/main/java/ru/soune/nocopy/dto/complaint/LawCaseResponse.java +++ b/src/main/java/ru/soune/nocopy/dto/complaint/LawCaseResponse.java @@ -49,6 +49,9 @@ public class LawCaseResponse { @JsonProperty("violation_id") private long violationId; + @JsonProperty("file_id") + private String fileId; + private List content; public static LawCaseResponse fromEntity(LawCase lawCase) { diff --git a/src/main/java/ru/soune/nocopy/handler/LawCaseHandler.java b/src/main/java/ru/soune/nocopy/handler/LawCaseHandler.java index e6e49c5..513b2fa 100644 --- a/src/main/java/ru/soune/nocopy/handler/LawCaseHandler.java +++ b/src/main/java/ru/soune/nocopy/handler/LawCaseHandler.java @@ -17,6 +17,7 @@ import ru.soune.nocopy.entity.complaint.LawCasePriority; import ru.soune.nocopy.entity.complaint.LawCaseType; import ru.soune.nocopy.entity.tokenoperation.OperationType; import ru.soune.nocopy.entity.user.User; +import ru.soune.nocopy.entity.violation.Violation; import ru.soune.nocopy.exception.NotValidFieldException; import ru.soune.nocopy.exception.TariffNotFoundException; import ru.soune.nocopy.exception.UserNotFoundException; @@ -25,8 +26,10 @@ import ru.soune.nocopy.service.complaint.LawCaseService; import ru.soune.nocopy.service.register.AuthService; import ru.soune.nocopy.service.tariff.TariffConstants; import ru.soune.nocopy.service.tariff.TariffInfoService; +import ru.soune.nocopy.service.violation.ViolationService; import java.io.IOException; +import java.util.ArrayList; import java.util.List; import java.util.Map; import java.util.stream.Collectors; @@ -46,6 +49,8 @@ public class LawCaseHandler implements RequestHandler { private final TariffInfoService tariffInfoService; + private final ViolationService violationService; + @Override public BaseResponse handle(BaseRequest request) throws Exception { @@ -84,9 +89,17 @@ public class LawCaseHandler implements RequestHandler { lawCaseRequest.getSortBy(), lawCaseRequest.getSortDir()); - List responses = lawCases.getContent().stream() - .map(LawCaseResponse::fromEntity) - .collect(Collectors.toList()); + List responses = new ArrayList<>(); + List content = lawCases.getContent(); + + for (LawCase lawCase: content) { + LawCaseResponse lawCaseResponse = LawCaseResponse.fromEntity(lawCase); + + Violation violation = violationService.getById(lawCase.getViolationId()); + if (violation != null) lawCaseResponse.setFileId(violation.getFileEntity().getId()); + + responses.add(lawCaseResponse); + } PaginatedResponse paginatedResponse = new PaginatedResponse<>( responses, diff --git a/src/main/java/ru/soune/nocopy/service/complaint/ComplaintEntityService.java b/src/main/java/ru/soune/nocopy/service/complaint/ComplaintEntityService.java index 812afbb..382f2e7 100644 --- a/src/main/java/ru/soune/nocopy/service/complaint/ComplaintEntityService.java +++ b/src/main/java/ru/soune/nocopy/service/complaint/ComplaintEntityService.java @@ -127,13 +127,15 @@ public class ComplaintEntityService { } private ComplaintResponse mapToResponse(ComplaintEntity entity) { + Violation violation = entity.getViolation(); return ComplaintResponse.builder() .id(entity.getId()) .status(entity.getStatus() != null ? entity.getStatus().name() : null) .complaintText(entity.getComplaintText()) .email(entity.getEmail()) - .violationId(entity.getViolation() != null ? entity.getViolation().getId() : null) + .violationId(violation != null ? violation.getId() : null) + .fileId(violation != null ? violation.getFileEntity().getId() : null) .createdAt(entity.getCreatedAt() != null ? entity.getCreatedAt().format(DATE_FORMATTER) : null) .updatedAt(entity.getUpdatedAt() != null ? entity.getUpdatedAt().format(DATE_FORMATTER) : null) .notModerated(entity.getNot_moderated_file() != null ? entity.getNot_moderated_file() : null)