SysUserController { @DeleteMapping(value = "/users/{id}") public Result delete(@PathVariable Long id) { if (checkAdmin(id)) { return Result.failed(ADMIN_CHANGE_MSG); } appUserService.delUser(id); return Result.succeed("删除成功"); }  @ApiOperation(value = "根据access_token当前登录用户") @GetMapping("/users/current") Result<LoginAppUser> getLoginAppUser(@LoginUser(isFull = true) SysUser user); @GetMapping(value = "/users/name/{username}") @ApiOperation(value = "根据用户名查询用户实体") @Cacheable(value = "user", key = "#username") SysUser selectByUsername(@PathVariable String username); @GetMapping(value = "/users-anon/login", params = "username") @ApiOperation(value = "根据用户名查询用户") LoginAppUser findByUsername(String username); @GetMapping(value = "/users-anon/mobile", params = "mobile") @ApiOperation(value = "根据手机号查询用户") SysUser findByMobile(String mobile); @GetMapping(value = "/users-anon/openId", params = "openId") @ApiOperation(value = "根据OpenId查询用户") SysUser findByOpenId(String openId); @GetMapping("/users/{id}") SysUser findUserById(@PathVariable Long id); @PutMapping("/users") @CachePut(value = "user", key = "#sysUser.username", unless="#result == null") //@AuditLog(operation = "'更新用户:' + #sysUser") void updateSysUser(@RequestBody SysUser sysUser); @PostMapping("/users/{id}/roles") void setRoleToUser(@PathVariable Long id, @RequestBody Set<Long> roleIds); @GetMapping("/users/{id}/roles") List<SysRole> findRolesByUserId(@PathVariable Long id); @ApiOperation(value = "用户查询列表") @ApiImplicitParams({ @ApiImplicitParam(name = "page", value = "分页起始位置", required = true, dataType = "Integer"), @ApiImplicitParam(name = "limit", value = "分页结束位置", required = true, dataType = "Integer") }) @GetMapping("/users") PageResult<SysUser> findUsers(@RequestParam Map<String, Object> params); @ApiOperation(value = "修改用户状态") @GetMapping("/users/updateEnabled") @ApiImplicitParams({ @ApiImplicitParam(name = "id", value = "用户id", required = true, dataType = "Integer"), @ApiImplicitParam(name = "enabled", value = "是否启用", required = true, dataType = "Boolean") }) Result updateEnabled(@RequestParam Map<String, Object> params); @PutMapping(value = "/users/{id}/password") //@AuditLog(operation = "'重置用户密码:' + #id") Result resetPassword(@PathVariable Long id); @PutMapping(value = "/users/password") Result resetPassword(@RequestBody SysUser sysUser); @DeleteMapping(value = "/users/{id}") //@AuditLog(operation = "'删除用户:' + #id") Result delete(@PathVariable Long id); @CacheEvict(value = "user", key = "#sysUser.username") @PostMapping("/users/saveOrUpdate") @AuditLog(operation = "'新增或更新用户:' + #sysUser.username") Result saveOrUpdate(@RequestBody SysUser sysUser); @PostMapping("/users/export") void exportUser(@RequestParam Map<String, Object> params, HttpServletResponse response); @PostMapping(value = "/users/import") Result importExcl(@RequestParam("file") MultipartFile excl); @ApiOperation(value = "用户全文搜索列表") @ApiImplicitParams({ @ApiImplicitParam(name = "page", value = "分页起始位置", required = true, dataType = "Integer"), @ApiImplicitParam(name = "limit", value = "分页结束位置", required = true, dataType = "Integer"), @ApiImplicitParam(name = "queryStr", value = "搜索关键字", dataType = "String") }) @GetMapping("/users/search") PageResult<JSONObject> search(SearchDto searchDto);  }
@Test @Transactional public void whenDeleteSuccess() throws Exception { mockMvc.perform(delete("/users/1") .header("x-userid-header", 1) .header("x-user-header", "admin") .header("x-tenant-header", "webApp") .contentType(MediaType.APPLICATION_JSON_UTF8)) .andExpect(status().isOk()); }