@RequestParam("ip") String ip,
@RequestParam("time") String time
) throws Exception {
Map<String, Object> params = new HashMap<>();
Template tmpl = Template.getTemplate(request);
if (!tmpl.isModeratorSession()) {
throw new AccessViolationException("Not moderator");
}
Calendar calendar = Calendar.getInstance();
calendar.setTime(new Date());
if ("hour".equals(time)) {
calendar.add(Calendar.HOUR_OF_DAY, -1);
} else if ("day".equals(time)) {
calendar.add(Calendar.DAY_OF_MONTH, -1);
} else if ("3day".equals(time)) {
calendar.add(Calendar.DAY_OF_MONTH, -3);
} else {
throw new UserErrorException("Invalid count");
}
Timestamp ts = new Timestamp(calendar.getTimeInMillis());
params.put("message", "Удаляем темы и сообщения после "+ts.toString()+" с IP "+ip+"<br>");
User moderator = tmpl.getCurrentUser();
DeleteCommentResult deleteResult = commentService.deleteCommentsByIPAddress(ip, ts, moderator, reason);
params.put("topics", deleteResult.getDeletedTopicIds().size()); // кол-во удаленных топиков
params.put("deleted", deleteResult.getDeleteInfo());