@@ -1,5 +1,6 @@
|
||||
package ru.soune.nocopy.dto.complaint;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import ru.soune.nocopy.entity.complaint.LawCase;
|
||||
@@ -14,19 +15,40 @@ import java.util.List;
|
||||
@Builder
|
||||
public class LawCaseResponse {
|
||||
private Long id;
|
||||
|
||||
private String name;
|
||||
|
||||
private String description;
|
||||
|
||||
private BigDecimal amount;
|
||||
|
||||
private LawCasePriority priority;
|
||||
|
||||
private LawCaseType type;
|
||||
|
||||
private String lawyer;
|
||||
|
||||
@JsonProperty("created_at")
|
||||
private LocalDateTime createdAt;
|
||||
|
||||
@JsonProperty("updated_at")
|
||||
private LocalDateTime updatedAt;
|
||||
|
||||
@JsonProperty("page_number")
|
||||
private int pageNumber;
|
||||
|
||||
@JsonProperty("page_size")
|
||||
private int pageSize;
|
||||
|
||||
@JsonProperty("total_elements")
|
||||
private long totalElements;
|
||||
|
||||
@JsonProperty("total_pages")
|
||||
private int totalPages;
|
||||
|
||||
@JsonProperty("violation_id")
|
||||
private long violationId;
|
||||
|
||||
private List<LawCaseResponse> content;
|
||||
|
||||
public static LawCaseResponse fromEntity(LawCase lawCase) {
|
||||
|
||||
@@ -1,12 +1,22 @@
|
||||
package ru.soune.nocopy.dto.violation;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class ViolationNotionRequest {
|
||||
@JsonProperty("token")
|
||||
private String token;
|
||||
|
||||
@JsonProperty("action")
|
||||
private String action;
|
||||
|
||||
@JsonProperty("violation_id")
|
||||
private Long violationId;
|
||||
|
||||
@JsonProperty("notion_id")
|
||||
private Long notionId;
|
||||
|
||||
@JsonProperty("message")
|
||||
private String message;
|
||||
}
|
||||
|
||||
@@ -25,6 +25,7 @@ import java.time.format.DateTimeParseException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
|
||||
@Component
|
||||
@Slf4j
|
||||
@@ -115,11 +116,21 @@ public class ViolationHandler implements RequestHandler {
|
||||
violationRequest.getPage(), violationRequest.getSize(), violationRequest.getSortDirection()
|
||||
);
|
||||
}
|
||||
|
||||
ViolationResponse.ViolationDto firstShowViolation = null;
|
||||
List<Violation> content = violationPage.getContent();
|
||||
List<ViolationResponse.ViolationDto> violationDtos = new ArrayList<>();
|
||||
|
||||
if ("getByViolationId".equals(violationRequest.getAction())) {
|
||||
Violation violation = violationService.getById(violationRequest.getViolationId());
|
||||
if (violation != null) {
|
||||
firstShowViolation = ViolationResponse.ViolationDto.fromEntity(violation);
|
||||
violationDtos.add(firstShowViolation);
|
||||
}
|
||||
}
|
||||
|
||||
for (Violation violation : content) {
|
||||
if (firstShowViolation != null && Objects.equals(firstShowViolation.getId(), violation.getId())) continue;
|
||||
|
||||
ViolationResponse.ViolationDto violationDto = ViolationResponse.ViolationDto.fromEntity(violation);
|
||||
violationDto.setCountry(geoCountryService.getCountryName(violation.getPageUrl()));
|
||||
violationDto.setCountryCode(geoCountryService.getCountryCode(violation.getPageUrl()));
|
||||
|
||||
@@ -56,6 +56,10 @@ public class ViolationService {
|
||||
}
|
||||
}
|
||||
|
||||
public Violation getById(Long violationId) {
|
||||
return violationRepository.findById(violationId).orElse(null);
|
||||
}
|
||||
|
||||
public List<FileViolationSummaryDTO> getFileViolationsSummary(Long userId) {
|
||||
List<FileEntity> userFiles = fileEntityService.getAllUserFiles(userId);
|
||||
List<Violation> violations = violationRepository.findByFileEntityIn(userFiles);
|
||||
|
||||
Reference in New Issue
Block a user