|
|
@@ -25,6 +25,7 @@ import com.xunmei.system.api.vo.SysOrgVO;
|
|
|
import com.xunmei.system.mapper.SysOrgMapper;
|
|
|
import com.xunmei.system.mapper.SysUserMapper;
|
|
|
import com.xunmei.system.service.ISysOrgService;
|
|
|
+import io.netty.util.internal.StringUtil;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.scheduling.annotation.Async;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
@@ -552,11 +553,26 @@ public class SysOrgServiceImpl extends ServiceImpl<SysOrgMapper, SysOrg> impleme
|
|
|
public SysOrg selectByShortName(String shortName) {
|
|
|
List<SysOrg> sysOrgs = baseMapper.selectByShortName(shortName);
|
|
|
if (!CollectionUtil.isEmpty(sysOrgs)) {
|
|
|
- if(sysOrgs.size()>1){
|
|
|
+ if (sysOrgs.size() > 1) {
|
|
|
throw new RuntimeException("机构名称重复,导入失败;请检查后重试");
|
|
|
}
|
|
|
return sysOrgs.get(0);
|
|
|
}
|
|
|
return null;
|
|
|
}
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public String selectOrgNameByPath(Long orgId) {
|
|
|
+ List<SysOrgVO> orgCache = getOrgCache();
|
|
|
+ Optional<SysOrgVO> first = orgCache.stream().filter(org -> org.getId().equals(orgId)).findFirst();
|
|
|
+ if (!first.isPresent()) {
|
|
|
+ return StringUtil.EMPTY_STRING;
|
|
|
+ }
|
|
|
+ List<Long> collect = Arrays.stream(first.get().getPath().split("-")).map(Long::valueOf).collect(Collectors.toList());
|
|
|
+ List<String> list = new ArrayList<>();
|
|
|
+ collect.forEach(id -> {
|
|
|
+ orgCache.stream().filter(org -> org.getId().equals(id)).findFirst().ifPresent(org -> list.add(org.getName()));
|
|
|
+ });
|
|
|
+ return String.join("_", list);
|
|
|
+ }
|
|
|
}
|