bug fix
parent
8e19dc4581
commit
4bc477aba1
|
|
@ -80,7 +80,7 @@ public class InstitutionDashboardExecutor implements InstitutionDashboardApi {
|
|||
|
||||
@Override
|
||||
public SingleResponse<InstitutionDashboardProjectNodeStatsCO> projectNodeStats() {
|
||||
Long orgId = ThreadLocalUserInfoAdapter.getOrgId() ;
|
||||
Long orgId = institutionOrgSupport.resolveCurrentOrgIdByUserId();
|
||||
if (orgId == null) {
|
||||
return SingleResponse.success(new InstitutionDashboardProjectNodeStatsCO());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,9 @@
|
|||
package org.qinan.safetyeval.infrastructure.support;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import org.qinan.safetyeval.infrastructure.dataobject.OrgInfoDO;
|
||||
import org.qinan.safetyeval.infrastructure.dataobject.OrgPersonnelDO;
|
||||
import org.qinan.safetyeval.infrastructure.mapper.OrgInfoMapper;
|
||||
import org.qinan.safetyeval.infrastructure.mapper.OrgPersonnelMapper;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
|
|
@ -32,6 +35,9 @@ public class UserOrgIdResolver {
|
|||
@Resource
|
||||
private OrgPersonnelMapper orgPersonnelMapper;
|
||||
|
||||
@Resource
|
||||
private OrgInfoMapper orgInfoMapper;
|
||||
|
||||
private final Map<Long, CacheEntry> cache = new ConcurrentHashMap<>();
|
||||
|
||||
/**
|
||||
|
|
@ -72,7 +78,25 @@ public class UserOrgIdResolver {
|
|||
|
||||
private Long queryOrgIdByUserId(Long userId) {
|
||||
OrgPersonnelDO personnel = orgPersonnelMapper.selectById(userId);
|
||||
return personnel == null ? null : personnel.getOrgId();
|
||||
if (personnel != null) {
|
||||
return personnel.getOrgId();
|
||||
}
|
||||
// 兜底:用户可能是机构注册人(org_info.create_id = userId),取其创建的机构
|
||||
return queryOrgIdByCreator(userId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据创建人 id 反查其创建的机构 orgId。
|
||||
*
|
||||
* @param userId 创建人 id(org_info.create_id)
|
||||
* @return 机构 orgId;未创建过机构返回 null
|
||||
*/
|
||||
private Long queryOrgIdByCreator(Long userId) {
|
||||
OrgInfoDO orgInfo = orgInfoMapper.selectOne(new LambdaQueryWrapper<OrgInfoDO>()
|
||||
.select(OrgInfoDO::getId)
|
||||
.eq(OrgInfoDO::getCreateId, userId)
|
||||
.last("limit 1"));
|
||||
return orgInfo == null ? null : orgInfo.getId();
|
||||
}
|
||||
|
||||
private static class CacheEntry {
|
||||
|
|
|
|||
Loading…
Reference in New Issue