dev add new action
Test Workflow / test (push) Has been cancelled

This commit is contained in:
2026-04-22 12:38:05 +07:00
parent bb96e3ac93
commit eb223c2ecb
4 changed files with 25 additions and 4 deletions
@@ -36,4 +36,7 @@ public class ComplaintResponse {
@JsonProperty("not_moderated")
private Boolean notModerated;
@JsonProperty("file_id")
private String fileId;
}
@@ -49,6 +49,9 @@ public class LawCaseResponse {
@JsonProperty("violation_id")
private long violationId;
@JsonProperty("file_id")
private String fileId;
private List<LawCaseResponse> content;
public static LawCaseResponse fromEntity(LawCase lawCase) {
@@ -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<LawCaseResponse> responses = lawCases.getContent().stream()
.map(LawCaseResponse::fromEntity)
.collect(Collectors.toList());
List<LawCaseResponse> responses = new ArrayList<>();
List<LawCase> 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<LawCaseResponse> paginatedResponse = new PaginatedResponse<>(
responses,
@@ -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)