@Test public void update() throws Exception { GroupDO root = GroupDO.builder().name("root").info("致敬周星星").build(); GroupDO group = GroupDO.builder().name("少林足球").info("致敬周星星").build(); groupMapper.insert(root); groupMapper.insert(group); RegisterDTO dto = new RegisterDTO(); dto.setGroupIds(Arrays.asList(group.getId())); dto.setEmail(email); dto.setConfirmPassword(password); dto.setPassword(password); dto.setUsername(username); userService.createUser(dto); UserDO user = userService.getUserByUsername(username); LocalUser.setLocalUser(user); UpdateInfoDTO dto1 = new UpdateInfoDTO(); dto1.setEmail("23129982604@qq.com"); dto1.setUsername("pedro小小"); ObjectMapper mapper = new ObjectMapper(); mapper.setPropertyNamingStrategy(PropertyNamingStrategy.CAMEL_CASE_TO_LOWER_CASE_WITH_UNDERSCORES); String content = mapper.writeValueAsString(dto1); mvc.perform(MockMvcRequestBuilders.put("/cms/user/") .contentType(MediaType.APPLICATION_JSON).content(content)) .andDo(print()) .andExpect(status().isOk()) .andExpect(MockMvcResultMatchers. jsonPath("$.message").value("更新用户成功")); UserDO user1 = userService.getUserByUsername("pedro小小"); assertTrue(user1.getEmail().equals("23129982604@qq.com")); }
@PutMapping @LoginRequired public UnifyResponseVO update(@RequestBody @Validated UpdateInfoDTO validator) { userService.updateUserInfo(validator); return ResponseUtil.generateUnifyResponse(4); }
UserController { @PutMapping @LoginRequired public UnifyResponseVO update(@RequestBody @Validated UpdateInfoDTO validator) { userService.updateUserInfo(validator); return ResponseUtil.generateUnifyResponse(4); } }
UserController { @PutMapping @LoginRequired public UnifyResponseVO update(@RequestBody @Validated UpdateInfoDTO validator) { userService.updateUserInfo(validator); return ResponseUtil.generateUnifyResponse(4); }  }
UserController { @PutMapping @LoginRequired public UnifyResponseVO update(@RequestBody @Validated UpdateInfoDTO validator) { userService.updateUserInfo(validator); return ResponseUtil.generateUnifyResponse(4); }  @PostMapping("/register") @AdminRequired UnifyResponseVO<String> register(@RequestBody @Validated RegisterDTO validator); @PostMapping("/login") Tokens login(@RequestBody @Validated LoginDTO validator); @PutMapping @LoginRequired UnifyResponseVO update(@RequestBody @Validated UpdateInfoDTO validator); @PutMapping("/change_password") @LoginRequired UnifyResponseVO updatePassword(@RequestBody @Validated ChangePasswordDTO validator); @GetMapping("/refresh") @RefreshRequired Tokens refreshToken(); @GetMapping("/permissions") @LoginRequired @RouteMeta(permission = "查询自己拥有的权限", module = "用户", mount = true) UserPermissionsVO getPermissions(); @LoginRequired @RouteMeta(permission = "查询自己信息", module = "用户", mount = true) @GetMapping("/information") UserInfoVO getInformation(); }
UserController { @PutMapping @LoginRequired public UnifyResponseVO update(@RequestBody @Validated UpdateInfoDTO validator) { userService.updateUserInfo(validator); return ResponseUtil.generateUnifyResponse(4); }  @PostMapping("/register") @AdminRequired UnifyResponseVO<String> register(@RequestBody @Validated RegisterDTO validator); @PostMapping("/login") Tokens login(@RequestBody @Validated LoginDTO validator); @PutMapping @LoginRequired UnifyResponseVO update(@RequestBody @Validated UpdateInfoDTO validator); @PutMapping("/change_password") @LoginRequired UnifyResponseVO updatePassword(@RequestBody @Validated ChangePasswordDTO validator); @GetMapping("/refresh") @RefreshRequired Tokens refreshToken(); @GetMapping("/permissions") @LoginRequired @RouteMeta(permission = "查询自己拥有的权限", module = "用户", mount = true) UserPermissionsVO getPermissions(); @LoginRequired @RouteMeta(permission = "查询自己信息", module = "用户", mount = true) @GetMapping("/information") UserInfoVO getInformation();  }