Merge branch 'dev' into NCBACK-35
# Conflicts: # src/main/java/ru/soune/nocopy/controller/ApiController.java # src/main/java/ru/soune/nocopy/repository/FileEntityRepository.java # src/main/java/ru/soune/nocopy/service/file/impl/FileUploadServiceImpl.java
This commit is contained in:
@@ -0,0 +1,90 @@
|
||||
package ru.soune.nocopy.service.complaint;
|
||||
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.PageRequest;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.data.domain.Sort;
|
||||
import org.springframework.stereotype.Service;
|
||||
import ru.soune.nocopy.entity.complaint.LawCase;
|
||||
import ru.soune.nocopy.entity.complaint.LawCasePriority;
|
||||
import ru.soune.nocopy.entity.complaint.LawCaseType;
|
||||
import ru.soune.nocopy.entity.user.User;
|
||||
import ru.soune.nocopy.repository.LawCaseRepository;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class LawCaseService {
|
||||
|
||||
private final LawCaseRepository lawCaseRepository;
|
||||
|
||||
public LawCase addLawCase(BigDecimal amount, String description, String name,
|
||||
LawCasePriority priority, Long violationId, User user) {
|
||||
LawCase lawCase = new LawCase();
|
||||
|
||||
BigDecimal damage = amount == null ? BigDecimal.ZERO : amount;
|
||||
|
||||
lawCase.setAmount(damage);
|
||||
lawCase.setName(name);
|
||||
lawCase.setDescription(description);
|
||||
lawCase.setPriority(priority);
|
||||
lawCase.setViolationId(violationId);
|
||||
lawCase.setUser(user);
|
||||
|
||||
return lawCaseRepository.save(lawCase);
|
||||
}
|
||||
|
||||
public LawCase getById(Long id) {
|
||||
return lawCaseRepository.findById(id).orElse(null);
|
||||
}
|
||||
|
||||
public LawCase changeStatus(Long id, LawCaseType type) {
|
||||
LawCase lawCase = lawCaseRepository.findById(id).orElse(null);
|
||||
if (lawCase == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
lawCase.setType(type);
|
||||
return lawCaseRepository.save(lawCase);
|
||||
}
|
||||
|
||||
public LawCase changePriority(Long id, LawCasePriority priority) {
|
||||
LawCase lawCase = lawCaseRepository.findById(id).orElse(null);
|
||||
if (lawCase == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
lawCase.setPriority(priority);
|
||||
return lawCaseRepository.save(lawCase);
|
||||
}
|
||||
|
||||
public LawCase changeDamage(Long id, BigDecimal damage) {
|
||||
LawCase lawCase = lawCaseRepository.findById(id).orElse(null);
|
||||
if (lawCase == null) {
|
||||
return null;
|
||||
}
|
||||
lawCase.setAmount(damage);
|
||||
return lawCaseRepository.save(lawCase);
|
||||
}
|
||||
|
||||
public Page<LawCase> getAllUserLawCases(Long userId, int pageSize, int pageNumber,
|
||||
LawCaseType lawCaseType, String lawyer,
|
||||
LawCasePriority lawCasePriority,
|
||||
Long violationId,
|
||||
String propertySort, String ascDesc) {
|
||||
Sort.Direction direction = ascDesc.equalsIgnoreCase("desc") ? Sort.Direction.DESC : Sort.Direction.ASC;
|
||||
Sort sort = Sort.by(direction, propertySort);
|
||||
Pageable pageable = PageRequest.of(pageNumber, pageSize, sort);
|
||||
|
||||
return lawCaseRepository.getUserLawCases(userId, lawCaseType, lawyer, lawCasePriority, violationId, pageable);
|
||||
}
|
||||
|
||||
public void deleteById(Long id) {
|
||||
lawCaseRepository.deleteById(id);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -3,6 +3,8 @@ package ru.soune.nocopy.service.file;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import ru.soune.nocopy.dto.file.FileEntityResponse;
|
||||
@@ -81,17 +83,61 @@ public class FileEntityService {
|
||||
for (Long uId : userRepository.findByCompanyId(user.getCompany().getId()).stream()
|
||||
.map(User::getId)
|
||||
.toList()) {
|
||||
allFiles.addAll(fileEntityRepository.findByUserIdAndStatusIn(uId,
|
||||
List.of(FileStatus.ACTIVE, FileStatus.BLOCKED, FileStatus.MODERATION)));
|
||||
allFiles.addAll(getAllUserFiles(uId, List.of(FileStatus.ACTIVE, FileStatus.BLOCKED,
|
||||
FileStatus.MODERATION)));
|
||||
}
|
||||
} else {
|
||||
allFiles = fileEntityRepository.findByUserIdAndStatusIn(userId,
|
||||
List.of(FileStatus.ACTIVE, FileStatus.BLOCKED, FileStatus.MODERATION));
|
||||
allFiles = getAllUserFiles(userId, List.of(FileStatus.ACTIVE, FileStatus.BLOCKED, FileStatus.MODERATION));
|
||||
}
|
||||
|
||||
return allFiles;
|
||||
}
|
||||
|
||||
public List<FileEntity> getAllUserFiles(Long userId, List<FileStatus> statuses) {
|
||||
User user = userRepository.findById(userId).orElseThrow();
|
||||
List<FileEntity> allFiles = new ArrayList<>();
|
||||
|
||||
if (user.getCompany() != null) {
|
||||
for (Long uId : userRepository.findByCompanyId(user.getCompany().getId()).stream()
|
||||
.map(User::getId)
|
||||
.toList()) {
|
||||
allFiles.addAll(fileEntityRepository.findByUserIdAndStatusIn(uId, statuses));
|
||||
}
|
||||
} else {
|
||||
allFiles = fileEntityRepository.findByUserIdAndStatusIn(userId, statuses);
|
||||
}
|
||||
|
||||
return allFiles;
|
||||
}
|
||||
|
||||
@Transactional(readOnly = true)
|
||||
public FileResponse getUserFiles(Long userId, Pageable pageable, int version) {
|
||||
User user = userRepository.findById(userId).orElseThrow();
|
||||
List<User> users = user.getCompany() != null ?
|
||||
userRepository.findByCompanyId(user.getCompany().getId()) : List.of(user);
|
||||
List<FileStatus> statusesForSearch = List.of(FileStatus.ACTIVE, FileStatus.BLOCKED, FileStatus.MODERATION);
|
||||
|
||||
Page<FileEntity> files = fileEntityRepository.findFiles(users.stream().map(User::getId).toList(),
|
||||
statusesForSearch, pageable);
|
||||
|
||||
Long totalSize = fileEntityRepository.sumFileSize(
|
||||
users.stream().map(User::getId).toList(),
|
||||
statusesForSearch);
|
||||
|
||||
List<FileEntityResponse> filesToResponse = files.stream()
|
||||
.map(file -> convertToResponse(file, version))
|
||||
.toList();
|
||||
|
||||
return FileResponse.builder()
|
||||
.files(filesToResponse)
|
||||
.totalCount((int) files.getTotalElements())
|
||||
.totalSize(totalSize != null ? totalSize : 0L)
|
||||
.formattedTotalSize(formatFileSize(totalSize != null ? totalSize : 0L))
|
||||
.page(pageable.getPageNumber())
|
||||
.pageSize(pageable.getPageSize())
|
||||
.build();
|
||||
}
|
||||
|
||||
@Transactional(readOnly = true)
|
||||
public FileResponse getUserFiles(Long userId, int page, int pageSize, int version) {
|
||||
User user = userRepository.findById(userId).orElseThrow();
|
||||
|
||||
@@ -25,8 +25,12 @@ public class FileStatsService {
|
||||
|
||||
private final UserRepository userRepository;
|
||||
|
||||
private final FileEntityService fileEntityService;
|
||||
|
||||
public FileInfoUserResponse getUserFileStats(Long userId) {
|
||||
List<FileEntity> userFiles = fileEntityRepository.findByUserId(userId);
|
||||
List<FileEntity> userFiles = fileEntityService.getAllUserFiles(userId, List.of(FileStatus.ACTIVE,
|
||||
FileStatus.BLOCKED, FileStatus.MODERATION));
|
||||
|
||||
return calculateStats(userFiles);
|
||||
}
|
||||
|
||||
@@ -34,32 +38,24 @@ public class FileStatsService {
|
||||
return FileInfoUserResponse.builder()
|
||||
.allFileSize(calculateTotalSize(files))
|
||||
.fileCount(calculateTotalCount(files))
|
||||
.filesCheck(calculateByStatus(files, FileStatus.CHECKED))
|
||||
.filesViolation(calculateByStatus(files, FileStatus.VIOLATION))
|
||||
// .filesCheck(calculateByStatus(files, FileStatus.CHECKED))
|
||||
// .filesViolation(calculateByStatus(files, FileStatus.VIOLATION))
|
||||
.protectedFilesCount(protectedUserFiles(files))
|
||||
|
||||
.imagesSize(calculateMediaSize(files, FileType.IMAGE))
|
||||
.imagesCount(calculateMediaCount(files, FileType.IMAGE))
|
||||
.imagesCheck(calculateMediaByStatus(files, FileType.IMAGE, FileStatus.CHECKED))
|
||||
.imagesViolations(calculateMediaByStatus(files, FileType.IMAGE, FileStatus.VIOLATION))
|
||||
.protectedImageFilesCount(protectedUserFiles(files, FileType.IMAGE))
|
||||
|
||||
.videosSize(calculateMediaSize(files, FileType.VIDEO))
|
||||
.videosCount(calculateMediaCount(files, FileType.VIDEO))
|
||||
.videosCheck(calculateMediaByStatus(files, FileType.VIDEO, FileStatus.CHECKED))
|
||||
.videosViolations(calculateMediaByStatus(files, FileType.VIDEO, FileStatus.VIOLATION))
|
||||
.protectedVideoFilesCount(protectedUserFiles(files, FileType.VIDEO))
|
||||
|
||||
.audiosSize(calculateMediaSize(files, FileType.AUDIO))
|
||||
.audiosCount(calculateMediaCount(files, FileType.AUDIO))
|
||||
.audiosCheck(calculateMediaByStatus(files, FileType.AUDIO, FileStatus.CHECKED))
|
||||
.audiosViolations(calculateMediaByStatus(files, FileType.AUDIO, FileStatus.VIOLATION))
|
||||
.protectedAudioFilesCount(protectedUserFiles(files, FileType.AUDIO))
|
||||
|
||||
.documentSize(calculateMediaSize(files, FileType.DOCUMENT))
|
||||
.documentCount(calculateMediaCount(files, FileType.DOCUMENT))
|
||||
.documentCheck(calculateMediaByStatus(files, FileType.DOCUMENT, FileStatus.CHECKED))
|
||||
.documentViolations(calculateMediaByStatus(files, FileType.DOCUMENT, FileStatus.VIOLATION))
|
||||
.protectedDocumentFilesCount(protectedUserFiles(files, FileType.DOCUMENT))
|
||||
.build();
|
||||
}
|
||||
|
||||
@@ -16,6 +16,9 @@ public interface FileUploadService {
|
||||
|
||||
UploadProgressResponse uploadChunk(String uploadId, Integer chunkNumber, MultipartFile chunkFile, Integer findSimilar);
|
||||
|
||||
UploadProgressResponse uploadPassportChunk(String uploadId, Integer chunkNumber, MultipartFile chunkFile,
|
||||
Long userId);
|
||||
|
||||
UploadProgressResponse getUploadProgress(String uploadId);
|
||||
|
||||
FileEntity completeFileProcessing(FileUploadSession session, FileStatus status);
|
||||
|
||||
@@ -0,0 +1,146 @@
|
||||
package ru.soune.nocopy.service.file;
|
||||
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
import ru.soune.nocopy.entity.file.FileEntity;
|
||||
import ru.soune.nocopy.entity.file.moderation.ModerationPassportFile;
|
||||
import ru.soune.nocopy.service.file.moderation.ModerationFileService;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.Base64;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.zip.ZipEntry;
|
||||
import java.util.zip.ZipOutputStream;
|
||||
|
||||
@Service
|
||||
@Slf4j
|
||||
@RequiredArgsConstructor
|
||||
public class ZipService {
|
||||
|
||||
private final ModerationFileService moderationFileService;
|
||||
|
||||
private static final int MAX_SIZE_MB = 20;
|
||||
|
||||
private static final int FIRST_PART = 1;
|
||||
|
||||
private static final int SECOND_PART = 2;
|
||||
|
||||
public void createAndSplitZip(Long userId, List<FileEntity> files) throws IOException {
|
||||
byte[] zipBytes = createZip(files);
|
||||
String base64String = Base64.getEncoder().encodeToString(zipBytes);
|
||||
String[] parts = splitBase64(base64String);
|
||||
saveSplitFiles(userId, parts[0], parts[1]);
|
||||
}
|
||||
|
||||
public byte[] assembleZipFromSplitFiles(Long userId) throws IOException {
|
||||
List<ModerationPassportFile> activeFiles = moderationFileService.getActiveFiles();
|
||||
|
||||
String part1Content = null;
|
||||
String part2Content = null;
|
||||
|
||||
for (ModerationPassportFile file : activeFiles) {
|
||||
Path filePath = Paths.get(file.getPath());
|
||||
String content = Files.readString(filePath);
|
||||
|
||||
if (file.getPart() == FIRST_PART) {
|
||||
part1Content = content;
|
||||
} else if (file.getPart() == SECOND_PART) {
|
||||
part2Content = content;
|
||||
}
|
||||
}
|
||||
|
||||
if (part1Content == null || part2Content == null) {
|
||||
throw new IOException("Missing part 1 or part 2 for user: " + userId);
|
||||
}
|
||||
|
||||
String base64String = mergeBase64(part1Content, part2Content);
|
||||
|
||||
return Base64.getDecoder().decode(base64String);
|
||||
}
|
||||
|
||||
private byte[] createZip(List<FileEntity> files) throws IOException {
|
||||
long totalSize = files.stream()
|
||||
.map(FileEntity::getFileSize)
|
||||
.reduce(0L, Long::sum);
|
||||
|
||||
|
||||
if (totalSize > MAX_SIZE_MB * 1024 * 1024) {
|
||||
throw new IllegalArgumentException(
|
||||
String.format("Total size %.2f MB exceeds %d MB limit",
|
||||
totalSize / (1024.0 * 1024.0), MAX_SIZE_MB)
|
||||
);
|
||||
}
|
||||
|
||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||
try (ZipOutputStream zos = new ZipOutputStream(baos)) {
|
||||
|
||||
for (FileEntity file: files) {
|
||||
String filePath = file.getFilePath();
|
||||
String fileName = file.getStoredFileName();
|
||||
|
||||
Path path = Paths.get(filePath);
|
||||
ZipEntry zipEntry = new ZipEntry(fileName);
|
||||
zos.putNextEntry(zipEntry);
|
||||
Files.copy(path, zos);
|
||||
zos.closeEntry();
|
||||
|
||||
log.info("Added file {} to ZIP", fileName);
|
||||
}
|
||||
}
|
||||
|
||||
return baos.toByteArray();
|
||||
}
|
||||
|
||||
private String[] splitBase64(String base64) {
|
||||
StringBuilder part1 = new StringBuilder();
|
||||
StringBuilder part2 = new StringBuilder();
|
||||
|
||||
for (int i = 0; i < base64.length(); i++) {
|
||||
if (i % 2 == 0) {
|
||||
part1.append(base64.charAt(i));
|
||||
} else {
|
||||
part2.append(base64.charAt(i));
|
||||
}
|
||||
}
|
||||
|
||||
return new String[]{part1.toString(), part2.toString()};
|
||||
}
|
||||
|
||||
private void saveSplitFiles(Long userId, String part1, String part2) throws IOException {
|
||||
Path userDir = Paths.get("/uploads/passport", String.valueOf(userId));
|
||||
Files.createDirectories(userDir);
|
||||
|
||||
Path file1 = userDir.resolve(userId + "___1.txt");
|
||||
Files.writeString(file1, part1);
|
||||
Path file2 = userDir.resolve(userId + "___2.txt");
|
||||
Files.writeString(file2, part2);
|
||||
Map<Integer, String> files = Map.of(FIRST_PART, file1.toString(), SECOND_PART, file2.toString());
|
||||
|
||||
moderationFileService.addFiles(userId, files);
|
||||
|
||||
log.info("Saved split files: {} and {}", file1, file2);
|
||||
}
|
||||
|
||||
private String mergeBase64(String part1, String part2) {
|
||||
StringBuilder merged = new StringBuilder();
|
||||
|
||||
int maxLength = Math.max(part1.length(), part2.length());
|
||||
|
||||
for (int i = 0; i < maxLength; i++) {
|
||||
if (i < part1.length()) {
|
||||
merged.append(part1.charAt(i));
|
||||
}
|
||||
if (i < part2.length()) {
|
||||
merged.append(part2.charAt(i));
|
||||
}
|
||||
}
|
||||
|
||||
return merged.toString();
|
||||
}
|
||||
}
|
||||
@@ -19,6 +19,7 @@ import org.springframework.web.multipart.MultipartFile;
|
||||
import ru.soune.nocopy.dto.file.UploadProgressResponse;
|
||||
import ru.soune.nocopy.entity.file.*;
|
||||
import ru.soune.nocopy.entity.notification.NotificationType;
|
||||
import ru.soune.nocopy.entity.tokenoperation.OperationType;
|
||||
import ru.soune.nocopy.exception.*;
|
||||
import ru.soune.nocopy.repository.FileEntityRepository;
|
||||
import ru.soune.nocopy.repository.FileUploadSessionRepository;
|
||||
@@ -30,7 +31,9 @@ import ru.soune.nocopy.service.file.FileEntityService;
|
||||
import ru.soune.nocopy.service.file.FileUploadService;
|
||||
import ru.soune.nocopy.service.file.cloud.CloudStorageService;
|
||||
import ru.soune.nocopy.service.tariff.TariffConstants;
|
||||
import ru.soune.nocopy.service.file.moderation.ModerationFileService;
|
||||
import ru.soune.nocopy.service.notification.NotificationService;
|
||||
import ru.soune.nocopy.service.register.AuthService;
|
||||
import ru.soune.nocopy.service.tariff.TariffInfoService;
|
||||
import ru.soune.nocopy.util.FileUtil;
|
||||
|
||||
@@ -91,6 +94,10 @@ public class FileUploadServiceImpl implements FileUploadService {
|
||||
|
||||
private final NotificationService notificationService;
|
||||
|
||||
private final AuthService authService;
|
||||
|
||||
private final ModerationFileService moderationFileService;
|
||||
|
||||
private final CloudStorageService cloudStorageService;
|
||||
|
||||
@PostConstruct
|
||||
@@ -189,35 +196,28 @@ public class FileUploadServiceImpl implements FileUploadService {
|
||||
|
||||
@Override
|
||||
public UploadProgressResponse uploadChunk(String uploadId, Integer chunkNumber,
|
||||
MultipartFile chunkFile, Integer findSimilar) {
|
||||
MultipartFile chunkFile, Integer findSimilar) {
|
||||
FileUploadSession session = sessionRepository.findById(uploadId)
|
||||
.orElseThrow(() -> new UploadSessionNotFoundException(uploadId));
|
||||
|
||||
validateSession(session);
|
||||
|
||||
if (session.getExpiresAt().isBefore(LocalDateTime.now())) {
|
||||
handleExpiredSession(session);
|
||||
throw new FileUploadException("Upload session expired");
|
||||
}
|
||||
|
||||
if (chunkNumber < 0 || chunkNumber >= session.getTotalChunks()) {
|
||||
throw new FileUploadException(
|
||||
String.format("Invalid chunk number %d. Expected number: %d",
|
||||
chunkNumber, session.getTotalChunks() - 1));
|
||||
}
|
||||
|
||||
if (chunkNumber == 0 && chunkFile.getSize() > chunkSize || chunkNumber + 1 == (session.getTotalChunks())
|
||||
&& chunkFile.getSize() > chunkSize) {
|
||||
throw new ChunkSizeExceededException(chunkFile.getSize(), chunkSize);
|
||||
}
|
||||
|
||||
if (chunkNumber > 0 && chunkNumber + 1 < session.getTotalChunks() && chunkFile.getSize() != chunkSize) {
|
||||
throw new ChunkSizeExceededException(chunkFile.getSize(), chunkSize);
|
||||
}
|
||||
validateSession(session, chunkNumber, chunkFile);
|
||||
|
||||
return processChunk(session, chunkNumber, chunkFile, findSimilar);
|
||||
}
|
||||
|
||||
@Override
|
||||
public UploadProgressResponse uploadPassportChunk(String uploadId, Integer chunkNumber, MultipartFile chunkFile,
|
||||
Long userId) {
|
||||
FileUploadSession session = sessionRepository.findById(uploadId).orElseThrow(() ->
|
||||
new UploadSessionNotFoundException(uploadId));
|
||||
|
||||
validateSession(session, chunkNumber, chunkFile);
|
||||
|
||||
UploadProgressResponse uploadProgressResponse = processChunk(session, chunkNumber, chunkFile);
|
||||
|
||||
return uploadProgressResponse;
|
||||
}
|
||||
|
||||
@Override
|
||||
public UploadProgressResponse getUploadProgress(String uploadId) {
|
||||
FileUploadSession session = sessionRepository.findById(uploadId)
|
||||
@@ -243,20 +243,23 @@ public class FileUploadServiceImpl implements FileUploadService {
|
||||
.fileExtension(session.getExtension())
|
||||
.checksum(checksum)
|
||||
.uploadSessionId(session.getUploadId())
|
||||
.protectionStatus(ProtectionStatus.PROCESSING)
|
||||
.status(status)
|
||||
.build();
|
||||
|
||||
if (status != FileStatus.TEMP) {
|
||||
fileEntity.setProtectionStatus(ProtectionStatus.PROCESSING);
|
||||
}
|
||||
|
||||
FileEntity saved = fileEntityRepository.save(fileEntity);
|
||||
|
||||
if (session.getFileType().equals("image")) {
|
||||
if (session.getFileType().equals("image") && status != FileStatus.PRIVATE) {
|
||||
Map<String, Long> hash = imageHashService.calculateHash(filePath);
|
||||
imageHashService.create(saved, hash);
|
||||
}
|
||||
|
||||
cleanupSessionFiles(session);
|
||||
|
||||
if (status != FileStatus.TEMP) {
|
||||
if (status != FileStatus.TEMP && status != FileStatus.PRIVATE) {
|
||||
FileProtector.FileInfo fileInfo = fileUtil.createFileInfo(fileEntity, session.getConvertTo());
|
||||
noCopyFileService.addFile(fileInfo);
|
||||
}
|
||||
@@ -271,7 +274,8 @@ public class FileUploadServiceImpl implements FileUploadService {
|
||||
}
|
||||
}
|
||||
|
||||
private void validateSession(FileUploadSession session) {
|
||||
private void validateSession(FileUploadSession session, Integer chunkNumber,
|
||||
MultipartFile chunkFile) {
|
||||
UploadStatus status = session.getStatus();
|
||||
|
||||
if (status == UploadStatus.FAILED) {
|
||||
@@ -298,6 +302,67 @@ public class FileUploadServiceImpl implements FileUploadService {
|
||||
session.setStatus(UploadStatus.UPLOADING);
|
||||
sessionRepository.save(session);
|
||||
}
|
||||
|
||||
if (session.getExpiresAt().isBefore(LocalDateTime.now())) {
|
||||
handleExpiredSession(session);
|
||||
throw new FileUploadException("Upload session expired");
|
||||
}
|
||||
|
||||
if (chunkNumber < 0 || chunkNumber >= session.getTotalChunks()) {
|
||||
throw new FileUploadException(
|
||||
String.format("Invalid chunk number %d. Expected number: %d",
|
||||
chunkNumber, session.getTotalChunks() - 1));
|
||||
}
|
||||
|
||||
if (chunkNumber == 0 && chunkFile.getSize() > chunkSize || chunkNumber + 1 == (session.getTotalChunks())
|
||||
&& chunkFile.getSize() > chunkSize) {
|
||||
throw new ChunkSizeExceededException(chunkFile.getSize(), chunkSize);
|
||||
}
|
||||
|
||||
if (chunkNumber > 0 && chunkNumber + 1 < session.getTotalChunks() && chunkFile.getSize() != chunkSize) {
|
||||
throw new ChunkSizeExceededException(chunkFile.getSize(), chunkSize);
|
||||
}
|
||||
}
|
||||
|
||||
private UploadProgressResponse processChunk(FileUploadSession session, Integer chunkNumber, MultipartFile chunkFile) {
|
||||
String chunkPath = null;
|
||||
|
||||
try {
|
||||
chunkPath = saveChunkWithIntegrityCheck(session, chunkNumber, chunkFile);
|
||||
|
||||
session.getChunkPaths().put(chunkNumber, chunkPath);
|
||||
session.setChunksUploaded(session.getChunksUploaded() + 1);
|
||||
session.setStatus(UploadStatus.UPLOADING);
|
||||
session.setExpiresAt(LocalDateTime.now().plusMinutes(1));
|
||||
|
||||
boolean isLastChunk = session.getChunksUploaded().equals(session.getTotalChunks());
|
||||
|
||||
if (isLastChunk) {
|
||||
String finalFilePath = assembleFileSynchronously(session);
|
||||
|
||||
session.setStatus(UploadStatus.COMPLETED);
|
||||
session.setFilePath(finalFilePath);
|
||||
|
||||
completeFileProcessingAsync(session, FileStatus.PRIVATE);
|
||||
} else {
|
||||
sessionRepository.save(session);
|
||||
}
|
||||
|
||||
return UploadProgressResponse.fromSession(session);
|
||||
} catch (Exception e) {
|
||||
if (chunkPath != null) {
|
||||
cleanupFailedChunk(chunkPath);
|
||||
}
|
||||
|
||||
log.error("Failed to process chunk {} for session {}: {}",
|
||||
chunkNumber, session.getUploadId(), e.getMessage(), e);
|
||||
|
||||
session.setStatus(UploadStatus.FAILED);
|
||||
session.setLastError(e.getMessage());
|
||||
sessionRepository.save(session);
|
||||
|
||||
throw new FileUploadException("Failed to upload chunk: " + e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
|
||||
@Autowired
|
||||
@@ -397,7 +462,7 @@ public class FileUploadServiceImpl implements FileUploadService {
|
||||
if (status != FileStatus.TEMP) {
|
||||
String fileType = session.getFileType();
|
||||
|
||||
tariffInfoService.writeOffTokens(session.getUserId(), costService.protectFileCost(fileType));
|
||||
tariffInfoService.writeOffTokens(session.getUserId(), costService.protectFileCost(fileType), OperationType.FILE_UPLOAD);
|
||||
}
|
||||
} else {
|
||||
sessionRepository.save(session);
|
||||
|
||||
@@ -0,0 +1,54 @@
|
||||
package ru.soune.nocopy.service.file.moderation;
|
||||
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
import ru.soune.nocopy.entity.file.moderation.ModerationPassportFile;
|
||||
import ru.soune.nocopy.repository.ModerationFileRepository;
|
||||
import ru.soune.nocopy.service.user.moderation.UserVerificationService;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class ModerationFileService {
|
||||
|
||||
private final ModerationFileRepository moderationFileRepository;
|
||||
|
||||
private final UserVerificationService userVerificationService;
|
||||
|
||||
public void addFiles(Long userId, Map<Integer, String> files) {
|
||||
List<ModerationPassportFile> moderationFileRepositoryByStatus =
|
||||
moderationFileRepository.findByStatus(ModerationFileStatus.ACTIVE.getName());
|
||||
|
||||
if (!moderationFileRepositoryByStatus.isEmpty()) {
|
||||
disActiveDocuments(moderationFileRepositoryByStatus);
|
||||
}
|
||||
|
||||
for (Map.Entry<Integer, String> file : files.entrySet()) {
|
||||
ModerationPassportFile moderationFile = ModerationPassportFile.builder().userId(userId)
|
||||
.path(file.getValue())
|
||||
.part(file.getKey())
|
||||
.userId(userId)
|
||||
.status(ModerationFileStatus.ACTIVE.getName())
|
||||
.build();
|
||||
|
||||
|
||||
moderationFileRepository.save(moderationFile);
|
||||
}
|
||||
|
||||
userVerificationService.initUserVerification(userId);
|
||||
}
|
||||
|
||||
public List<ModerationPassportFile> getActiveFiles() {
|
||||
return moderationFileRepository.findByStatus(ModerationFileStatus.ACTIVE.getName());
|
||||
}
|
||||
|
||||
private void disActiveDocuments(List<ModerationPassportFile> moderationFileRepositoryByStatus) {
|
||||
for (ModerationPassportFile moderationFile : moderationFileRepositoryByStatus) {
|
||||
moderationFile.setStatus(ModerationFileStatus.NOT_ACTIVE.getName());
|
||||
|
||||
moderationFileRepository.save(moderationFile);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package ru.soune.nocopy.service.file.moderation;
|
||||
|
||||
import lombok.Getter;
|
||||
|
||||
@Getter
|
||||
public enum ModerationFileStatus {
|
||||
ACTIVE("active"), NOT_ACTIVE("not_active");
|
||||
|
||||
private final String name;
|
||||
|
||||
ModerationFileStatus(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
package ru.soune.nocopy.service.geo;
|
||||
|
||||
import com.maxmind.geoip2.DatabaseReader;
|
||||
import com.maxmind.geoip2.exception.GeoIp2Exception;
|
||||
import com.maxmind.geoip2.model.CountryResponse;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.core.io.ClassPathResource;
|
||||
import org.springframework.core.io.Resource;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.InetAddress;
|
||||
|
||||
@Service
|
||||
@Slf4j
|
||||
public class GeoCountryService {
|
||||
|
||||
private final DatabaseReader dbReader;
|
||||
|
||||
public GeoCountryService() throws IOException {
|
||||
Resource resource = new ClassPathResource("geo/GeoLite2-Country.mmdb");
|
||||
this.dbReader = new DatabaseReader.Builder(resource.getInputStream()).build();
|
||||
}
|
||||
|
||||
public String getCountryName(String input) {
|
||||
try {
|
||||
CountryResponse response = extractCountry(input);
|
||||
|
||||
return response.getCountry().getName();
|
||||
} catch (Exception e) {
|
||||
log.error("Failed for input: {}", input, e);
|
||||
return "UNKNOWN";
|
||||
}
|
||||
}
|
||||
|
||||
public String getCountryCode(String input) {
|
||||
try {
|
||||
CountryResponse response = extractCountry(input);
|
||||
|
||||
return response.getCountry().getIsoCode();
|
||||
} catch (Exception e) {
|
||||
log.error("Failed for input: {}", input, e);
|
||||
return "UNKNOWN";
|
||||
}
|
||||
}
|
||||
|
||||
private CountryResponse extractCountry(String input) throws IOException, GeoIp2Exception {
|
||||
String domain = extractDomain(input);
|
||||
|
||||
InetAddress ip = InetAddress.getByName(domain);
|
||||
|
||||
return dbReader.country(ip);
|
||||
}
|
||||
|
||||
private String extractDomain(String input) {
|
||||
if (input == null || input.isEmpty()) {
|
||||
throw new IllegalArgumentException("Input is empty");
|
||||
}
|
||||
|
||||
String cleaned = input.replaceAll("^https?://", "");
|
||||
cleaned = cleaned.split("/")[0];
|
||||
cleaned = cleaned.split(":")[0];
|
||||
|
||||
return cleaned;
|
||||
}
|
||||
}
|
||||
@@ -15,6 +15,7 @@ import ru.soune.nocopy.entity.notification.NotificationMessage;
|
||||
import ru.soune.nocopy.entity.notification.NotificationType;
|
||||
import ru.soune.nocopy.entity.tarif.TariffInfo;
|
||||
import ru.soune.nocopy.entity.tarif.TariffType;
|
||||
import ru.soune.nocopy.entity.tokenoperation.OperationType;
|
||||
import ru.soune.nocopy.entity.user.User;
|
||||
import ru.soune.nocopy.exception.TariffNotFoundException;
|
||||
import ru.soune.nocopy.repository.FileMonitoringRepository;
|
||||
@@ -64,9 +65,10 @@ public class MonitoringSearchService {
|
||||
|
||||
MonitoringType monitoringType = monitoring.getMonitoringType();
|
||||
TariffDTO tariffMonitoring = tariffService.getTariffByType(TariffType.valueOf(monitoringType.name()));
|
||||
User user = userRepository.findById(monitoring.getUserId()).orElseThrow();
|
||||
|
||||
try {
|
||||
tariffInfoService.writeOffTokens(monitoring.getUserId(), tariffMonitoring.getTokens());
|
||||
tariffInfoService.writeOffTokens(monitoring.getUserId(), tariffMonitoring.getTokens(), OperationType.MONITORING);
|
||||
|
||||
boolean useYandex = searchProperties.getEngines().getOrDefault("yandex",
|
||||
new SearchProperties.EngineConfig()).isEnabled();
|
||||
@@ -88,10 +90,14 @@ public class MonitoringSearchService {
|
||||
allResults.addAll(yandexImages);
|
||||
log.info("Yandex search found {} results", yandexImages.size());
|
||||
|
||||
} catch (TimeoutException e) {
|
||||
log.warn("Yandex search timeout for monitoring file {}", monitoring.getFile().getId());
|
||||
} catch (IOException e) {
|
||||
log.error("Yandex search failed for monitoring file {}", monitoring.getFile().getId(), e);
|
||||
} catch (TimeoutException | IOException e) {
|
||||
log.error("Error processing monitoring search", e);
|
||||
monitoring.setLastRunStatus("ERROR: " + e.getMessage());
|
||||
updateNextRun(monitoring);
|
||||
|
||||
monitoringRepository.save(monitoring);
|
||||
|
||||
notificationService.addNotification(NotificationType.SEARCH_OPERATION_FAILED, user.getId());
|
||||
}
|
||||
} else {
|
||||
log.info("Yandex search is disabled by settings");
|
||||
@@ -108,10 +114,14 @@ public class MonitoringSearchService {
|
||||
allResults.addAll(googleImages);
|
||||
log.info("Google search found {} results", googleImages.size());
|
||||
|
||||
} catch (TimeoutException e) {
|
||||
log.warn("Google search timeout for monitoring file {}", monitoring.getFile().getId());
|
||||
} catch (IOException e) {
|
||||
log.error("Google search failed for monitoring file {}", monitoring.getFile().getId(), e);
|
||||
} catch (TimeoutException | IOException e) {
|
||||
log.error("Error processing monitoring search", e);
|
||||
monitoring.setLastRunStatus("ERROR: " + e.getMessage());
|
||||
updateNextRun(monitoring);
|
||||
|
||||
monitoringRepository.save(monitoring);
|
||||
|
||||
notificationService.addNotification(NotificationType.SEARCH_OPERATION_FAILED, user.getId());
|
||||
}
|
||||
} else {
|
||||
log.info("Google search is disabled by settings");
|
||||
@@ -138,7 +148,6 @@ public class MonitoringSearchService {
|
||||
}
|
||||
|
||||
} catch (TariffNotFoundException e) {
|
||||
User user = userRepository.findById(monitoring.getUserId()).orElseThrow();
|
||||
TariffInfo activeTariffInfo = user.getActiveTariffInfo();
|
||||
int currentTokens = activeTariffInfo.getTokens() + activeTariffInfo.getBoughtTokens();
|
||||
|
||||
@@ -153,7 +162,6 @@ public class MonitoringSearchService {
|
||||
notificationService.addNotification(NotificationType.TOKEN_NOT_FOUND, user.getId(),
|
||||
NotificationMessage.FILE_SEARCH.getMessageKey());
|
||||
} catch (Exception e) {
|
||||
User user = userRepository.findById(monitoring.getUserId()).orElseThrow();
|
||||
log.error("Error processing monitoring search", e);
|
||||
monitoring.setLastRunStatus("ERROR: " + e.getMessage());
|
||||
updateNextRun(monitoring);
|
||||
|
||||
@@ -17,6 +17,7 @@ import ru.soune.nocopy.repository.NotificationRepository;
|
||||
import ru.soune.nocopy.repository.UserRepository;
|
||||
import ru.soune.nocopy.service.user.UserService;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
@@ -33,15 +34,12 @@ public class NotificationService {
|
||||
|
||||
@Transactional
|
||||
public void addNotification(NotificationType notificationType, long userId, Object... args) {
|
||||
Locale locale = Locale.forLanguageTag("ru");
|
||||
|
||||
String message = messageSource.getMessage(notificationType.getMessageKey(), args, locale);
|
||||
|
||||
Notification notification = Notification.builder()
|
||||
.notificationType(notificationType)
|
||||
.createdAt(LocalDateTime.now())
|
||||
.user(userRepository.findById(userId).orElseThrow())
|
||||
.status(NotificationStatus.NEW)
|
||||
.message(message)
|
||||
.message(notificationType.getMessageKey())
|
||||
.build();
|
||||
|
||||
notificationRepository.save(notification);
|
||||
@@ -110,7 +108,24 @@ public class NotificationService {
|
||||
if (notificationIds == null || notificationIds.isEmpty()) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return notificationRepository.updateStatus(notificationIds, user, NotificationStatus.NEW,
|
||||
NotificationStatus.READIED);
|
||||
NotificationStatus.READIED, LocalDateTime.now());
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public int delete(List<Long> notificationIds) {
|
||||
if (notificationIds == null || notificationIds.isEmpty()) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int count = 0;
|
||||
|
||||
for (Long notificationId : notificationIds) {
|
||||
notificationRepository.deleteById(notificationId);
|
||||
count += 1;
|
||||
}
|
||||
|
||||
return count;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,6 +12,7 @@ import ru.soune.nocopy.entity.notification.NotificationType;
|
||||
import ru.soune.nocopy.entity.search.GlobalSearchResult;
|
||||
import ru.soune.nocopy.entity.search.GlobalSearchTask;
|
||||
import ru.soune.nocopy.entity.search.SearchStatus;
|
||||
import ru.soune.nocopy.entity.tokenoperation.OperationType;
|
||||
import ru.soune.nocopy.repository.FileEntityRepository;
|
||||
import ru.soune.nocopy.repository.GlobalSearchResultRepository;
|
||||
import ru.soune.nocopy.repository.GlobalSearchTaskRepository;
|
||||
@@ -59,7 +60,7 @@ public class GlobalSearchAsyncProcessor {
|
||||
FileEntity file = fileEntityRepository.findById(uuid)
|
||||
.orElseThrow(() -> new RuntimeException("File not found: " + uuid));
|
||||
|
||||
tariffInfoService.writeOffTokens(userId, TariffConstants.TOKEN_VALUE_FOR_SEARCH);
|
||||
tariffInfoService.writeOffTokens(userId, TariffConstants.TOKEN_VALUE_FOR_SEARCH, OperationType.GLOBAL_SEARCH);
|
||||
GlobalSearchResult result = processFile(file, taskId, userId);
|
||||
globalSearchResultRepository.save(result);
|
||||
|
||||
|
||||
@@ -0,0 +1,55 @@
|
||||
package ru.soune.nocopy.service.statistic;
|
||||
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
import ru.soune.nocopy.dto.statistic.IncomeStatisticResponse;
|
||||
import ru.soune.nocopy.repository.ReferralJpaRepository;
|
||||
import ru.soune.nocopy.util.PercentileCalculator;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
@Slf4j
|
||||
public class IncomeStatisticService {
|
||||
private final ReferralJpaRepository referralRepository;
|
||||
|
||||
private static final int PERCENTILE_5 = 5;
|
||||
|
||||
private static final int PERCENTILE_50 = 50;
|
||||
|
||||
private static final int PERCENTILE_95 = 95;
|
||||
|
||||
public IncomeStatisticResponse getIncomeStatistics() {
|
||||
Long totalIncome = referralRepository.getTotalIncome();
|
||||
Long totalAvailable = referralRepository.getTotalAvailableIncome();
|
||||
Long totalHold = referralRepository.getTotalHoldBalance();
|
||||
|
||||
List<Object[]> incomeData = referralRepository.getIncomePerUser();
|
||||
List<Long> incomeValues = extractIncomeValues(incomeData);
|
||||
|
||||
PercentileCalculator.PercentilesResult incomePercentiles =
|
||||
PercentileCalculator.calculatePercentiles(incomeValues, PERCENTILE_5, PERCENTILE_50,
|
||||
PERCENTILE_95);
|
||||
|
||||
return IncomeStatisticResponse.builder()
|
||||
.totalIncome(totalIncome != null ? totalIncome : 0L)
|
||||
.totalAvailable(totalAvailable != null ? totalAvailable : 0L)
|
||||
.totalHold(totalHold != null ? totalHold : 0L)
|
||||
.incomePerUser(new IncomeStatisticResponse.Percentiles(
|
||||
incomePercentiles.getP5() != null ? incomePercentiles.getP5() : 0L,
|
||||
incomePercentiles.getP50() != null ? incomePercentiles.getP50() : 0L,
|
||||
incomePercentiles.getP95() != null ? incomePercentiles.getP95() : 0L
|
||||
))
|
||||
.build();
|
||||
}
|
||||
|
||||
private List<Long> extractIncomeValues(List<Object[]> data) {
|
||||
return data.stream()
|
||||
.map(row -> row[1] != null ? ((Number) row[1]).longValue() : 0L)
|
||||
.filter(value -> value > 0)
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,118 @@
|
||||
package ru.soune.nocopy.service.statistic;
|
||||
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
import ru.soune.nocopy.dto.statistic.ProtectedFilesStatisticResponse;
|
||||
import ru.soune.nocopy.repository.FileEntityRepository;
|
||||
import ru.soune.nocopy.util.PercentileCalculator;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
@Slf4j
|
||||
public class ProtectedFilesStatisticService {
|
||||
private static final int PERCENTILE_5 = 5;
|
||||
|
||||
private static final int PERCENTILE_50 = 50;
|
||||
|
||||
private static final int PERCENTILE_95 = 95;
|
||||
|
||||
private static final double BYTES_TO_MB = 1048576.0;
|
||||
|
||||
private static final double BYTES_TO_GB = 1073741824.0;
|
||||
|
||||
private final FileEntityRepository fileEntityRepository;
|
||||
|
||||
public ProtectedFilesStatisticResponse getProtectedFilesStatistics() {
|
||||
List<Object[]> totalStats = fileEntityRepository.getProtectedFilesTotalStats();
|
||||
Long totalFiles = extractTotalFiles(totalStats);
|
||||
Long totalSize = extractTotalSize(totalStats);
|
||||
|
||||
List<Object[]> userStats = fileEntityRepository.getProtectedFilesPerUserStats();
|
||||
|
||||
List<Long> fileCounts = extractFileCounts(userStats);
|
||||
List<Long> fileSizes = extractFileSizes(userStats);
|
||||
|
||||
PercentileCalculator.PercentilesResult filesPercentiles =
|
||||
PercentileCalculator.calculatePercentiles(fileCounts, PERCENTILE_5, PERCENTILE_50, PERCENTILE_95);
|
||||
PercentileCalculator.PercentilesResult sizePercentiles =
|
||||
PercentileCalculator.calculatePercentiles(fileSizes, PERCENTILE_5, PERCENTILE_50, PERCENTILE_95);
|
||||
|
||||
return buildResponse(totalFiles, totalSize, filesPercentiles, sizePercentiles);
|
||||
}
|
||||
|
||||
private Long extractTotalFiles(List<Object[]> totalStats) {
|
||||
if (totalStats.isEmpty() || totalStats.get(0) == null) {
|
||||
return 0L;
|
||||
}
|
||||
Object[] row = totalStats.get(0);
|
||||
return row[0] != null ? ((Number) row[0]).longValue() : 0L;
|
||||
}
|
||||
|
||||
private Long extractTotalSize(List<Object[]> totalStats) {
|
||||
if (totalStats.isEmpty() || totalStats.get(0) == null) {
|
||||
return 0L;
|
||||
}
|
||||
Object[] row = totalStats.get(0);
|
||||
return row[1] != null ? ((Number) row[1]).longValue() : 0L;
|
||||
}
|
||||
|
||||
private List<Long> extractFileCounts(List<Object[]> userStats) {
|
||||
return userStats.stream()
|
||||
.map(row -> row[1] != null ? ((Number) row[1]).longValue() : 0L)
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
private List<Long> extractFileSizes(List<Object[]> userStats) {
|
||||
return userStats.stream()
|
||||
.map(row -> row[2] != null ? ((Number) row[2]).longValue() : 0L)
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
private ProtectedFilesStatisticResponse buildResponse(
|
||||
Long totalFiles,
|
||||
Long totalSize,
|
||||
PercentileCalculator.PercentilesResult filesPercentiles,
|
||||
PercentileCalculator.PercentilesResult sizePercentiles) {
|
||||
|
||||
ProtectedFilesStatisticResponse.Percentiles filesPerUser =
|
||||
new ProtectedFilesStatisticResponse.Percentiles(
|
||||
filesPercentiles.getP5(),
|
||||
filesPercentiles.getP50(),
|
||||
filesPercentiles.getP95());
|
||||
|
||||
ProtectedFilesStatisticResponse.SizePercentiles sizePerUser =
|
||||
new ProtectedFilesStatisticResponse.SizePercentiles(
|
||||
sizePercentiles.getP5(),
|
||||
sizePercentiles.getP50(),
|
||||
sizePercentiles.getP95(),
|
||||
convertBytesToMb(sizePercentiles.getP5()),
|
||||
convertBytesToMb(sizePercentiles.getP50()),
|
||||
convertBytesToMb(sizePercentiles.getP95()));
|
||||
|
||||
return ProtectedFilesStatisticResponse.builder()
|
||||
.totalFiles(totalFiles)
|
||||
.totalSizeBytes(totalSize)
|
||||
.totalSizeGb(convertBytesToGb(totalSize))
|
||||
.filesPerUser(filesPerUser)
|
||||
.sizePerUser(sizePerUser)
|
||||
.build();
|
||||
}
|
||||
|
||||
private Double convertBytesToMb(Long bytes) {
|
||||
if (bytes == null || bytes == 0) {
|
||||
return 0.0;
|
||||
}
|
||||
return bytes / BYTES_TO_MB;
|
||||
}
|
||||
|
||||
private Double convertBytesToGb(Long bytes) {
|
||||
if (bytes == null || bytes == 0) {
|
||||
return 0.0;
|
||||
}
|
||||
return bytes / BYTES_TO_GB;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,118 @@
|
||||
package ru.soune.nocopy.service.statistic;
|
||||
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
import ru.soune.nocopy.dto.statistic.SubscriberStatisticResponse;
|
||||
import ru.soune.nocopy.entity.tarif.TariffInfo;
|
||||
import ru.soune.nocopy.entity.tarif.TariffTimeTerm;
|
||||
import ru.soune.nocopy.entity.user.User;
|
||||
import ru.soune.nocopy.repository.TariffInfoRepository;
|
||||
import ru.soune.nocopy.repository.UserRepository;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
@Slf4j
|
||||
public class SubscriberStatisticService {
|
||||
|
||||
private final TariffInfoRepository tariffInfoRepository;
|
||||
private final UserRepository userRepository;
|
||||
|
||||
public SubscriberStatisticResponse getSubscriberStatistics() {
|
||||
return SubscriberStatisticResponse.builder()
|
||||
.monthly(buildPeriodStatistics(TariffTimeTerm.MONTHLY))
|
||||
.yearly(buildPeriodStatistics(TariffTimeTerm.YEAR))
|
||||
.build();
|
||||
}
|
||||
|
||||
private SubscriberStatisticResponse.PeriodStatistics buildPeriodStatistics(TariffTimeTerm term) {
|
||||
Long currentActive = tariffInfoRepository.getCurrentActiveSubscriptions(term);
|
||||
|
||||
List<TariffInfo> allTariffs = tariffInfoRepository.getAllTariffInfosForAnalysis(term);
|
||||
|
||||
Map<Long, List<TariffInfo>> tariffsByUser = groupTariffsByUser(allTariffs);
|
||||
|
||||
Long firstTime = countFirstTimeSubscriptions(tariffsByUser);
|
||||
Long renewals = countRenewals(tariffsByUser);
|
||||
UpDownGradeResult gradeResult = analyzeUpgradesAndDowngrades(tariffsByUser);
|
||||
|
||||
return SubscriberStatisticResponse.PeriodStatistics.builder()
|
||||
.currentActiveSubscriptions(currentActive != null ? currentActive : 0L)
|
||||
.firstTimeSubscriptions(firstTime)
|
||||
.renewals(renewals)
|
||||
.upgrades(gradeResult.upgrades)
|
||||
.downgrades(gradeResult.downgrades)
|
||||
.build();
|
||||
}
|
||||
|
||||
private Map<Long, List<TariffInfo>> groupTariffsByUser(List<TariffInfo> tariffs) {
|
||||
Map<Long, List<TariffInfo>> result = new HashMap<>();
|
||||
|
||||
for (TariffInfo ti : tariffs) {
|
||||
Optional<User> userOpt = userRepository.findByPersonalTariffInfoId(ti.getId());
|
||||
if (userOpt.isPresent()) {
|
||||
Long userId = userOpt.get().getId();
|
||||
result.computeIfAbsent(userId, k -> new ArrayList<>()).add(ti);
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
private Long countFirstTimeSubscriptions(Map<Long, List<TariffInfo>> tariffsByUser) {
|
||||
return (long) tariffsByUser.size();
|
||||
}
|
||||
|
||||
private Long countRenewals(Map<Long, List<TariffInfo>> tariffsByUser) {
|
||||
return tariffsByUser.values().stream()
|
||||
.filter(list -> list.size() > 1)
|
||||
.mapToLong(list -> list.size() - 1)
|
||||
.sum();
|
||||
}
|
||||
|
||||
private UpDownGradeResult analyzeUpgradesAndDowngrades(Map<Long, List<TariffInfo>> tariffsByUser) {
|
||||
long upgrades = 0L;
|
||||
long downgrades = 0L;
|
||||
|
||||
for (List<TariffInfo> userTariffs : tariffsByUser.values()) {
|
||||
if (userTariffs.size() < 2) {
|
||||
continue;
|
||||
}
|
||||
|
||||
userTariffs.sort(Comparator.comparing(TariffInfo::getStartTariff,
|
||||
Comparator.nullsLast(Comparator.naturalOrder())));
|
||||
|
||||
for (int i = 1; i < userTariffs.size(); i++) {
|
||||
TariffInfo previous = userTariffs.get(i - 1);
|
||||
TariffInfo current = userTariffs.get(i);
|
||||
|
||||
if (previous.getTariff() == null || current.getTariff() == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
double previousPrice = previous.getTariff().getPrice();
|
||||
double currentPrice = current.getTariff().getPrice();
|
||||
|
||||
if (currentPrice > previousPrice) {
|
||||
upgrades++;
|
||||
} else if (currentPrice < previousPrice) {
|
||||
downgrades++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return new UpDownGradeResult(upgrades, downgrades);
|
||||
}
|
||||
|
||||
private static class UpDownGradeResult {
|
||||
final Long upgrades;
|
||||
final Long downgrades;
|
||||
|
||||
UpDownGradeResult(Long upgrades, Long downgrades) {
|
||||
this.upgrades = upgrades;
|
||||
this.downgrades = downgrades;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
package ru.soune.nocopy.service.statistic;
|
||||
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
import ru.soune.nocopy.dto.statistic.TokenStatisticResponse;
|
||||
import ru.soune.nocopy.repository.PaymentRepository;
|
||||
import ru.soune.nocopy.repository.TokenOperationRepository;
|
||||
import ru.soune.nocopy.util.PercentileCalculator;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
@Slf4j
|
||||
public class TokenStatisticService {
|
||||
private final PaymentRepository paymentRepository;
|
||||
|
||||
private final TokenOperationRepository tokenOperationRepository;
|
||||
|
||||
private static final int PERCENTILE_5 = 5;
|
||||
|
||||
private static final int PERCENTILE_50 = 50;
|
||||
|
||||
private static final int PERCENTILE_95 = 95;
|
||||
|
||||
public TokenStatisticResponse getTokenStatistics() {
|
||||
Long totalBought = paymentRepository.getTotalTokensBought();
|
||||
Long totalSpent = tokenOperationRepository.getTotalTokensSpent();
|
||||
|
||||
List<Object[]> boughtData = paymentRepository.getTokensBoughtPerUser();
|
||||
List<Long> boughtValues = extractTokenValues(boughtData);
|
||||
|
||||
List<Object[]> spentData = tokenOperationRepository.getTokensSpentPerUser();
|
||||
List<Long> spentValues = extractTokenValues(spentData);
|
||||
|
||||
PercentileCalculator.PercentilesResult boughtPercentiles =
|
||||
PercentileCalculator.calculatePercentiles(boughtValues, PERCENTILE_5, PERCENTILE_50, PERCENTILE_95);
|
||||
PercentileCalculator.PercentilesResult spentPercentiles =
|
||||
PercentileCalculator.calculatePercentiles(spentValues, PERCENTILE_5, PERCENTILE_50, PERCENTILE_95);
|
||||
|
||||
return TokenStatisticResponse.builder()
|
||||
.totalBought(totalBought != null ? totalBought : 0L)
|
||||
.totalSpent(totalSpent != null ? totalSpent : 0L)
|
||||
.boughtPerUser(new TokenStatisticResponse.Percentiles(
|
||||
boughtPercentiles.getP5(),
|
||||
boughtPercentiles.getP50(),
|
||||
boughtPercentiles.getP95()
|
||||
))
|
||||
.spentPerUser(new TokenStatisticResponse.Percentiles(
|
||||
spentPercentiles.getP5(),
|
||||
spentPercentiles.getP50(),
|
||||
spentPercentiles.getP95()
|
||||
))
|
||||
.build();
|
||||
}
|
||||
|
||||
private List<Long> extractTokenValues(List<Object[]> data) {
|
||||
return data.stream()
|
||||
.map(row -> row[1] != null ? ((Number) row[1]).longValue() : 0L)
|
||||
.filter(value -> value > 0)
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
package ru.soune.nocopy.service.statistic;
|
||||
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
import ru.soune.nocopy.dto.statistic.UserDynamicStatisticResponse;
|
||||
import ru.soune.nocopy.repository.UserRepository;
|
||||
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
@Slf4j
|
||||
public class UserDynamicStatisticService {
|
||||
private final UserRepository userRepository;
|
||||
|
||||
public UserDynamicStatisticResponse getUserDynamicStatistics() {
|
||||
Long totalUsers = userRepository.getTotalUsersCount();
|
||||
Long newLast30Days = userRepository.getNewUsersCount(30);
|
||||
Long totalUpTo60Days = userRepository.getNewUsersCount(60);
|
||||
Long newPrevious30Days = totalUpTo60Days - newLast30Days;
|
||||
Double growthPercent = calculateGrowthPercent(newLast30Days, newPrevious30Days);
|
||||
Long newCurrentMonth = userRepository.getNewUsersCurrentMonth();
|
||||
Long newPreviousMonth = userRepository.getNewUsersPreviousMonth();
|
||||
|
||||
Double monthGrowthPercent = calculateGrowthPercent(newCurrentMonth, newPreviousMonth);
|
||||
|
||||
return UserDynamicStatisticResponse.builder()
|
||||
.totalUsers(totalUsers != null ? totalUsers : 0L)
|
||||
.newLast30Days(newLast30Days != null ? newLast30Days : 0L)
|
||||
.newPrevious30Days(newPrevious30Days != null ? newPrevious30Days : 0L)
|
||||
.growthPercent(growthPercent)
|
||||
.newCurrentMonth(newCurrentMonth != null ? newCurrentMonth : 0L)
|
||||
.newPreviousMonth(newPreviousMonth != null ? newPreviousMonth : 0L)
|
||||
.monthGrowthPercent(monthGrowthPercent)
|
||||
.build();
|
||||
}
|
||||
|
||||
private Double calculateGrowthPercent(Long current, Long previous) {
|
||||
if (previous == null || previous == 0) {
|
||||
return current != null && current > 0 ? 100.0 : 0.0;
|
||||
}
|
||||
|
||||
double percent = ((current - previous) * 100.0) / previous;
|
||||
|
||||
return Math.round(percent * 100.0) / 100.0;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
package ru.soune.nocopy.service.statistic;
|
||||
|
||||
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
import ru.soune.nocopy.dto.statistic.ViolationStatisticResponse;
|
||||
import ru.soune.nocopy.repository.ComplaintEntityRepository;
|
||||
import ru.soune.nocopy.repository.LawCaseRepository;
|
||||
import ru.soune.nocopy.repository.ViolationRepository;
|
||||
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
@Slf4j
|
||||
public class ViolationStatisticService {
|
||||
private final ViolationRepository violationRepository;
|
||||
|
||||
private final ComplaintEntityRepository complaintRepository;
|
||||
|
||||
private final LawCaseRepository lawCaseRepository;
|
||||
|
||||
public ViolationStatisticResponse getViolationStatistics() {
|
||||
Long totalViolations = violationRepository.getTotalViolationsCount();
|
||||
Long totalComplaints = complaintRepository.getTotalComplaintsCount();
|
||||
Long totalLawCases = lawCaseRepository.getTotalLawCasesCount();
|
||||
Long complaintsWithoutCase = complaintRepository.getComplaintsWithoutLawCaseCount();
|
||||
Long violationsWithComplaint = violationRepository.getViolationsWithComplaintCount();
|
||||
|
||||
Long violationsWithoutComplaint = totalViolations - violationsWithComplaint;
|
||||
|
||||
return ViolationStatisticResponse.builder()
|
||||
.totalViolations(totalViolations != null ? totalViolations : 0L)
|
||||
.totalComplaints(totalComplaints != null ? totalComplaints : 0L)
|
||||
.totalLawCases(totalLawCases != null ? totalLawCases : 0L)
|
||||
.complaintsWithoutCase(complaintsWithoutCase != null ? complaintsWithoutCase : 0L)
|
||||
.violationsWithComplaint(violationsWithComplaint != null ? violationsWithComplaint : 0L)
|
||||
.violationsWithoutComplaint(violationsWithoutComplaint)
|
||||
.build();
|
||||
}
|
||||
}
|
||||
@@ -18,4 +18,5 @@ public class TariffConstants {
|
||||
public static final Integer AUDIO_TOKEN_VALUE = 8;
|
||||
public static final Integer PDF_TOKEN_VALUE = 6;
|
||||
public static final Integer TOKEN_VALUE_FOR_SEARCH = 5;
|
||||
public static final Integer LEGAL_COST = 100;
|
||||
}
|
||||
|
||||
@@ -10,12 +10,14 @@ import ru.soune.nocopy.entity.tarif.Tariff;
|
||||
import ru.soune.nocopy.entity.tarif.TariffInfo;
|
||||
import ru.soune.nocopy.entity.tarif.TariffStatus;
|
||||
import ru.soune.nocopy.entity.tarif.TariffType;
|
||||
import ru.soune.nocopy.entity.tokenoperation.OperationType;
|
||||
import ru.soune.nocopy.entity.user.User;
|
||||
import ru.soune.nocopy.exception.TariffNotFoundException;
|
||||
import ru.soune.nocopy.repository.TariffInfoRepository;
|
||||
import ru.soune.nocopy.repository.TariffRepository;
|
||||
import ru.soune.nocopy.repository.UserRepository;
|
||||
import ru.soune.nocopy.service.mail.EmailService;
|
||||
import ru.soune.nocopy.service.tokenoperation.TokenOperationService;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.time.LocalDateTime;
|
||||
@@ -35,6 +37,8 @@ public class TariffInfoService {
|
||||
|
||||
private EmailService emailService;
|
||||
|
||||
private TokenOperationService tokenOperationService;
|
||||
|
||||
public TariffInfo createTariffInfo(LocalDateTime startTariff, LocalDateTime endTariff, TariffStatus tariffStatus,
|
||||
Integer tokens) {
|
||||
TariffInfo tariffInfo = new TariffInfo();
|
||||
@@ -48,7 +52,7 @@ public class TariffInfoService {
|
||||
}
|
||||
|
||||
// @Transactional
|
||||
public void writeOffTokens(long userId, Integer value) throws MessagingException, IOException {
|
||||
public void writeOffTokens(long userId, Integer value, OperationType operationType) throws MessagingException, IOException {
|
||||
User user = userRepository.findById(userId).orElseThrow();
|
||||
|
||||
TariffInfo activeTariffInfo;
|
||||
@@ -60,6 +64,8 @@ public class TariffInfoService {
|
||||
}
|
||||
|
||||
writeOffTokensForTariff(activeTariffInfo, value);
|
||||
|
||||
tokenOperationService.create(operationType, userId, Long.valueOf(value));
|
||||
}
|
||||
|
||||
public void writeOffTokensForTariff(TariffInfo activeTariffInfo, Integer value) throws MessagingException, IOException {
|
||||
|
||||
@@ -0,0 +1,122 @@
|
||||
package ru.soune.nocopy.service.tokenoperation;
|
||||
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.PageRequest;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.data.domain.Sort;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import ru.soune.nocopy.entity.tokenoperation.OperationType;
|
||||
import ru.soune.nocopy.entity.tokenoperation.TokenOperation;
|
||||
import ru.soune.nocopy.repository.TokenOperationRepository;
|
||||
|
||||
import jakarta.persistence.EntityNotFoundException;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Slf4j
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
@Transactional(readOnly = true)
|
||||
public class TokenOperationService {
|
||||
|
||||
private final TokenOperationRepository repository;
|
||||
|
||||
@Transactional
|
||||
public TokenOperation create(OperationType operationType, Long userId, Long spent) {
|
||||
TokenOperation tokenOperation = new TokenOperation();
|
||||
|
||||
tokenOperation.setOperationType(operationType);
|
||||
tokenOperation.setUserId(userId);
|
||||
tokenOperation.setSpent(spent);
|
||||
tokenOperation.setCreatedAt(LocalDateTime.now());
|
||||
|
||||
return repository.save(tokenOperation);
|
||||
}
|
||||
|
||||
public TokenOperation findById(Long id) {
|
||||
log.debug("Finding token operation by id: {}", id);
|
||||
return repository.findById(id)
|
||||
.orElseThrow(() -> new EntityNotFoundException("TokenOperation not found with id: " + id));
|
||||
}
|
||||
|
||||
public Page<TokenOperation> findAll(int page, int size, String sortBy, String direction) {
|
||||
log.debug("Finding all operations with pagination: page={}, size={}, sortBy={}, dir={}",
|
||||
page, size, sortBy, direction);
|
||||
|
||||
Sort sort = direction.equalsIgnoreCase("desc")
|
||||
? Sort.by(sortBy).descending()
|
||||
: Sort.by(sortBy).ascending();
|
||||
|
||||
Pageable pageable = PageRequest.of(page, size, sort);
|
||||
return repository.findAll(pageable);
|
||||
}
|
||||
|
||||
public Page<TokenOperation> findByFilters(
|
||||
Long userId,
|
||||
OperationType operationType,
|
||||
Long minSpent,
|
||||
Long maxSpent,
|
||||
int page,
|
||||
int size,
|
||||
String sortBy,
|
||||
String direction) {
|
||||
|
||||
log.debug("Finding by filters: userId={}, type={}, minSpent={}, maxSpent={}",
|
||||
userId, operationType, minSpent, maxSpent);
|
||||
|
||||
Sort sort = Sort.by(Sort.Direction.fromString(direction), sortBy);
|
||||
Pageable pageable = PageRequest.of(page, size, sort);
|
||||
|
||||
return repository.findByFilters(userId, operationType, minSpent, maxSpent, pageable);
|
||||
}
|
||||
|
||||
public Page<TokenOperation> findByUserId(Long userId, int page, int size) {
|
||||
log.debug("Finding operations for user id: {}", userId);
|
||||
Pageable pageable = PageRequest.of(page, size, Sort.by("id").descending());
|
||||
return repository.findByUserId(userId, pageable);
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public TokenOperation update(Long id, TokenOperation updatedOperation) {
|
||||
log.info("Updating token operation with id: {}", id);
|
||||
|
||||
TokenOperation existing = findById(id);
|
||||
|
||||
existing.setOperationType(updatedOperation.getOperationType());
|
||||
existing.setUserId(updatedOperation.getUserId());
|
||||
existing.setSpent(updatedOperation.getSpent());
|
||||
|
||||
return repository.save(existing);
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public void deleteById(Long id) {
|
||||
log.info("Deleting token operation with id: {}", id);
|
||||
|
||||
if (!repository.existsById(id)) {
|
||||
throw new EntityNotFoundException("TokenOperation not found with id: " + id);
|
||||
}
|
||||
repository.deleteById(id);
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public void deleteByUserId(Long userId) {
|
||||
log.warn("Deleting all operations for user id: {}", userId);
|
||||
List<TokenOperation> userOps = repository.findByUserId(userId);
|
||||
repository.deleteAll(userOps);
|
||||
}
|
||||
|
||||
public Long getTotalSpentByUserAndType(Long userId, OperationType type) {
|
||||
Long sum = repository.sumSpentByUserAndType(userId, type);
|
||||
return sum != null ? sum : 0L;
|
||||
}
|
||||
|
||||
public Long countByUserId(Long userId) {
|
||||
return repository.countByUserId(userId);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
package ru.soune.nocopy.service.user.moderation;
|
||||
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
import ru.soune.nocopy.entity.user.ModerationStatus;
|
||||
import ru.soune.nocopy.entity.user.User;
|
||||
import ru.soune.nocopy.entity.user.moderation.UserVerification;
|
||||
import ru.soune.nocopy.repository.UserRepository;
|
||||
import ru.soune.nocopy.repository.UserVerificationRepository;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class UserVerificationService {
|
||||
|
||||
private final UserRepository userRepository;
|
||||
|
||||
private final UserVerificationRepository userVerificationRepository;
|
||||
|
||||
public void initUserVerification(Long userId) {
|
||||
User user = userRepository.findById(userId).orElse(null);
|
||||
|
||||
if (user == null) return;
|
||||
|
||||
UserVerification userVerification = UserVerification.builder()
|
||||
.moderationStatus(ModerationStatus.VERIFICATION_IN_PROGRESS)
|
||||
.userId(user.getId())
|
||||
.createdAt(LocalDateTime.now())
|
||||
.build();
|
||||
|
||||
user.setVerificationStatus(ModerationStatus.VERIFICATION_IN_PROGRESS);
|
||||
|
||||
userRepository.save(user);
|
||||
|
||||
userVerificationRepository.save(userVerification);
|
||||
}
|
||||
|
||||
public UserVerification verifyUser(Long userId, String message, Long adminId, boolean verified) {
|
||||
User user = userRepository.findById(userId).orElse(null);
|
||||
|
||||
if (user == null) return null;
|
||||
|
||||
UserVerification userVerification = userVerificationRepository.findById(userId).orElse(null);
|
||||
|
||||
if (userVerification == null) return null;
|
||||
|
||||
ModerationStatus moderationStatus = verified ? ModerationStatus.VERIFIED: ModerationStatus.VERIFICATION_FAILED;
|
||||
|
||||
userVerification.setModerationStatus(moderationStatus);
|
||||
|
||||
if (message != null) userVerification.setMessage(message);
|
||||
|
||||
userVerification.setAdminId(adminId);
|
||||
|
||||
UserVerification save = userVerificationRepository.save(userVerification);
|
||||
|
||||
user.setVerificationStatus(moderationStatus);
|
||||
|
||||
userRepository.save(user);
|
||||
|
||||
return save;
|
||||
}
|
||||
|
||||
public List<UserVerification> verifications() {
|
||||
return userVerificationRepository.findAll();
|
||||
}
|
||||
}
|
||||
@@ -191,7 +191,6 @@ public class ViolationService {
|
||||
}
|
||||
|
||||
Set<String> inProgressStatuses = Set.of(
|
||||
ViolationStatus.SHOWED.name(),
|
||||
ViolationStatus.LEGAL_IN_WORK.name(),
|
||||
ViolationStatus.COMPLAINT_IN_WORK.name(),
|
||||
ViolationStatus.COMPLAINT_AND_LEGAL_IN_WORK.name()
|
||||
|
||||
Reference in New Issue
Block a user