@Test public void getAllGroup() throws Exception { String name = "千里之外"; String info = "千里之外是个啥"; GroupDO group = GroupDO.builder().name(name).info(info).build(); groupMapper.insert(group); String module = "信息"; String permissionName = "查看lin的信息"; PermissionDO permission = PermissionDO.builder().name(permissionName).module(module).build(); permissionMapper.insert(permission); groupPermissionMapper.insert(new GroupPermissionDO(group.getId(), permission.getId())); mvc.perform(get("/cms/admin/group/all") .contentType(MediaType.APPLICATION_JSON)) .andDo(print()) .andExpect(status().isOk()) .andExpect(MockMvcResultMatchers.jsonPath("$").isArray()); }
@GetMapping("/group/all") @AdminRequired @RouteMeta(permission = "查询所有权限组", module = "管理员") public List<GroupDO> getAllGroup() { List<GroupDO> groups = adminService.getAllGroups(); return groups; }
AdminController { @GetMapping("/group/all") @AdminRequired @RouteMeta(permission = "查询所有权限组", module = "管理员") public List<GroupDO> getAllGroup() { List<GroupDO> groups = adminService.getAllGroups(); return groups; } }
AdminController { @GetMapping("/group/all") @AdminRequired @RouteMeta(permission = "查询所有权限组", module = "管理员") public List<GroupDO> getAllGroup() { List<GroupDO> groups = adminService.getAllGroups(); return groups; }  }
AdminController { @GetMapping("/group/all") @AdminRequired @RouteMeta(permission = "查询所有权限组", module = "管理员") public List<GroupDO> getAllGroup() { List<GroupDO> groups = adminService.getAllGroups(); return groups; }  @GetMapping("/permission") @AdminRequired @RouteMeta(permission = "查询所有可分配的权限", module = "管理员") Map<String, List<PermissionDO>> getAllPermissions(); @GetMapping("/users") @AdminRequired @RouteMeta(permission = "查询所有用户", module = "管理员") PageResponseVO getUsers(
            @RequestParam(name = "group_id", required = false)
            @Min(value = 1, message = "{group_id}") Long groupId,
            @RequestParam(name = "count", required = false, defaultValue = "10")
            @Min(value = 1, message = "{count}") Long count,
            @RequestParam(name = "page", required = false, defaultValue = "0")
            @Min(value = 0, message = "{page}") Long page); @PutMapping("/user/{id}/password") @AdminRequired @RouteMeta(permission = "修改用户密码", module = "管理员") UnifyResponseVO changeUserPassword(@PathVariable @Positive(message = "{id}") Long id, @RequestBody @Validated ResetPasswordDTO validator); @DeleteMapping("/user/{id}") @AdminRequired @RouteMeta(permission = "删除用户", module = "管理员") UnifyResponseVO deleteUser(@PathVariable @Positive(message = "{id}") Long id); @PutMapping("/user/{id}") @AdminRequired @RouteMeta(permission = "管理员更新用户信息", module = "管理员") UnifyResponseVO updateUser(@PathVariable @Positive(message = "{id}") Long id, @RequestBody @Validated UpdateUserInfoDTO validator); @GetMapping("/group") @AdminRequired @RouteMeta(permission = "查询所有权限组及其权限", module = "管理员") PageResponseVO getGroups(
            @RequestParam(name = "count", required = false, defaultValue = "10")
            @Min(value = 1, message = "{count}") Long count,
            @RequestParam(name = "page", required = false, defaultValue = "0")
            @Min(value = 0, message = "{page}") Long page); @GetMapping("/group/all") @AdminRequired @RouteMeta(permission = "查询所有权限组", module = "管理员") List<GroupDO> getAllGroup(); @GetMapping("/group/{id}") @AdminRequired @RouteMeta(permission = "查询一个权限组及其权限", module = "管理员") GroupPermissionsBO getGroup(@PathVariable @Positive(message = "{id}") Long id); @PostMapping("/group") @AdminRequired @RouteMeta(permission = "新建权限组", module = "管理员") UnifyResponseVO createGroup(@RequestBody @Validated NewGroupDTO validator); @PutMapping("/group/{id}") @AdminRequired @RouteMeta(permission = "更新一个权限组", module = "管理员") UnifyResponseVO updateGroup(@PathVariable @Positive(message = "{id}") Long id,
                                       @RequestBody @Validated UpdateGroupDTO validator); @DeleteMapping("/group/{id}") @AdminRequired @RouteMeta(permission = "删除一个权限组", module = "管理员") UnifyResponseVO deleteGroup(@PathVariable @Positive(message = "{id}") Long id); @PostMapping("/permission/dispatch") @AdminRequired @RouteMeta(permission = "分配单个权限", module = "管理员") UnifyResponseVO dispatchPermission(@RequestBody @Validated DispatchPermissionDTO validator); @PostMapping("/permission/dispatch/batch") @AdminRequired @RouteMeta(permission = "分配多个权限", module = "管理员") UnifyResponseVO dispatchPermissions(@RequestBody @Validated DispatchPermissionsDTO validator); @PostMapping("/permission/remove") @AdminRequired @RouteMeta(permission = "删除多个权限", module = "管理员") UnifyResponseVO removePermissions(@RequestBody @Validated RemovePermissionsDTO validator); }
