private boolean vldExist(Integer id, Integer siteId, WebErrors errors) { if (errors.ifNull(id, "id")) { return true; } CmsComment entity = manager.findById(id); if (errors.ifNotExist(entity, CmsComment.class, id)) { return true; } if (!entity.getSite().getId().equals(siteId)) { errors.notInSite(CmsComment.class, id); return true; } return false; }
@RequestMapping("/comment/o_delete.do") public String delete( Integer queryContentId, Boolean queryChecked, Boolean queryRecommend, Integer[] ids, Integer pageNo, HttpServletRequest request, ModelMap model) { WebErrors errors = validateDelete(ids, request); if (errors.hasErrors()) { return errors.showErrorPage(model); } CmsComment[] beans = manager.deleteByIds(ids); for (CmsComment bean : beans) { log.info("delete CmsComment id={}", bean.getId()); cmsLogMng.operating(request, "cmsComment.log.delete", "id=" + bean.getId()); } return list(queryContentId, queryChecked, queryRecommend, pageNo, request, model); }
@RequestMapping("/comment/o_update.do") public String update( Integer queryContentId, Boolean queryChecked, Boolean queryRecommend, String reply, CmsComment bean, CmsCommentExt ext, Integer pageNo, HttpServletRequest request, ModelMap model) { WebErrors errors = validateUpdate(bean.getId(), request); if (errors.hasErrors()) { return errors.showErrorPage(model); } // 若回复内容不为空而且回复更新,则设置回复时间,已最新回复时间为准 if (StringUtils.isNotBlank(ext.getReply()) && !reply.equals(ext.getReply())) { bean.setReplayTime(new Date()); } bean = manager.update(bean, ext); log.info("update CmsComment id={}.", bean.getId()); cmsLogMng.operating(request, "cmsComment.log.update", "id=" + bean.getId()); return list(queryContentId, queryChecked, queryRecommend, pageNo, request, model); }