You've already forked DataMate
feat(kg): 实现知识图谱组织同步功能
- 替换硬编码的 org:default 占位符,支持真实组织数据 - 从 users 表的 organization 字段获取组织映射 - 支持多租户场景,每个组织独立管理 - 添加降级保护机制,防止数据丢失 - 修复 BELONGS_TO 关系遗留问题 - 修复组织编码碰撞问题 - 新增 95 个测试用例,全部通过 修改文件: - Auth 模块:添加组织字段和查询接口 - KG Sync Client:添加用户组织映射 - Core Sync Logic:重写组织实体和关系逻辑 - Tests:新增测试用例覆盖核心场景
This commit is contained in:
@@ -110,6 +110,17 @@ public class AuthApplicationService {
|
||||
return responses;
|
||||
}
|
||||
|
||||
/**
|
||||
* 返回所有用户的用户名与组织映射,供内部同步服务使用。
|
||||
*/
|
||||
public List<UserOrgMapping> listUserOrganizations() {
|
||||
return authMapper.listUsers().stream()
|
||||
.map(u -> new UserOrgMapping(u.getUsername(), u.getOrganization()))
|
||||
.toList();
|
||||
}
|
||||
|
||||
public record UserOrgMapping(String username, String organization) {}
|
||||
|
||||
public List<AuthRoleInfo> listRoles() {
|
||||
return authMapper.listRoles();
|
||||
}
|
||||
|
||||
@@ -14,5 +14,6 @@ public class AuthUserSummary {
|
||||
private String email;
|
||||
private String fullName;
|
||||
private Boolean enabled;
|
||||
private String organization;
|
||||
}
|
||||
|
||||
|
||||
@@ -58,6 +58,14 @@ public class AuthController {
|
||||
return authApplicationService.listUsersWithRoles();
|
||||
}
|
||||
|
||||
/**
|
||||
* 内部接口:返回所有用户的用户名与组织映射,供知识图谱同步服务调用。
|
||||
*/
|
||||
@GetMapping("/users/organizations")
|
||||
public List<AuthApplicationService.UserOrgMapping> listUserOrganizations() {
|
||||
return authApplicationService.listUserOrganizations();
|
||||
}
|
||||
|
||||
@PutMapping("/users/{userId}/roles")
|
||||
public void assignRoles(@PathVariable("userId") Long userId,
|
||||
@RequestBody @Valid AssignUserRolesRequest request) {
|
||||
|
||||
@@ -66,7 +66,8 @@
|
||||
username,
|
||||
email,
|
||||
full_name AS fullName,
|
||||
enabled
|
||||
enabled,
|
||||
organization
|
||||
FROM users
|
||||
ORDER BY id ASC
|
||||
</select>
|
||||
|
||||
Reference in New Issue
Block a user