This commit is contained in:
@@ -13,15 +13,6 @@ public class ViolationRequest {
|
||||
@JsonProperty("violation_id")
|
||||
private Long violationId;
|
||||
|
||||
@JsonProperty("page")
|
||||
private Integer page = 0;
|
||||
|
||||
@JsonProperty("size")
|
||||
private Integer size = 10;
|
||||
|
||||
@JsonProperty("sort_direction")
|
||||
private String sortDirection = "desc";
|
||||
|
||||
@JsonProperty("status")
|
||||
private String status;
|
||||
|
||||
@@ -31,9 +22,6 @@ public class ViolationRequest {
|
||||
@JsonProperty("end_date")
|
||||
private String endDate;
|
||||
|
||||
@JsonProperty("group_by")
|
||||
private String groupBy;
|
||||
|
||||
@JsonProperty("action")
|
||||
private String action;
|
||||
|
||||
@@ -42,4 +30,17 @@ public class ViolationRequest {
|
||||
|
||||
@JsonProperty("file_name")
|
||||
private String fileName = null;
|
||||
|
||||
@JsonProperty("page")
|
||||
private Integer page = 0;
|
||||
|
||||
@JsonProperty("size")
|
||||
private Integer size = 10;
|
||||
|
||||
@JsonProperty("sort_direction")
|
||||
private String sortDirection = "desc";
|
||||
|
||||
@JsonProperty("group_by")
|
||||
private String groupBy;
|
||||
|
||||
}
|
||||
@@ -4,7 +4,6 @@ import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import ru.soune.nocopy.entity.violation.Violation;
|
||||
import ru.soune.nocopy.service.geo.GeoCountryService;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
@@ -13,8 +12,6 @@ import java.util.List;
|
||||
@Builder
|
||||
public class ViolationResponse {
|
||||
|
||||
private final GeoCountryService geoCountryService;
|
||||
|
||||
@JsonProperty("violations")
|
||||
private List<ViolationDto> violations;
|
||||
|
||||
|
||||
@@ -66,6 +66,16 @@ public class ViolationHandler implements RequestHandler {
|
||||
if (violationRequest.getFileId() != null && !violationRequest.getFileId().isEmpty()) {
|
||||
FileEntity file = fileRepository.findById(violationRequest.getFileId())
|
||||
.orElseThrow(() -> new FileNotFoundException("File not found with id: " + violationRequest.getFileId()));
|
||||
|
||||
if (!Objects.equals(file.getUserId(), userId)) {
|
||||
return BaseResponse.builder()
|
||||
.messageCode(MessageCode.USER_NOT_HAD_PERMISSION.getCode())
|
||||
.messageCode(MessageCode.USER_NOT_HAD_PERMISSION.getCode())
|
||||
.msgId(request.getMsgId())
|
||||
.messageBody(Map.of("user_id", userId))
|
||||
.build();
|
||||
}
|
||||
|
||||
targetFiles = List.of(file);
|
||||
} else {
|
||||
targetFiles = fileEntityService.getAllUserFiles(userId);
|
||||
@@ -170,6 +180,8 @@ public class ViolationHandler implements RequestHandler {
|
||||
return BaseResponse.builder()
|
||||
.msgId(request.getMsgId())
|
||||
.messageBody(response)
|
||||
.messageCode(MessageCode.SUCCESS.getCode())
|
||||
.messageDesc(MessageCode.SUCCESS.getDescription())
|
||||
.build();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -37,7 +37,8 @@ public class GeoCountryService {
|
||||
try {
|
||||
CountryResponse response = extractCountry(input);
|
||||
|
||||
return response.getCountry().getName();
|
||||
return response.getCountry().getName() == null ? "Not defined":
|
||||
response.getCountry().getName();
|
||||
} catch (Exception e) {
|
||||
log.error("Failed for input: {}", input, e);
|
||||
return "UNKNOWN";
|
||||
@@ -83,7 +84,8 @@ public class GeoCountryService {
|
||||
try {
|
||||
CountryResponse response = extractCountry(input);
|
||||
|
||||
return response.getCountry().getIsoCode();
|
||||
return response.getCountry().getIsoCode() == null ? "Not defined":
|
||||
response.getCountry().getIsoCode();
|
||||
} catch (Exception e) {
|
||||
log.error("Failed for input: {}", input, e);
|
||||
return "UNKNOWN";
|
||||
|
||||
Reference in New Issue
Block a user