Example #1
0
 /** 重载函数,因为Role中没有建立与User的关联,因此需要以较低效率的方式进行删除User与Role的多对多中间表. */
 @SuppressWarnings("unchecked")
 @Override
 public void delete(Long id) {
   Role role = get(id);
   // 查询出拥有该角色的用户,并删除该用户的角色.
   List<User> users = createQuery(QUERY_USER_BY_ROLEID, role.getId()).list();
   for (User u : users) {
     u.getRoleList().remove(role);
   }
   super.delete(role);
 }
Example #2
0
 @Override
 public String save() throws Exception {
   // 根据页面上的checkbox 整合Role的Authorities Set.
   HibernateUtils.mergeByCheckedIds(entity.getAuthorityList(), checkedAuthIds, Authority.class);
   // 保存用户并放入成功信息.
   accountManager.saveRole(entity);
   addActionMessage("保存角色成功");
   return RELOAD;
 }
Example #3
0
 @Override
 public String input() throws Exception {
   checkedAuthIds = entity.getAuthIds();
   return INPUT;
 }