This commit is contained in:
@@ -18,6 +18,7 @@ public enum MessageCode {
|
||||
FILE_NOT_EXIST(2, "File not exist on disk"),
|
||||
FILE_DELETE(2, "File was deleted"),
|
||||
USER_NOT_HAD_PERMISSION(2, "User not have permission for file"),
|
||||
NOT_OWNER_FILE_STATUS_VIOLATION(2, "Violation in not owner file status"),
|
||||
USER_NOT_VERIFIED(2, "User not verified"),
|
||||
LAW_CASE_NOT_FOUND(4, "Law case not found"),
|
||||
PERMISSION_NOT_FOUND(2, "Permission not found"),
|
||||
|
||||
@@ -23,6 +23,7 @@ import ru.soune.nocopy.repository.ViolationRepository;
|
||||
import ru.soune.nocopy.service.complaint.ComplaintEntityService;
|
||||
import ru.soune.nocopy.service.register.AuthService;
|
||||
import ru.soune.nocopy.service.user.UserService;
|
||||
import ru.soune.nocopy.service.violation.ViolationStatus;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
@@ -99,6 +100,11 @@ public class ComplaintEntityHandler implements RequestHandler {
|
||||
MessageCode.USER_NOT_HAD_PERMISSION.getDescription());
|
||||
}
|
||||
|
||||
if (violation.getStatus().equals(ViolationStatus.NOT_OWNER_FILE.name())) {
|
||||
return errorResponse(msgId, MessageCode.USER_NOT_HAD_PERMISSION.getCode(),
|
||||
MessageCode.USER_NOT_HAD_PERMISSION.getDescription());
|
||||
}
|
||||
|
||||
if (complaintEntityRepository.existsByViolationId(violationId)) {
|
||||
return errorResponse(msgId, MessageCode.COMPLAINT_ALREADY_EXIST.getCode(),
|
||||
MessageCode.COMPLAINT_ALREADY_EXIST.getDescription());
|
||||
|
||||
@@ -28,6 +28,7 @@ import ru.soune.nocopy.service.register.AuthService;
|
||||
import ru.soune.nocopy.service.tariff.TariffConstants;
|
||||
import ru.soune.nocopy.service.tariff.TariffInfoService;
|
||||
import ru.soune.nocopy.service.violation.ViolationService;
|
||||
import ru.soune.nocopy.service.violation.ViolationStatus;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.*;
|
||||
@@ -163,12 +164,18 @@ public class LawCaseHandler implements RequestHandler {
|
||||
private BaseResponse createLawCase(Long userId, LawCaseRequest lawCaseRequest, BaseRequest request) {
|
||||
validateRequiredParameters(lawCaseRequest, request, userId);
|
||||
Long violationId = lawCaseRequest.getViolationId();
|
||||
Violation violation = violationService.getById(violationId);
|
||||
|
||||
if (lawCaseService.lawCaseExistByViolationId(violationId)) {
|
||||
return new BaseResponse(request.getMsgId(), MessageCode.LAW_CASE_ALREADY_EXIST.getCode(),
|
||||
MessageCode.LAW_CASE_ALREADY_EXIST.getDescription(), "Law case was already exists");
|
||||
}
|
||||
|
||||
if (violation != null && violation.getStatus().equals(ViolationStatus.NOT_OWNER_FILE.name())) {
|
||||
return new BaseResponse(request.getMsgId(), MessageCode.USER_NOT_HAD_PERMISSION.getCode(),
|
||||
MessageCode.USER_NOT_HAD_PERMISSION.getDescription(), "Wrong status");
|
||||
}
|
||||
|
||||
try {
|
||||
tariffInfoService.writeOffTokens(userId, TariffConstants.LEGAL_COST, OperationType.CREATE_LEGAL_CASE);
|
||||
} catch (TariffNotFoundException e) {
|
||||
|
||||
@@ -159,8 +159,7 @@ public class ViolationHandler implements RequestHandler {
|
||||
violationRequest.getStatus(),
|
||||
violationRequest.getPage(),
|
||||
violationRequest.getSize(),
|
||||
violationRequest.getSortDirection()
|
||||
);
|
||||
violationRequest.getSortDirection());
|
||||
|
||||
ViolationResponse.ViolationDto firstShowViolation = null;
|
||||
List<Violation> content = violationPage.getContent();
|
||||
|
||||
@@ -90,9 +90,18 @@ public class ViolationService {
|
||||
cb.between(root.get("createdDate"), startDate, endDate));
|
||||
}
|
||||
|
||||
List<String> allStatuses = Arrays.asList(
|
||||
"NEW", "SHOWED", "LEGAL_IN_WORK",
|
||||
"COMPLAINT_IN_WORK", "COMPLAINT_AND_LEGAL_IN_WORK",
|
||||
"AUTHORIZED_USE"
|
||||
);
|
||||
|
||||
if (status != null && !status.isEmpty()) {
|
||||
spec = spec.and((root, query, cb) ->
|
||||
cb.equal(root.get("status"), status));
|
||||
} else {
|
||||
spec = spec.and((root, query, cb) ->
|
||||
root.get("status").in(allStatuses));
|
||||
}
|
||||
|
||||
Sort sort = Sort.by("ASC".equalsIgnoreCase(sortDirection) ?
|
||||
|
||||
Reference in New Issue
Block a user