修复钉钉登录:使用官方logo SVG路径,优化部门匹配逻辑(匹配失败时使用默认部门)

This commit is contained in:
Your Name 2026-01-02 13:26:14 +08:00
parent 7f89ceb66d
commit 949eecaf37
2 changed files with 39 additions and 17 deletions

View File

@ -610,23 +610,45 @@ public class UserService {
log.info("自动匹配到系统部门: deptId={}, deptName={}, type={}",
matchedDeptId, dept.getDeptName(), dept.getDeptType());
} else {
// 无法自动匹配,需要用户手动选择
String deptNamesStr = dingDepartments.stream()
.map(d -> String.valueOf(d.get("name")))
.collect(Collectors.joining(", "));
log.warn("无法自动匹配系统部门,钉钉部门: {}", deptNamesStr);
user.setDeptId(null);
user.setDeptName(null);
user.setRoleIds(null);
user.setStatus(0); // 暂时禁用,待选择部门后启用
// 无法自动匹配,使用第一个可用部门作为默认值
List<Department> availableDepts = departmentMapper.selectList(
new LambdaQueryWrapper<Department>()
.eq(Department::getStatus, 1)
.eq(Department::getDeleted, 0)
.orderByAsc(Department::getSortOrder)
.orderByAsc(Department::getId)
);
if (!availableDepts.isEmpty()) {
// 使用第一个可用部门作为默认值
Department defaultDept = availableDepts.get(0);
user.setDeptId(defaultDept.getId());
user.setDeptName(defaultDept.getDeptName());
user.setRoleIds("receiving".equals(defaultDept.getDeptType()) ? "5" : "6");
log.warn("无法自动匹配系统部门,使用默认部门: deptId={}, deptName={}, 钉钉部门: {}",
defaultDept.getId(), defaultDept.getDeptName(),
dingDepartments.stream()
.map(d -> String.valueOf(d.get("name")))
.collect(Collectors.joining(", ")));
} else {
// 如果系统没有任何部门,才需要用户手动选择
String deptNamesStr = dingDepartments.stream()
.map(d -> String.valueOf(d.get("name")))
.collect(Collectors.joining(", "));
log.warn("无法自动匹配系统部门,且系统无可用部门,钉钉部门: {}", deptNamesStr);
user.setDeptId(null);
user.setDeptName(null);
user.setRoleIds(null);
user.setStatus(0); // 暂时禁用,待选择部门后启用
}
}
userMapper.insert(user);
log.info("钉钉用户创建成功: userId={}, username={}, needSelectDept={}",
user.getId(), user.getUsername(), matchedDeptId == null);
// 如果需要选择部门,抛出特殊异常
if (matchedDeptId == null) {
// 如果需要选择部门(系统无任何可用部门的情况),抛出特殊异常
if (user.getDeptId() == null) {
String deptInfo = dingDepartments.isEmpty() ? "无钉钉部门信息" :
dingDepartments.stream()
.map(d -> String.valueOf(d.get("name")))

View File

@ -198,12 +198,12 @@
@click="handleDingTalkLogin"
:loading="dingTalkLoginLoading"
>
<!-- 钉钉logo - 白色圆形带内部图形 -->
<svg class="dingtalk-logo" viewBox="0 0 64 64" width="20" height="20" fill="currentColor" xmlns="http://www.w3.org/2000/svg">
<circle cx="32" cy="32" r="28" fill="currentColor"/>
<circle cx="32" cy="32" r="24" fill="none" stroke="white" stroke-width="2"/>
<circle cx="32" cy="24" r="3" fill="white"/>
<rect x="29" y="30" width="6" height="8" rx="1" fill="white"/>
<!-- 钉钉官方logo SVG - 使用白色版本 -->
<svg class="dingtalk-logo" viewBox="0 0 1024 1024" width="20" height="20" xmlns="http://www.w3.org/2000/svg">
<path
d="M512 2C230.2 2 2 230.2 2 512s228.2 510 510 510 510-228.2 510-510S793.3 2 512 2z m235.9 442c-1 4.6-3.6 10.8-7.2 19.1l-0.5 0.5c-21.6 45.8-77.3 135.5-77.3 135.5l-0.5-0.5-16.5 28.3h78.8L574.3 826.8l34-136h-61.8l21.6-90.2c-17.5 4.1-38.1 9.8-62.3 18 0 0-33 19.1-94.8-37.1 0 0-41.7-37.1-17.5-45.8 10.3-4.1 50-8.8 81.4-12.9 42.2-5.7 68.5-8.8 68.5-8.8s-130.3 2.1-161.2-3.1c-30.9-4.6-70.1-56.7-78.3-102 0 0-12.9-24.7 27.8-12.9 40.2 11.8 209.2 45.8 209.2 45.8S321.4 375 307 358.5c-14.4-16.5-42.8-89.6-39.2-134.5 0 0 1.5-11.3 12.9-8.2 0 0 161.8 74.2 272.5 114.4C664.5 371.4 760.8 392 747.9 444z"
fill="currentColor"
/>
</svg>
钉钉登录
</a-button>