Esempio n. 1
0
  @RequestMapping("role-def-save")
  public String save(@ModelAttribute RoleDef roleDef, RedirectAttributes redirectAttributes) {
    try {
      // before check
      roleDefChecker.check(roleDef);

      // after invoke
      RoleDef dest = null;
      Long id = roleDef.getId();

      if (id != null) {
        dest = roleDefManager.get(id);
        beanMapper.copy(roleDef, dest);
      } else {
        dest = roleDef;
      }

      if (id == null) {
        dest.setScopeId(ScopeHolder.getScopeId());
      }

      roleDefManager.save(dest);

      messageHelper.addFlashMessage(redirectAttributes, "core.success.save", "保存成功");
    } catch (CheckRoleException ex) {
      logger.warn(ex.getMessage(), ex);
      redirectAttributes.addFlashAttribute("message", ex.getMessage());

      return "auth/role-def-input";
    }

    return "redirect:/auth/role-def-list.do";
  }
Esempio n. 2
0
  @RequestMapping("role-def-remove")
  public String remove(
      @RequestParam("selectedItem") List<Long> selectedItem,
      RedirectAttributes redirectAttributes) {
    try {
      List<RoleDef> roleDefs = roleDefManager.findByIds(selectedItem);

      for (RoleDef roleDef : roleDefs) {
        roleDefChecker.check(roleDef);
      }

      roleDefManager.removeAll(roleDefs);
      messageHelper.addFlashMessage(redirectAttributes, "core.success.delete", "删除成功");
    } catch (CheckRoleException ex) {
      logger.warn(ex.getMessage(), ex);

      messageHelper.addFlashMessage(redirectAttributes, ex.getMessage());
    }

    return "redirect:/auth/role-def-list.do";
  }