Пример #1
1
  private void validateEmail(SysUser user, Errors errors) {

    // 修改且已邮件未变更,则不进行验证
    if (user.getId() != null) {
      SysUser di = userDao.findOne(user.getId());
      if (di != null && StringUtils.equals(di.getEmail(), user.getEmail())) {
        return;
      }
    }

    ValidationUtils.rejectIfEmptyOrWhitespace(errors, "email", null, "请输入邮箱地址");
    if (!errors.hasFieldErrors("email")) {
      Matcher matcher = emailPattern.matcher(user.getEmail());
      if (!matcher.matches()) {
        errors.rejectValue("email", null, "邮箱格式不正确");
      } else if (user.getEmail().length() > 50) {
        errors.rejectValue("email", null, "邮箱地址长度必须小于等于50位");
      } else {
        if (user.getId() != null) {
          SysUser obj = userDao.findByIdNotAndEmail(user.getId(), user.getEmail());
          if (obj != null) {
            errors.rejectValue("email", null, "邮箱地址已被使用");
          }
        } else {
          SysUser obj = userDao.findByEmail(user.getEmail());
          if (obj != null) {
            errors.rejectValue("email", null, "邮箱地址已被使用");
          }
        }
      }
    }
  }
Пример #2
0
  @RequestMapping(value = "/audit", method = RequestMethod.GET)
  public String audit(Long id, Model model) {
    SysAnnouncement sysAnnouncement = sysAnnouncementDao.findOne(id);
    model.addAttribute("sysAnnouncement", sysAnnouncement);
    model.addAttribute("destMap", SysAnnouncement.DEST_MAP);
    model.addAttribute("statusMap", SysAnnouncement.STATUS_MAP);

    if (sysAnnouncement.getPubUser() != null) {
      model.addAttribute("pubUser", userDao.findOne(sysAnnouncement.getPubUser()));
    }

    if (sysAnnouncement.getAuditUser() != null) {
      model.addAttribute("auditUser", userDao.findOne(sysAnnouncement.getAuditUser()));
    }
    SysFileImg advise =
        sysAnnouncementService.findImg(sysAnnouncement.getId(), BsFileService.ADVISE_PIC_KEY);
    if (null != advise) {
      model.addAttribute("advisePath", advise.getFileWebPath());
    }
    SysFileImg adviseExtend =
        sysAnnouncementService.findImg(
            sysAnnouncement.getId(), BsFileService.ADVISE_EXTEND_PIC_KEY);
    if (null != adviseExtend) {
      model.addAttribute("adviseExtendPath", adviseExtend.getFileWebPath());
    }

    model.addAttribute("tp", "audit");
    return "/websys/announcement/view";
  }
Пример #3
0
 private void validateUserCode(SysUser user, Errors errors) {
   ValidationUtils.rejectIfEmptyOrWhitespace(errors, "userCode", null, "请填写帐号");
   if (!errors.hasFieldErrors("userCode")) {
     String userCode = user.getUserCode();
     SysUser obj = userDao.findByUserCode(userCode);
     if (obj != null) {
       errors.rejectValue("userCode", null, "帐号已存在");
     }
   }
 }