feat: 新建用户时设置用户来源
This commit is contained in:
parent
158bac4be8
commit
9045102e21
|
@ -57,7 +57,7 @@ public class LdapController {
|
||||||
user.setEmail(email);
|
user.setEmail(email);
|
||||||
user.setPassword(password);
|
user.setPassword(password);
|
||||||
user.setSource(UserSource.Ldap.name());
|
user.setSource(UserSource.Ldap.name());
|
||||||
userService.createUser(user);
|
userService.addLdapUser(user);
|
||||||
} else {
|
} else {
|
||||||
request.setUsername(u.getId());
|
request.setUsername(u.getId());
|
||||||
request.setPassword(u.getPassword());
|
request.setPassword(u.getPassword());
|
||||||
|
|
|
@ -141,14 +141,26 @@ public class UserService {
|
||||||
user.setSource(UserSource.Local.name());
|
user.setSource(UserSource.Local.name());
|
||||||
// 密码使用 MD5
|
// 密码使用 MD5
|
||||||
user.setPassword(CodingUtil.md5(user.getPassword()));
|
user.setPassword(CodingUtil.md5(user.getPassword()));
|
||||||
|
checkEmailIsExist(user.getEmail());
|
||||||
|
userMapper.insertSelective(user);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addLdapUser(User user) {
|
||||||
|
user.setCreateTime(System.currentTimeMillis());
|
||||||
|
user.setUpdateTime(System.currentTimeMillis());
|
||||||
|
user.setStatus(UserStatus.NORMAL);
|
||||||
|
checkEmailIsExist(user.getEmail());
|
||||||
|
userMapper.insertSelective(user);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void checkEmailIsExist(String email) {
|
||||||
UserExample userExample = new UserExample();
|
UserExample userExample = new UserExample();
|
||||||
UserExample.Criteria criteria = userExample.createCriteria();
|
UserExample.Criteria criteria = userExample.createCriteria();
|
||||||
criteria.andEmailEqualTo(user.getEmail());
|
criteria.andEmailEqualTo(email);
|
||||||
List<User> userList = userMapper.selectByExample(userExample);
|
List<User> userList = userMapper.selectByExample(userExample);
|
||||||
if (!CollectionUtils.isEmpty(userList)) {
|
if (!CollectionUtils.isEmpty(userList)) {
|
||||||
MSException.throwException(Translator.get("user_email_already_exists"));
|
MSException.throwException(Translator.get("user_email_already_exists"));
|
||||||
}
|
}
|
||||||
userMapper.insertSelective(user);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public UserDTO getUserDTO(String userId) {
|
public UserDTO getUserDTO(String userId) {
|
||||||
|
|
Loading…
Reference in New Issue