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