@RequestMapping(value = "/member/jobapply_delete.jspx") public String delete( Integer[] ids, HttpServletRequest request, String nextUrl, HttpServletResponse response, ModelMap model) { CmsSite site = CmsUtils.getSite(request); CmsUser user = CmsUtils.getUser(request); FrontUtils.frontData(request, model, site); MemberConfig mcfg = site.getConfig().getMemberConfig(); // 没有开启会员功能 if (!mcfg.isMemberOn()) { return FrontUtils.showMessage(request, model, "member.memberClose"); } if (user == null) { return FrontUtils.showLogin(request, model, site); } WebErrors errors = validateDelete(ids, site, user, request); if (errors.hasErrors()) { return FrontUtils.showError(request, response, model, errors); } CmsJobApply[] arr = jobApplyMng.deleteByIds(ids); log.info("member contribute delete Content success. ids={}", StringUtils.join(arr, ",")); return FrontUtils.showSuccess(request, model, nextUrl); }
private WebErrors validateDelete( Integer[] ids, CmsSite site, CmsUser user, HttpServletRequest request) { WebErrors errors = WebErrors.create(request); if (vldOpt(errors, site, user, ids)) { return errors; } return errors; }
private boolean vldOpt(WebErrors errors, CmsSite site, CmsUser user, Integer[] ids) { for (Integer id : ids) { if (errors.ifNull(id, "id")) { return true; } CmsJobApply jobapply = jobApplyMng.findById(id); // 数据不存在 if (errors.ifNotExist(jobapply, CmsJobApply.class, id)) { return true; } // 非本用户数据 if (!jobapply.getUser().getId().equals(user.getId())) { errors.noPermission(Content.class, id); return true; } } return false; }