From 0e12e4ab45db6768a0f45d8952f78b0ae9190723 Mon Sep 17 00:00:00 2001 From: ZQN <364596817@qq.com> Date: 星期一, 19 五月 2025 16:09:01 +0800 Subject: [PATCH] 手机号登录,去掉短信验证。脱敏 --- project-system/src/main/java/com/project/system/service/impl/SysDeptServiceImpl.java | 43 ++++++++++++++++++++++++++++++++++++++++++- 1 files changed, 42 insertions(+), 1 deletions(-) diff --git a/project-system/src/main/java/com/project/system/service/impl/SysDeptServiceImpl.java b/project-system/src/main/java/com/project/system/service/impl/SysDeptServiceImpl.java index 9d3b4be..c2ac98b 100644 --- a/project-system/src/main/java/com/project/system/service/impl/SysDeptServiceImpl.java +++ b/project-system/src/main/java/com/project/system/service/impl/SysDeptServiceImpl.java @@ -1,5 +1,7 @@ package com.project.system.service.impl; +import cn.hutool.core.collection.CollectionUtil; +import cn.hutool.core.util.StrUtil; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.project.common.annotation.DataScope; import com.project.common.constant.UserConstants; @@ -19,6 +21,7 @@ import org.springframework.stereotype.Service; import java.util.ArrayList; +import java.util.Collections; import java.util.Iterator; import java.util.List; import java.util.stream.Collectors; @@ -302,7 +305,7 @@ public Long getCheckDeptIdByLoginDeptId(Long deptId) { SysDept loginDept = selectDeptById(deptId); - if (loginDept.getParentId()==100){ + if (loginDept.getDeptId()==100 || loginDept.getParentId()==100){ return loginDept.getDeptId(); } else { return getCheckDeptIdByLoginDeptId(loginDept.getParentId()); @@ -318,6 +321,18 @@ public List<Long> getApplyDeptIdsByLoginUserId(Long userId) { return deptMapper.getApplyDeptIdsByLoginUserId(userId); + } + + @Override + public String getDeptAllName(Long deptId) + { + List<String> names = new ArrayList<>(); + names = getAncestorsNames(deptId, names); + if (CollectionUtil.isEmpty(names)){ + return ""; + } + Collections.reverse(names); + return StrUtil.join("-", names); } /** @@ -362,4 +377,30 @@ { return getChildList(list, t).size() > 0; } + + + /** + * 鑾峰彇绁栫睄names鍒楄〃 + * + * @param deptId 褰撳墠閮ㄩ棬id + * @param names 绁栫睄id鍒楄〃 + * @return names鍒楄〃 + */ + public List<String> getAncestorsNames(long deptId, List<String> names) { + SysDept dept = deptMapper.selectDeptById(deptId); + if (dept == null) { + return names; + } + if (deptId == 100) { + names.add(dept.getDeptName()); + return names; + } + if (dept.getParentId() != null && dept.getParentId() == 100) { + names.add(dept.getDeptName()); + return names; + } else { + names.add(dept.getDeptName()); + return getAncestorsNames(dept.getParentId(), names); + } + } } -- Gitblit v1.9.1