Ejemplo n.º 1
0
 /**
  * 密码修改提交页
  *
  * @param origPwd 原始密码
  * @param newPwd 新密码
  * @param email 邮箱
  * @param nextUrl 下一个页面地址
  * @param request
  * @param response
  * @param model
  * @return
  * @throws IOException
  */
 @RequestMapping(value = "/member/pwd.jspx", method = RequestMethod.POST)
 public String passwordSubmit(
     String origPwd,
     String newPwd,
     String email,
     String nextUrl,
     HttpServletRequest request,
     HttpServletResponse response,
     ModelMap model)
     throws IOException {
   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 = validatePasswordSubmit(user.getId(), origPwd, newPwd, email, request);
   if (errors.hasErrors()) {
     return FrontUtils.showError(request, response, model, errors);
   }
   cmsUserMng.updatePwdEmail(user.getId(), newPwd, email);
   return FrontUtils.showSuccess(request, model, nextUrl);
 }
Ejemplo n.º 2
0
 @RequestMapping("/comment/v_edit.do")
 public String edit(Integer id, HttpServletRequest request, ModelMap model) {
   WebErrors errors = validateEdit(id, request);
   if (errors.hasErrors()) {
     return errors.showErrorPage(model);
   }
   model.addAttribute("cmsComment", manager.findById(id));
   return "comment/edit";
 }
Ejemplo n.º 3
0
 private WebErrors validateDelete(Integer[] ids, HttpServletRequest request) {
   WebErrors errors = WebErrors.create(request);
   CmsSite site = CmsUtils.getSite(request);
   if (errors.ifEmpty(ids, "ids")) {
     return errors;
   }
   for (Integer id : ids) {
     vldExist(id, site.getId(), errors);
   }
   return errors;
 }
Ejemplo n.º 4
0
 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;
 }
Ejemplo n.º 5
0
 @RequestMapping("/site_config/o_base_update.do")
 public String baseUpdate(
     CmsSite bean, Integer uploadFtpId, HttpServletRequest request, ModelMap model) {
   WebErrors errors = validateBaseUpdate(bean, request);
   if (errors.hasErrors()) {
     return errors.showErrorPage(model);
   }
   CmsSite site = CmsUtils.getSite(request);
   bean.setId(site.getId());
   bean = manager.update(bean, uploadFtpId);
   model.addAttribute("message", "global.success");
   log.info("update CmsSite success. id={}", site.getId());
   cmsLogMng.operating(request, "cmsSiteConfig.log.updateBase", null);
   return baseEdit(request, model);
 }
Ejemplo n.º 6
0
 private WebErrors validateUpdate(Integer id, HttpServletRequest request) {
   WebErrors errors = WebErrors.create(request);
   CmsSite site = CmsUtils.getSite(request);
   if (vldExist(id, site.getId(), errors)) {
     return errors;
   }
   return errors;
 }
Ejemplo n.º 7
0
 @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);
 }
Ejemplo n.º 8
0
 @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);
 }
Ejemplo n.º 9
0
 private WebErrors validatePasswordSubmit(
     Integer id, String origPwd, String newPwd, String email, HttpServletRequest request) {
   WebErrors errors = WebErrors.create(request);
   if (errors.ifBlank(origPwd, "origPwd", 100)) {
     return errors;
   }
   if (errors.ifMaxLength(newPwd, "newPwd", 100)) {
     return errors;
   }
   if (errors.ifMaxLength(email, "email", 100)) {
     return errors;
   }
   if (!cmsUserMng.isPasswordValid(id, origPwd)) {
     errors.addErrorCode("member.origPwdInvalid");
     return errors;
   }
   return errors;
 }
Ejemplo n.º 10
0
 private WebErrors validateBaseUpdate(CmsSite bean, HttpServletRequest request) {
   WebErrors errors = WebErrors.create(request);
   return errors;
 }