@@ -42,7 +42,6 @@ public class ModerationReasonService {
|
||||
throw new IllegalArgumentException("Reason text cannot be empty");
|
||||
}
|
||||
|
||||
// Проверяем на дубликат
|
||||
if (moderationReasonRepository.findByReasonText(reasonText.trim()).isPresent()) {
|
||||
throw new IllegalArgumentException("Reason with this text already exists");
|
||||
}
|
||||
@@ -70,7 +69,6 @@ public class ModerationReasonService {
|
||||
throw new IllegalArgumentException("Reason text cannot be empty");
|
||||
}
|
||||
|
||||
// Проверяем на дубликат (исключая текущую запись)
|
||||
moderationReasonRepository.findByReasonText(newReasonText.trim())
|
||||
.ifPresent(existingReason -> {
|
||||
if (!existingReason.getId().equals(reasonId)) {
|
||||
@@ -99,14 +97,13 @@ public class ModerationReasonService {
|
||||
ModerationReason reason = moderationReasonRepository.findById(reasonId)
|
||||
.orElseThrow(() -> new ModerationReasonNotFoundException(reasonId));
|
||||
|
||||
// Проверяем, используется ли причина в активных блокировках
|
||||
long usageCount = getReasonUsageCount(reasonId);
|
||||
|
||||
if (usageCount > 0) {
|
||||
throw new ModerationReasonInUseException(reasonId, usageCount);
|
||||
}
|
||||
|
||||
moderationReasonRepository.delete(reason);
|
||||
moderationReasonRepository.deleteById(reasonId);
|
||||
|
||||
log.info("Deleted moderation reason: id={}, text={}", reasonId, reason.getReasonText());
|
||||
}
|
||||
|
||||
@@ -72,7 +72,7 @@ public class ModerationService {
|
||||
fileAppealRepository.findByFileIdAndStatus(file.getId(), AppealStatus.PENDING)
|
||||
.ifPresent(appeal -> {
|
||||
appeal.setStatus(AppealStatus.REJECTED);
|
||||
appeal.setAdminComment("Апелляция отклонена в процессе модерации");
|
||||
appeal.setAdminComment(request.getComment());
|
||||
appeal.setResolvedAt(LocalDateTime.now());
|
||||
fileAppealRepository.save(appeal);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user