20260720172840

This commit is contained in:
oneao committed 2026-07-20 17:28:47 +08:00
1 parent cda7f16d3a
commit 94207c77ff
3117 files changed
+201407 -1236

No files matched your search

@@ -50,12 +50,14 @@ public class AuthService {
}
String accountId = getString(account, "b_account");
long userPrimaryKey = getLong(account, "b_id");
String sessionId = UUID.randomUUID().toString();
String token = jwtUtils.generateToken(accountId, normalizedOrgId, sessionId);
activeSessionRegistry.activate(normalizedOrgId, accountId, sessionId);
Map<String, Object> user = new LinkedHashMap<>();
user.put("id", accountId);
user.put("id", userPrimaryKey);
user.put("account", accountId);
user.put("name", getString(account, "b_name"));
Map<String, Object> result = new LinkedHashMap<>();
@@ -70,6 +72,21 @@ public class AuthService {
return value == null ? null : value.toString();
}
private long getLong(Map<String, Object> row, String column) {
Object value = getValue(row, column);
if (value instanceof Number number) {
return number.longValue();
}
if (value != null) {
try {
return Long.parseLong(value.toString());
} catch (NumberFormatException ignored) {
// Report the same configuration error below.
}
}
throw new IllegalStateException("登录用户缺少有效的" + column);
}
private Object getValue(Map<String, Object> row, String column) {
for (Map.Entry<String, Object> entry : row.entrySet()) {
if (entry.getKey().equalsIgnoreCase(column)) {
@@ -61,7 +61,8 @@ class AuthServiceTests {
assertThat(result).isPresent();
assertThat(result.orElseThrow()).containsEntry("token", "token");
Map<?, ?> user = (Map<?, ?>) result.orElseThrow().get("user");
assertThat(user.get("id")).isEqualTo("g3soft");
assertThat(user.get("id")).isEqualTo(828084517703744L);
assertThat(user.get("account")).isEqualTo("g3soft");
assertThat(user.get("name")).isEqualTo("G3Soft");
}
}