This commit is contained in:
@@ -90,14 +90,20 @@ public class ComplaintEntityHandler implements RequestHandler {
|
||||
"violation_id is required");
|
||||
if (req.getComplaintText() == null) return errorResponse(msgId, MessageCode.NOT_FOUND.getCode(),
|
||||
"text is required");
|
||||
Long violationId = req.getViolationId();
|
||||
|
||||
Violation violation = violationRepository.findById(req.getViolationId()).orElse(null);
|
||||
Violation violation = violationRepository.findById(violationId).orElse(null);
|
||||
|
||||
if (violation == null || !Objects.equals(violation.getFileEntity().getUserId(), userId)) {
|
||||
return errorResponse(msgId, MessageCode.USER_NOT_HAD_PERMISSION.getCode(),
|
||||
MessageCode.USER_NOT_HAD_PERMISSION.getDescription());
|
||||
}
|
||||
|
||||
if (violationRepository.existsViolation(violationId)) {
|
||||
return errorResponse(msgId, MessageCode.COMPLAINT_ALREADY_EXIST.getCode(),
|
||||
MessageCode.COMPLAINT_ALREADY_EXIST.getDescription());
|
||||
}
|
||||
|
||||
ComplaintResponse response = complaintService.createComplaint(req);
|
||||
|
||||
return successResponse(msgId, "Complaint created successfully", response);
|
||||
|
||||
@@ -162,6 +162,12 @@ public class LawCaseHandler implements RequestHandler {
|
||||
|
||||
private BaseResponse createLawCase(Long userId, LawCaseRequest lawCaseRequest, BaseRequest request) {
|
||||
validateRequiredParameters(lawCaseRequest, request, userId);
|
||||
Long violationId = lawCaseRequest.getViolationId();
|
||||
|
||||
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");
|
||||
}
|
||||
|
||||
try {
|
||||
tariffInfoService.writeOffTokens(userId, TariffConstants.LEGAL_COST, OperationType.CREATE_LEGAL_CASE);
|
||||
@@ -175,7 +181,6 @@ public class LawCaseHandler implements RequestHandler {
|
||||
}
|
||||
|
||||
User user = userRepository.findById(userId).orElseThrow(() -> new UserNotFoundException("User not found"));
|
||||
Long violationId = lawCaseRequest.getViolationId();
|
||||
|
||||
LawCase lawCase = lawCaseService.addLawCase(
|
||||
lawCaseRequest.getAmount(),
|
||||
|
||||
Reference in New Issue
Block a user