@@ -24,9 +24,9 @@ public class LawCaseRequest {
|
|||||||
private String sortBy = "updatedAt";
|
private String sortBy = "updatedAt";
|
||||||
private String sortDir = "desc";
|
private String sortDir = "desc";
|
||||||
private String action;
|
private String action;
|
||||||
private LawCaseType filterType;
|
private String filterType;
|
||||||
private String filterLawyer;
|
private String filterLawyer;
|
||||||
private LawCasePriority filterPriority;
|
private String filterPriority;
|
||||||
@JsonProperty("violation_id")
|
@JsonProperty("violation_id")
|
||||||
private Long violationId;
|
private Long violationId;
|
||||||
|
|
||||||
|
|||||||
@@ -52,7 +52,6 @@ public class LawCaseHandler implements RequestHandler {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BaseResponse handle(BaseRequest request) throws Exception {
|
public BaseResponse handle(BaseRequest request) throws Exception {
|
||||||
|
|
||||||
LawCaseRequest lawCaseRequest = objectMapper.convertValue(request.getMessageBody(),
|
LawCaseRequest lawCaseRequest = objectMapper.convertValue(request.getMessageBody(),
|
||||||
LawCaseRequest.class);
|
LawCaseRequest.class);
|
||||||
Long userId = authService.useUserAuthToken(lawCaseRequest.getToken());
|
Long userId = authService.useUserAuthToken(lawCaseRequest.getToken());
|
||||||
@@ -83,9 +82,9 @@ public class LawCaseHandler implements RequestHandler {
|
|||||||
userId,
|
userId,
|
||||||
lawCaseRequest.getPageSize(),
|
lawCaseRequest.getPageSize(),
|
||||||
lawCaseRequest.getPageNumber(),
|
lawCaseRequest.getPageNumber(),
|
||||||
lawCaseRequest.getFilterType(),
|
LawCaseType.valueOf(lawCaseRequest.getFilterType().toUpperCase()),
|
||||||
lawCaseRequest.getFilterLawyer(),
|
lawCaseRequest.getFilterLawyer(),
|
||||||
lawCaseRequest.getFilterPriority(),
|
LawCasePriority.valueOf(lawCaseRequest.getFilterPriority().toUpperCase()),
|
||||||
lawCaseRequest.getViolationId(),
|
lawCaseRequest.getViolationId(),
|
||||||
lawCaseRequest.getSortBy(),
|
lawCaseRequest.getSortBy(),
|
||||||
lawCaseRequest.getSortDir());
|
lawCaseRequest.getSortDir());
|
||||||
@@ -116,43 +115,10 @@ public class LawCaseHandler implements RequestHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void validateLawCaseRequestFilters(LawCaseRequest lawCaseRequest) {
|
private void validateLawCaseRequestFilters(LawCaseRequest lawCaseRequest) {
|
||||||
// if (lawCaseRequest.getFilterType() != null && !lawCaseRequest.getFilterType().getName().isEmpty()) {
|
if (lawCaseRequest.getFilterPriority() != null && !lawCaseRequest.getFilterPriority().equals(LawCasePriority.HIGH.name()) &&
|
||||||
// boolean isValidType = Arrays.stream(LawCaseType.values())
|
!lawCaseRequest.getFilterPriority().equals(LawCasePriority.MIDDLE.name()) &&
|
||||||
// .anyMatch(type -> type.getName().equalsIgnoreCase(lawCaseRequest.getFilterType().name()));
|
!lawCaseRequest.getFilterPriority().equals(LawCasePriority.LOW.name()) &&
|
||||||
//
|
!lawCaseRequest.getFilterPriority().equals(LawCasePriority.CRITICAL.name())) {
|
||||||
// if (!isValidType) {
|
|
||||||
// throw new NotValidFieldException("Not valid filter type",
|
|
||||||
// new BaseResponse(null, MessageCode.NOT_VALID_FIELD.getCode(),
|
|
||||||
// MessageCode.NOT_VALID_FIELD.getDescription(),
|
|
||||||
// Map.of("field", "filterType",
|
|
||||||
// "valid_values", Arrays.stream(LawCaseType.values())
|
|
||||||
// .map(LawCaseType::getName)
|
|
||||||
// .collect(Collectors.toList()),
|
|
||||||
// "received_value", lawCaseRequest.getFilterType())));
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// if (lawCaseRequest.getFilterPriority() != null && !lawCaseRequest.getFilterPriority().name().isEmpty()) {
|
|
||||||
// boolean isValidPriority = Arrays.stream(LawCasePriority.values())
|
|
||||||
// .anyMatch(priority ->
|
|
||||||
// priority.name().equalsIgnoreCase(lawCaseRequest.getFilterPriority().name()));
|
|
||||||
//
|
|
||||||
// if (!isValidPriority) {
|
|
||||||
// throw new NotValidFieldException("Not valid filter priority",
|
|
||||||
// new BaseResponse(null, MessageCode.NOT_VALID_FIELD.getCode(),
|
|
||||||
// MessageCode.NOT_VALID_FIELD.getDescription(),
|
|
||||||
// Map.of("field", "filterPriority",
|
|
||||||
// "valid_values", Arrays.stream(LawCasePriority.values())
|
|
||||||
// .map(LawCasePriority::name)
|
|
||||||
// .collect(Collectors.toList()),
|
|
||||||
// "received_value", lawCaseRequest.getFilterPriority())));
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
if (lawCaseRequest.getFilterPriority() != null && lawCaseRequest.getFilterPriority() != LawCasePriority.HIGH &&
|
|
||||||
lawCaseRequest.getFilterPriority() != LawCasePriority.MIDDLE &&
|
|
||||||
lawCaseRequest.getFilterPriority() != LawCasePriority.LOW &&
|
|
||||||
lawCaseRequest.getFilterPriority() != LawCasePriority.CRITICAL) {
|
|
||||||
|
|
||||||
throw new NotValidFieldException("Not valid filter priority",
|
throw new NotValidFieldException("Not valid filter priority",
|
||||||
new BaseResponse(null, MessageCode.NOT_VALID_FIELD.getCode(),
|
new BaseResponse(null, MessageCode.NOT_VALID_FIELD.getCode(),
|
||||||
@@ -164,8 +130,9 @@ public class LawCaseHandler implements RequestHandler {
|
|||||||
"received_value", lawCaseRequest.getFilterPriority())));
|
"received_value", lawCaseRequest.getFilterPriority())));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (lawCaseRequest.getFilterType() != null && lawCaseRequest.getFilterType() != LawCaseType.CLOSED &&
|
if (lawCaseRequest.getFilterType() != null && !lawCaseRequest.getFilterType().equals(LawCaseType.CLOSED.getName()) &&
|
||||||
lawCaseRequest.getFilterType() != LawCaseType.ACTIVE && lawCaseRequest.getFilterType() != LawCaseType.COMPLETED) {
|
!lawCaseRequest.getFilterType().equals(LawCaseType.ACTIVE.getName()) &&
|
||||||
|
!lawCaseRequest.getFilterType().equals(LawCaseType.COMPLETED.getName())) {
|
||||||
throw new NotValidFieldException("Not valid filter type",
|
throw new NotValidFieldException("Not valid filter type",
|
||||||
new BaseResponse(null, MessageCode.NOT_VALID_FIELD.getCode(),
|
new BaseResponse(null, MessageCode.NOT_VALID_FIELD.getCode(),
|
||||||
MessageCode.NOT_VALID_FIELD.getDescription(),
|
MessageCode.NOT_VALID_FIELD.getDescription(),
|
||||||
|
|||||||
Reference in New Issue
Block a user