🐛 扩容用户手机号字段并规范化 OA 多号码同步
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
+19
@@ -88,6 +88,8 @@ public interface UserConvert {
|
||||
default User person2user(OAPersonResponse person, String defaultPassword) {
|
||||
User user = baseConvert(person);
|
||||
user.setAccount(resolveAccount(person));
|
||||
// OA 可能返回多号(如 133.../137...),只保留首个号码再入库加密
|
||||
user.setPhone(normalizeMobile(user.getPhone()));
|
||||
// 密码
|
||||
user.setPassword(defaultPassword);
|
||||
// 性别
|
||||
@@ -103,6 +105,23 @@ public interface UserConvert {
|
||||
return user;
|
||||
}
|
||||
|
||||
/**
|
||||
* 规范化手机号:去空白,多号时取第一个
|
||||
*/
|
||||
default String normalizeMobile(String mobile) {
|
||||
if (StringUtils.isBlank(mobile)) {
|
||||
return null;
|
||||
}
|
||||
String trimmed = mobile.trim();
|
||||
String[] parts = trimmed.split("[/|,;;,\\s]+");
|
||||
for (String part : parts) {
|
||||
if (StringUtils.isNotBlank(part)) {
|
||||
return part.trim();
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 解析本系统登录账号:优先 OA loginid,其次工号,最后手机号
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user