@Log(message = "向{0}用户分配了{1}的角色。") @RequiresPermissions("User:assign") @RequestMapping( value = "/create/userRole", method = {RequestMethod.POST}) public @ResponseBody void assignRole(UserRole userRole) { userRoleService.save(userRole); User user = userService.get(userRole.getUser().getId()); Role role = roleService.get(userRole.getRole().getId()); LogUitl.putArgs( LogMessageObject.newWrite().setObjects(new Object[] {user.getUsername(), role.getName()})); }
@Log(message = "撤销了{0}用户的{1}角色。") @RequiresPermissions("User:assign") @RequestMapping( value = "/delete/userRole/{userRoleId}", method = {RequestMethod.POST}) public @ResponseBody void deleteUserRole(@PathVariable Long userRoleId) { UserRole userRole = userRoleService.get(userRoleId); LogUitl.putArgs( LogMessageObject.newWrite() .setObjects( new Object[] {userRole.getUser().getUsername(), userRole.getRole().getName()})); userRoleService.delete(userRoleId); }
@Log(message = "删除了{0}用户。") @RequiresPermissions("User:delete") @RequestMapping(value = "/delete", method = RequestMethod.POST) public @ResponseBody String deleteMany(Long[] ids) { String[] usernames = new String[ids.length]; try { for (int i = 0; i < ids.length; i++) { User user = userService.get(ids[i]); userService.delete(user.getId()); usernames[i] = user.getUsername(); } } catch (ServiceException e) { return AjaxObject.newError(e.getMessage()).setCallbackType("").toString(); } LogUitl.putArgs( LogMessageObject.newWrite().setObjects(new Object[] {Arrays.toString(usernames)})); return AjaxObject.newOk("删除用户成功!").setCallbackType("").toString(); }