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