@Test public void add() throws Exception { mockMvc.perform(MockMvcRequestBuilders.post("/member/add") .contentType(MediaType.APPLICATION_JSON_UTF8) .content(requestJson) .accept(MediaType.APPLICATION_JSON_UTF8)) .andExpect(MockMvcResultMatchers.status().isOk()) .andDo(MockMvcResultHandlers.print()); }
@RequestMapping(value = "/add", method = RequestMethod.POST) public ServiceResult<String> add(@Validated(AddMember.class) @RequestBody UserGroup userGroup, @CurrentUser LoginUser user, Errors errors) throws Exception { userGroup.setUpdate_user_no(user.getUserNo()); ValidateResult validateRes = groupMemberService.validatePermisionAdd(user, userGroup, errors) .addAssert(() -> !groupMemberService.isUserInGroup(userGroup.getUser_id(), userGroup.getGroup_id()), message.group_message_user_ingroup) .addAssert(() -> userGroupDao.insertUserGroup(userGroup) > 0, message.db_message_add_operation_failed).validate(); if (!validateRes.isValid()) { return ServiceResult.fail(validateRes.getSummarize()); } return ServiceResult.success(); }
GroupMemberController { @RequestMapping(value = "/add", method = RequestMethod.POST) public ServiceResult<String> add(@Validated(AddMember.class) @RequestBody UserGroup userGroup, @CurrentUser LoginUser user, Errors errors) throws Exception { userGroup.setUpdate_user_no(user.getUserNo()); ValidateResult validateRes = groupMemberService.validatePermisionAdd(user, userGroup, errors) .addAssert(() -> !groupMemberService.isUserInGroup(userGroup.getUser_id(), userGroup.getGroup_id()), message.group_message_user_ingroup) .addAssert(() -> userGroupDao.insertUserGroup(userGroup) > 0, message.db_message_add_operation_failed).validate(); if (!validateRes.isValid()) { return ServiceResult.fail(validateRes.getSummarize()); } return ServiceResult.success(); } }
GroupMemberController { @RequestMapping(value = "/add", method = RequestMethod.POST) public ServiceResult<String> add(@Validated(AddMember.class) @RequestBody UserGroup userGroup, @CurrentUser LoginUser user, Errors errors) throws Exception { userGroup.setUpdate_user_no(user.getUserNo()); ValidateResult validateRes = groupMemberService.validatePermisionAdd(user, userGroup, errors) .addAssert(() -> !groupMemberService.isUserInGroup(userGroup.getUser_id(), userGroup.getGroup_id()), message.group_message_user_ingroup) .addAssert(() -> userGroupDao.insertUserGroup(userGroup) > 0, message.db_message_add_operation_failed).validate(); if (!validateRes.isValid()) { return ServiceResult.fail(validateRes.getSummarize()); } return ServiceResult.success(); }  }
GroupMemberController { @RequestMapping(value = "/add", method = RequestMethod.POST) public ServiceResult<String> add(@Validated(AddMember.class) @RequestBody UserGroup userGroup, @CurrentUser LoginUser user, Errors errors) throws Exception { userGroup.setUpdate_user_no(user.getUserNo()); ValidateResult validateRes = groupMemberService.validatePermisionAdd(user, userGroup, errors) .addAssert(() -> !groupMemberService.isUserInGroup(userGroup.getUser_id(), userGroup.getGroup_id()), message.group_message_user_ingroup) .addAssert(() -> userGroupDao.insertUserGroup(userGroup) > 0, message.db_message_add_operation_failed).validate(); if (!validateRes.isValid()) { return ServiceResult.fail(validateRes.getSummarize()); } return ServiceResult.success(); }  @RequestMapping(value = "/users") ServiceResult<List<MemberView>> getUsers(@RequestParam(value = "name", defaultValue = "") String name); @RequestMapping(value = "/list", method = RequestMethod.POST) ServiceResult<ListResult<MemberView>> getGroupUsers(@RequestBody Paging<UserGroup> paging); @RequestMapping(value = "/add", method = RequestMethod.POST) ServiceResult<String> add(@Validated(AddMember.class) @RequestBody UserGroup userGroup, @CurrentUser LoginUser user, Errors errors); @RequestMapping(value = "/delete", method = RequestMethod.DELETE) ServiceResult<String> delete(@Validated(DeleteMember.class) @RequestBody UserGroup userGroup, @CurrentUser LoginUser user, Errors errors); @RequestMapping(value = "/update", method = RequestMethod.PUT) ServiceResult<String> update(@Validated(UpdateMember.class) @RequestBody UserGroup userGroup, @CurrentUser LoginUser user, Errors errors); }
GroupMemberController { @RequestMapping(value = "/add", method = RequestMethod.POST) public ServiceResult<String> add(@Validated(AddMember.class) @RequestBody UserGroup userGroup, @CurrentUser LoginUser user, Errors errors) throws Exception { userGroup.setUpdate_user_no(user.getUserNo()); ValidateResult validateRes = groupMemberService.validatePermisionAdd(user, userGroup, errors) .addAssert(() -> !groupMemberService.isUserInGroup(userGroup.getUser_id(), userGroup.getGroup_id()), message.group_message_user_ingroup) .addAssert(() -> userGroupDao.insertUserGroup(userGroup) > 0, message.db_message_add_operation_failed).validate(); if (!validateRes.isValid()) { return ServiceResult.fail(validateRes.getSummarize()); } return ServiceResult.success(); }  @RequestMapping(value = "/users") ServiceResult<List<MemberView>> getUsers(@RequestParam(value = "name", defaultValue = "") String name); @RequestMapping(value = "/list", method = RequestMethod.POST) ServiceResult<ListResult<MemberView>> getGroupUsers(@RequestBody Paging<UserGroup> paging); @RequestMapping(value = "/add", method = RequestMethod.POST) ServiceResult<String> add(@Validated(AddMember.class) @RequestBody UserGroup userGroup, @CurrentUser LoginUser user, Errors errors); @RequestMapping(value = "/delete", method = RequestMethod.DELETE) ServiceResult<String> delete(@Validated(DeleteMember.class) @RequestBody UserGroup userGroup, @CurrentUser LoginUser user, Errors errors); @RequestMapping(value = "/update", method = RequestMethod.PUT) ServiceResult<String> update(@Validated(UpdateMember.class) @RequestBody UserGroup userGroup, @CurrentUser LoginUser user, Errors errors);  }