Ejemplo n.º 1
0
 /**
  * 删除
  *
  * @param ids
  */
 @RequiresPermissions("role:delete")
 @RequestMapping(value = "/delete", method = RequestMethod.POST)
 public @ResponseBody Message delete(Long[] ids) {
   if (ids != null) {
     for (Long id : ids) {
       WRole role = roleService.load(id);
       if (role.getAccounts() != null && !role.getAccounts().isEmpty()) {
         return Message.error("admin.role.deleteExistNotAllowed", role.getRoleName());
       }
     }
     roleService.delete(ids);
     return SUCCESS_MESSAGE;
   }
   return ERROR_MESSAGE;
 }
Ejemplo n.º 2
0
 @RequiresPermissions("role:view")
 @RequestMapping(method = RequestMethod.GET)
 public String index(ModelMap model) {
   List<WRole> roleList = roleService.getAll();
   model.put("roleList", roleList);
   return "/admin/role/index";
 }
Ejemplo n.º 3
0
 /**
  * 编辑
  *
  * @param id
  * @param model
  * @param redirectAttributes
  * @return String
  */
 @RequiresPermissions("role:edit")
 @RequestMapping(value = "/edit", method = RequestMethod.GET)
 public String edit(Long id, ModelMap model, RedirectAttributes redirectAttributes) {
   WRole role = roleService.load(id);
   List<cn.uuf.stu.entity.framework.WResource> resources = resourceService.getAll();
   List<RoleScope> roleScopeList = roleScopeService.getAll();
   model.put("rcList", roleScopeList);
   model.put("role", role);
   model.put("resources", resources);
   return "/admin/role/edit";
 }
Ejemplo n.º 4
0
 /**
  * 保存
  *
  * @param role
  * @param ids
  * @return String
  */
 @RequiresPermissions("role:create")
 @RequestMapping(value = "/save", method = RequestMethod.POST)
 public String save(WRole role, RedirectAttributes redirectAttributes, Long... ids) {
   if (!isValid(role)) {
     return ERROR_VIEW;
   }
   role.setResoures(resourceService.getList(ids));
   roleService.save(role);
   addFlashMessage(redirectAttributes, SUCCESS_MESSAGE);
   return "redirect:/admin/role";
 }
Ejemplo n.º 5
0
 /**
  * 更新
  *
  * @param role
  * @param redirectAttributes
  * @param ids
  * @return String
  */
 @RequiresPermissions("role:edit")
 @RequestMapping(value = "/update", method = RequestMethod.POST)
 public String update(WRole role, RedirectAttributes redirectAttributes, Long... ids) {
   if (!isValid(role)) {
     return ERROR_VIEW;
   }
   role.setResoures(resourceService.getList(ids));
   roleService.update(role, role.getId(), "accounts", "categorys");
   addFlashMessage(redirectAttributes, SUCCESS_MESSAGE);
   return "redirect:/admin/role";
 }