identityType=5情况获取平台用户信息

This commit is contained in:
tianliyong 2022-11-17 14:35:27 +08:00
parent 7ae800c196
commit 6e285e898a
2 changed files with 52 additions and 5 deletions

View File

@ -128,6 +128,11 @@
<artifactId>basics-profiles-api</artifactId>
</dependency>
<dependency>
<groupId>cn.axzo.pudge</groupId>
<artifactId>pudge-api</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.kafka</groupId>
<artifactId>spring-kafka</artifactId>

View File

@ -7,6 +7,7 @@ import cn.axzo.apollo.workspace.api.workspace.res.GetDetailRes;
import cn.axzo.basics.organizational.api.OrganizationalUnitApi;
import cn.axzo.basics.organizational.api.vo.response.OrganizationalUnitVO;
import cn.axzo.basics.profiles.api.UserProfileServiceApi;
import cn.axzo.basics.profiles.common.enums.IdentityType;
import cn.axzo.basics.profiles.dto.basic.IdentityProfileDto;
import cn.axzo.log.platform.server.dto.*;
import cn.axzo.log.platform.server.entity.OperateLogRecordEntity;
@ -16,6 +17,8 @@ import cn.axzo.log.platform.server.repository.OperateLogRepository;
import cn.axzo.log.platform.server.service.BaseEsService;
import cn.axzo.log.platform.server.service.OperateLogService;
import cn.axzo.log.platform.server.service.converter.OperateLogConverter;
import cn.axzo.pudge.api.PlatUserServiceApi;
import cn.axzo.pudge.api.dto.response.PlatUserSimpleInfoRes;
import cn.azxo.framework.common.model.CommonPageResponse;
import cn.azxo.framework.common.model.CommonResponse;
import cn.hutool.core.date.CalendarUtil;
@ -76,6 +79,9 @@ public class OperateLogServiceImpl extends BaseEsService implements OperateLogSe
@Resource
private WorkspaceApi workspaceApi;
@Resource
private PlatUserServiceApi platUserServiceApi;
@Resource
private UserProfileServiceApi profileServiceApi;
@ -223,10 +229,21 @@ public class OperateLogServiceImpl extends BaseEsService implements OperateLogSe
//判断是否已经传手机和姓名存在,如果不存在则(通过接口调用获取用户手机姓名)
if (!StringUtils.hasText(unifiedLogRecord.getIdentityUserPhone())
|| !StringUtils.hasText(unifiedLogRecord.getIdentityUserName())) {
IdentityProfileDto identityProfile = qryIdentityProfile(req.getIdentityId(), req.getIdentityType());
if (identityProfile != null && identityProfile.getPersonProfile() != null) {
unifiedLogRecord.setIdentityUserName(identityProfile.getPersonProfile().getRealName());
unifiedLogRecord.setIdentityUserPhone(identityProfile.getPersonProfile().getPhone());
// identityType=5单独处理如果是请求接口获取用户手机和姓名
Long identityId = req.getIdentityId();
Integer identityType = req.getIdentityType();
if (identityType == IdentityType.OPERATOR.getCode()) {
PlatUserSimpleInfoRes platUserSimpleInfo = queryPlatUserInfo(identityId);
if (platUserSimpleInfo != null) {
unifiedLogRecord.setIdentityUserName(platUserSimpleInfo.getName());
unifiedLogRecord.setIdentityUserPhone(platUserSimpleInfo.getPhone());
}
} else {
IdentityProfileDto identityProfile = qryIdentityProfile(identityId, identityType);
if (identityProfile != null && identityProfile.getPersonProfile() != null) {
unifiedLogRecord.setIdentityUserName(identityProfile.getPersonProfile().getRealName());
unifiedLogRecord.setIdentityUserPhone(identityProfile.getPersonProfile().getPhone());
}
}
}
// 通过接口方式调用 workspaceApi单位等信息,
@ -367,6 +384,30 @@ public class OperateLogServiceImpl extends BaseEsService implements OperateLogSe
return response.getData();
}
/**
* 通过identityId获取平台用户信息
* @param identityId
* @return
*/
private PlatUserSimpleInfoRes queryPlatUserInfo(Long identityId) throws ThirdApiException {
if (identityId == null) {
throw new ThirdApiException("illegal params,identityId is null");
}
List<Long> ids = new ArrayList<>();
ids.add(identityId);
cn.axzo.pudge.core.web.Result<List<PlatUserSimpleInfoRes>> result = platUserServiceApi.getByIds(ids);
if (result.getCode() != 200) {
logger.warn("query plat User with identityId failed,identityId={},errMsg={}.", identityId, result.getMsg());
throw new ThirdApiException(result.getMsg());
}
List<PlatUserSimpleInfoRes> platUserInfoList = result.getData();
if (platUserInfoList == null || platUserInfoList.isEmpty()) {
logger.warn("can not get plat user info,identityId={}." , identityId);
return null;
}
return platUserInfoList.get(0);
}
/**
* 通过 identityId & identityType 获取用户信息
*
@ -386,7 +427,8 @@ public class OperateLogServiceImpl extends BaseEsService implements OperateLogSe
}
List<IdentityProfileDto> profileList = response.getData();
if (profileList == null || profileList.isEmpty()) {
throw new ThirdApiException(String.format("can not get identity profile,identityId=%s,identityType=%s", identityId, identityType));
logger.warn("can not get identity profile,identityId={}, identityType={}", identityId, identityType);
return null;
}
return profileList.get(0);
}