添加调试日志:在syncUserFromDingTalk中添加详细的roleIds检查日志
This commit is contained in:
parent
cfa38c9b36
commit
4e74747947
@ -510,11 +510,19 @@ public class UserService {
|
||||
user.setDeptName(primaryDept.getDeptName());
|
||||
// 根据主部门类型设置角色(但如果用户已经是管理员,保留管理员角色)
|
||||
String currentRoleIds = user.getRoleIds();
|
||||
log.info("syncUserFromDingTalk - 检查管理员角色: userId={}, currentRoleIds={}",
|
||||
user.getId(), currentRoleIds);
|
||||
boolean isAdmin = currentRoleIds != null &&
|
||||
(currentRoleIds.contains("1") || currentRoleIds.contains("2"));
|
||||
log.info("syncUserFromDingTalk - isAdmin={}, currentRoleIds.contains('1')={}, currentRoleIds.contains('2')={}",
|
||||
isAdmin, currentRoleIds != null && currentRoleIds.contains("1"),
|
||||
currentRoleIds != null && currentRoleIds.contains("2"));
|
||||
if (!isAdmin) {
|
||||
// 只有非管理员用户才根据部门类型设置角色
|
||||
user.setRoleIds("receiving".equals(primaryDept.getDeptType()) ? "5" : "6");
|
||||
String newRoleIds = "receiving".equals(primaryDept.getDeptType()) ? "5" : "6";
|
||||
log.info("syncUserFromDingTalk - 非管理员用户,设置角色: userId={}, newRoleIds={}",
|
||||
user.getId(), newRoleIds);
|
||||
user.setRoleIds(newRoleIds);
|
||||
} else {
|
||||
log.info("用户已是管理员,保留管理员角色: userId={}, roleIds={}",
|
||||
user.getId(), currentRoleIds);
|
||||
@ -541,11 +549,17 @@ public class UserService {
|
||||
user.setDeptName(defaultDept.getDeptName());
|
||||
// 根据部门类型设置角色(但如果用户已经是管理员,保留管理员角色)
|
||||
String currentRoleIds = user.getRoleIds();
|
||||
log.info("syncUserFromDingTalk - 检查管理员角色(默认部门): userId={}, currentRoleIds={}",
|
||||
user.getId(), currentRoleIds);
|
||||
boolean isAdmin = currentRoleIds != null &&
|
||||
(currentRoleIds.contains("1") || currentRoleIds.contains("2"));
|
||||
log.info("syncUserFromDingTalk - isAdmin={}", isAdmin);
|
||||
if (!isAdmin) {
|
||||
// 只有非管理员用户才根据部门类型设置角色
|
||||
user.setRoleIds("receiving".equals(defaultDept.getDeptType()) ? "5" : "6");
|
||||
String newRoleIds = "receiving".equals(defaultDept.getDeptType()) ? "5" : "6";
|
||||
log.info("syncUserFromDingTalk - 非管理员用户,设置角色: userId={}, newRoleIds={}",
|
||||
user.getId(), newRoleIds);
|
||||
user.setRoleIds(newRoleIds);
|
||||
} else {
|
||||
log.info("用户已是管理员,保留管理员角色: userId={}, roleIds={}",
|
||||
user.getId(), currentRoleIds);
|
||||
@ -711,8 +725,9 @@ public class UserService {
|
||||
}
|
||||
} else {
|
||||
// 已有用户:同步更新信息
|
||||
log.info("钉钉用户已存在,同步更新: userId={}", user.getId());
|
||||
log.info("钉钉用户已存在,同步更新: userId={}, 当前roleIds={}", user.getId(), user.getRoleIds());
|
||||
syncUserFromDingTalk(user, detailedInfo, dingtalkUserId, dingDepartments);
|
||||
log.info("钉钉用户同步完成: userId={}, 最终roleIds={}", user.getId(), user.getRoleIds());
|
||||
}
|
||||
|
||||
// 5. 生成Token
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user