@Test public void updateInfoByAdmin() throws Exception { UserReq userReq = new UserReq(); String email = UUID.randomUUID().toString().substring(0, 4) + "@celess.cn"; userMapper.addUser(email, MD5Util.getMD5("123456789")); User userByDb = userMapper.findByEmail(email); userReq.setId(userByDb.getId()); userReq.setPwd(UUID.randomUUID().toString().replaceAll("-", "").substring(0, 10)); userReq.setDesc(UUID.randomUUID().toString()); userReq.setEmailStatus(new Random().nextBoolean()); userReq.setRole("admin"); userReq.setDisplayName(UUID.randomUUID().toString().substring(0, 4)); userReq.setEmail(UUID.randomUUID().toString().substring(0, 5) + "@celess.cn"); mockMvc.perform(put("/admin/user").contentType("application/json").content(JSONObject.fromObject(userReq).toString())) .andDo(result -> assertEquals(HAVE_NOT_LOG_IN.getCode(), JSONObject.fromObject(result.getResponse().getContentAsString()).getInt(Code))); mockMvc.perform(put("/admin/user").contentType("application/json").header("Authorization", userLogin()).content(JSONObject.fromObject(userReq).toString())) .andDo(result -> assertEquals(PERMISSION_ERROR.getCode(), JSONObject.fromObject(result.getResponse().getContentAsString()).getInt(Code))); mockMvc.perform(put("/admin/user").contentType("application/json").header("Authorization", adminLogin()).content(JSONObject.fromObject(userReq).toString())) .andDo(result -> { JSONObject object = JSONObject.fromObject(result.getResponse().getContentAsString()); assertEquals(SUCCESS.getCode(), object.getInt(Code)); UserModel user = (UserModel) JSONObject.toBean(object.getJSONObject(Result), UserModel.class); assertEquals(userReq.getId(), user.getId()); assertEquals(userReq.getRole(), user.getRole()); assertEquals(userReq.getEmail(), user.getEmail()); assertEquals(userReq.getDesc(), user.getDesc()); assertEquals(userReq.getDisplayName(), user.getDisplayName()); }); }
@PutMapping("/admin/user") public Response updateInfoByAdmin(@RequestBody UserReq user) { return ResponseUtil.success(userService.adminUpdate(user)); }
UserController { @PutMapping("/admin/user") public Response updateInfoByAdmin(@RequestBody UserReq user) { return ResponseUtil.success(userService.adminUpdate(user)); } }
UserController { @PutMapping("/admin/user") public Response updateInfoByAdmin(@RequestBody UserReq user) { return ResponseUtil.success(userService.adminUpdate(user)); }  }
UserController { @PutMapping("/admin/user") public Response updateInfoByAdmin(@RequestBody UserReq user) { return ResponseUtil.success(userService.adminUpdate(user)); }  @PostMapping("/login") Response login(@RequestBody LoginReq loginReq); @PostMapping("/registration") Response registration(@RequestParam("email") String email,
                                 @RequestParam("password") String password); @GetMapping("/logout") Response logout(); @PutMapping("/user/userInfo/update") Response updateInfo(String desc, String displayName); @GetMapping("/user/userInfo") Response getUserInfo(); @PostMapping("/user/imgUpload") @ResponseBody Response upload(@RequestParam("file") MultipartFile file); @PostMapping("/sendResetPwdEmail") Response sendResetPwdEmail(@RequestParam("email") String email); @PostMapping("/sendVerifyEmail") Response sendVerifyEmail(@RequestParam("email") String email); @PostMapping("/emailVerify") Response emailVerify(@RequestParam("verifyId") String verifyId,
                                @RequestParam("email") String mail); @PostMapping("/resetPwd") Response resetPwd(@RequestParam("verifyId") String verifyId,
                             @RequestParam("email") String email,
                             @RequestParam("pwd") String pwd); @DeleteMapping("/admin/user/delete") Response multipleDelete(@RequestBody Integer[] ids); @DeleteMapping("/admin/user/delete/{id}") Response delete(@PathVariable("id") Integer id); @PutMapping("/admin/user") Response updateInfoByAdmin(@RequestBody UserReq user); @GetMapping("/admin/users") Response getAllUser(@RequestParam("page") int pageNum, @RequestParam("count") int count); @GetMapping("/emailStatus/{email}") Response getEmailStatus(@PathVariable("email") String email); }
UserController { @PutMapping("/admin/user") public Response updateInfoByAdmin(@RequestBody UserReq user) { return ResponseUtil.success(userService.adminUpdate(user)); }  @PostMapping("/login") Response login(@RequestBody LoginReq loginReq); @PostMapping("/registration") Response registration(@RequestParam("email") String email,
                                 @RequestParam("password") String password); @GetMapping("/logout") Response logout(); @PutMapping("/user/userInfo/update") Response updateInfo(String desc, String displayName); @GetMapping("/user/userInfo") Response getUserInfo(); @PostMapping("/user/imgUpload") @ResponseBody Response upload(@RequestParam("file") MultipartFile file); @PostMapping("/sendResetPwdEmail") Response sendResetPwdEmail(@RequestParam("email") String email); @PostMapping("/sendVerifyEmail") Response sendVerifyEmail(@RequestParam("email") String email); @PostMapping("/emailVerify") Response emailVerify(@RequestParam("verifyId") String verifyId,
                                @RequestParam("email") String mail); @PostMapping("/resetPwd") Response resetPwd(@RequestParam("verifyId") String verifyId,
                             @RequestParam("email") String email,
                             @RequestParam("pwd") String pwd); @DeleteMapping("/admin/user/delete") Response multipleDelete(@RequestBody Integer[] ids); @DeleteMapping("/admin/user/delete/{id}") Response delete(@PathVariable("id") Integer id); @PutMapping("/admin/user") Response updateInfoByAdmin(@RequestBody UserReq user); @GetMapping("/admin/users") Response getAllUser(@RequestParam("page") int pageNum, @RequestParam("count") int count); @GetMapping("/emailStatus/{email}") Response getEmailStatus(@PathVariable("email") String email);  }