예제 #1
0
 @RequestMapping(value = "/edit")
 public ModelAndView editPage(Role role) {
   if (null != role && null != role.getId()) {
     role = roleService.getRoleById(role.getId());
     List<Map<String, Object>> permissionList = permissionService.getPermissionMap(role.getId());
     Iterator<Map<String, Object>> it = permissionList.iterator();
     List<String> permissiontringList = new ArrayList<>();
     while (it.hasNext()) {
       Map<String, Object> rm = it.next();
       permissiontringList.add(JsonMapper.nonDefaultMapper().toJson(rm));
     }
     role.setPermissionList(permissiontringList);
   }
   return new ModelAndView(EDIT, "role", role);
 }
예제 #2
0
 @ResponseBody
 @RequestMapping(value = "/save")
 public Map<String, Object> save(Role role) {
   HashMap<String, Object> result = new HashMap<>();
   if (null == role.getId() || StringUtils.isBlank(role.getId().toString())) {
     Role roleTemp = roleService.getRoleByName(role.getName());
     if (null != roleTemp) {
       result.put("result", "ERROR");
       result.put("str", "角色不能重复!");
       return result;
     }
   }
   roleService.save(role);
   result.put("result", "SUCCESS");
   return result;
 }