This commit is contained in:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user