fix(系统设置): 优化用户编辑时填写已存在邮箱的报错信息

This commit is contained in:
song-tianyang 2024-01-30 19:10:45 +08:00 committed by Craftsman
parent 4923456b6d
commit 55a6ecae3b
2 changed files with 7 additions and 2 deletions

View File

@ -204,10 +204,12 @@ public class UserService {
}
}
public UserEditRequest updateUser(UserEditRequest userEditRequest, String operator) {
//检查用户组合法性
globalUserRoleService.checkRoleIsGlobalAndHaveMember(userEditRequest.getUserRoleIdList(), true);
//检查用户邮箱的合法性
this.checkUserEmail(userEditRequest.getId(), userEditRequest.getEmail());
User user = new User();
BeanUtils.copyBean(user, userEditRequest);
user.setUpdateUser(operator);

View File

@ -402,6 +402,7 @@ public class UserControllerTests extends BaseTest {
@Test
@Order(5)
public void testUserUpdateError() throws Exception {
this.checkUserList();
// 4xx 验证
UserCreateInfo user = new UserCreateInfo();
UserEditRequest userMaintainRequest;
@ -432,7 +433,9 @@ public class UserControllerTests extends BaseTest {
BeanUtils.copyBean(user, USER_LIST.get(0));
user.setEmail(USER_LIST.get(USER_LIST.size() - 1).getEmail());
userMaintainRequest = UserParamUtils.getUserUpdateDTO(user, USER_ROLE_LIST);
this.requestPost(UserRequestUtils.URL_USER_UPDATE, userMaintainRequest, ERROR_REQUEST_MATCHER);
MvcResult mvcResult = this.requestPost(UserRequestUtils.URL_USER_UPDATE, userMaintainRequest, ERROR_REQUEST_MATCHER).andReturn();
ResultHolder resultHolder = JSON.parseObject(mvcResult.getResponse().getContentAsString(StandardCharsets.UTF_8), ResultHolder.class);
Assertions.assertEquals(resultHolder.getMessage(), "用户邮箱已存在");
//用户组不包含系统成员
BeanUtils.copyBean(user, USER_LIST.get(0));
userMaintainRequest = UserParamUtils.getUserUpdateDTO(user,