AdminController { @GetMapping("/group/all") @AdminRequired @RouteMeta(permission = "查询所有权限组", module = "管理员") public List<GroupDO> getAllGroup() { List<GroupDO> groups = adminService.getAllGroups(); return groups; }  @GetMapping("/permission") @AdminRequired @RouteMeta(permission = "查询所有可分配的权限", module = "管理员") Map<String, List<PermissionDO>> getAllPermissions(); @GetMapping("/users") @AdminRequired @RouteMeta(permission = "查询所有用户", module = "管理员") PageResponseVO getUsers(
            @RequestParam(name = "group_id", required = false)
            @Min(value = 1, message = "{group_id}") Long groupId,
            @RequestParam(name = "count", required = false, defaultValue = "10")
            @Min(value = 1, message = "{count}") Long count,
            @RequestParam(name = "page", required = false, defaultValue = "0")
            @Min(value = 0, message = "{page}") Long page); @PutMapping("/user/{id}/password") @AdminRequired @RouteMeta(permission = "修改用户密码", module = "管理员") UnifyResponseVO changeUserPassword(@PathVariable @Positive(message = "{id}") Long id, @RequestBody @Validated ResetPasswordDTO validator); @DeleteMapping("/user/{id}") @AdminRequired @RouteMeta(permission = "删除用户", module = "管理员") UnifyResponseVO deleteUser(@PathVariable @Positive(message = "{id}") Long id); @PutMapping("/user/{id}") @AdminRequired @RouteMeta(permission = "管理员更新用户信息", module = "管理员") UnifyResponseVO updateUser(@PathVariable @Positive(message = "{id}") Long id, @RequestBody @Validated UpdateUserInfoDTO validator); @GetMapping("/group") @AdminRequired @RouteMeta(permission = "查询所有权限组及其权限", module = "管理员") PageResponseVO getGroups(
            @RequestParam(name = "count", required = false, defaultValue = "10")
            @Min(value = 1, message = "{count}") Long count,
            @RequestParam(name = "page", required = false, defaultValue = "0")
            @Min(value = 0, message = "{page}") Long page); @GetMapping("/group/all") @AdminRequired @RouteMeta(permission = "查询所有权限组", module = "管理员") List<GroupDO> getAllGroup(); @GetMapping("/group/{id}") @AdminRequired @RouteMeta(permission = "查询一个权限组及其权限", module = "管理员") GroupPermissionsBO getGroup(@PathVariable @Positive(message = "{id}") Long id); @PostMapping("/group") @AdminRequired @RouteMeta(permission = "新建权限组", module = "管理员") UnifyResponseVO createGroup(@RequestBody @Validated NewGroupDTO validator); @PutMapping("/group/{id}") @AdminRequired @RouteMeta(permission = "更新一个权限组", module = "管理员") UnifyResponseVO updateGroup(@PathVariable @Positive(message = "{id}") Long id,
                                       @RequestBody @Validated UpdateGroupDTO validator); @DeleteMapping("/group/{id}") @AdminRequired @RouteMeta(permission = "删除一个权限组", module = "管理员") UnifyResponseVO deleteGroup(@PathVariable @Positive(message = "{id}") Long id); @PostMapping("/permission/dispatch") @AdminRequired @RouteMeta(permission = "分配单个权限", module = "管理员") UnifyResponseVO dispatchPermission(@RequestBody @Validated DispatchPermissionDTO validator); @PostMapping("/permission/dispatch/batch") @AdminRequired @RouteMeta(permission = "分配多个权限", module = "管理员") UnifyResponseVO dispatchPermissions(@RequestBody @Validated DispatchPermissionsDTO validator); @PostMapping("/permission/remove") @AdminRequired @RouteMeta(permission = "删除多个权限", module = "管理员") UnifyResponseVO removePermissions(@RequestBody @Validated RemovePermissionsDTO validator);  }