add new field for operate log

This commit is contained in:
pepsi 2022-10-14 14:41:36 +08:00
parent 135ddca115
commit 1a61f6f395
4 changed files with 25 additions and 12 deletions

View File

@ -128,14 +128,14 @@
<artifactId>basics-profiles-api</artifactId>
</dependency>
<!-- 测试 client 使用
<dependency>
<groupId>cn.axzo.platform</groupId>
<artifactId>axzo-log-api</artifactId>
<version>1.0.0-SNAPSHOT</version>
<scope>test</scope>
</dependency>
-->
</dependencies>
<build>

View File

@ -41,6 +41,7 @@ public class OperateLogController {
BindingResult bindingResult) {
//参数缺失等返回
if (bindingResult.hasErrors()) {
logger.warn("illegal param for create operate log.");
return CommonResponse.fail(bindingResult.getAllErrors().get(0).getDefaultMessage());
}
try {

View File

@ -221,7 +221,7 @@ public class OperateLogServiceImpl extends BaseEsService implements OperateLogSe
OperateLogRecordEntity unifiedLogRecord = operateLogConverter.toEntity(req);
//判断是否已经传手机和姓名存在,如果不存在则(通过接口调用获取用户手机姓名)
if (!StringUtils.hasText(unifiedLogRecord.getIdentityUserPhone())
|| StringUtils.hasText(unifiedLogRecord.getIdentityUserName())) {
|| !StringUtils.hasText(unifiedLogRecord.getIdentityUserName())) {
IdentityProfileDto identityProfile = qryIdentityProfile(req.getIdentityId(), req.getIdentityType());
if (identityProfile != null && identityProfile.getPersonProfile() != null) {
unifiedLogRecord.setIdentityUserName(identityProfile.getPersonProfile().getRealName());
@ -229,10 +229,16 @@ public class OperateLogServiceImpl extends BaseEsService implements OperateLogSe
}
}
// 通过接口方式调用 workspaceApi单位等信息,
GetDetailRes workspaceInf = qryWorkspaceInfo(req.getWorkspaceId());
unifiedLogRecord.setWorkspaceName(null != workspaceInf ? workspaceInf.getName() : null);
OrganizationalUnitVO ouInf = qryOrgUnitInf(req.getOuId());
unifiedLogRecord.setOuName(ouInf != null ? ouInf.getName() : null);
if (unifiedLogRecord.getWorkspaceId() != null
&& unifiedLogRecord.getWorkspaceId() > 0) {
GetDetailRes workspaceInf = qryWorkspaceInfo(req.getWorkspaceId());
unifiedLogRecord.setWorkspaceName(null != workspaceInf ? workspaceInf.getName() : null);
}
if (unifiedLogRecord.getOuId() != null
&& unifiedLogRecord.getOuId() > 0) {
OrganizationalUnitVO ouInf = qryOrgUnitInf(req.getOuId());
unifiedLogRecord.setOuName(ouInf != null ? ouInf.getName() : null);
}
return unifiedLogRecord;
}
@ -361,12 +367,18 @@ public class OperateLogServiceImpl extends BaseEsService implements OperateLogSe
}
/**
* 通过 identityId & identityType 获取用户信息
*
* @param identityId
* @param identityType
* @return
*/
private IdentityProfileDto qryIdentityProfile(Long identityId, Integer identityType) {
//todo 需要根据类型判断用那个接口查询
//todo 需要根据类型判断用那个接口查询先写死
if (identityType == 5) {
}
List<Long> ids = new ArrayList<>();
ids.add(identityId);
CommonResponse<List<IdentityProfileDto>> response = profileServiceApi.getIdentitiesByIdSet(ids, identityType);
@ -374,8 +386,8 @@ public class OperateLogServiceImpl extends BaseEsService implements OperateLogSe
throw new ServiceException(response.getMsg());
}
List<IdentityProfileDto> profileList = response.getData();
if (profileList.size() != 1) {
return null;
if (profileList == null || profileList.isEmpty()) {
throw new ServiceException(String.format("can not get identity profile,identityId=%s,identityType=%s", identityId, identityType));
}
return profileList.get(0);
}

View File

@ -31,8 +31,8 @@ public class LogPlatClientTest extends LogPlatApplicationTestBase {
req.setFeatureName("FeatureName");
req.setLogGrade(4);
req.setOperateTime(new Date());
req.setIdentityId(1L);
req.setIdentityType(1);
req.setIdentityId(81L);
req.setIdentityType(5);
req.setWorkspaceId(1L);
req.setOuId(1L);
req.setTerminal("macos");