|
@@ -0,0 +1,96 @@
|
|
|
+package com.dragoninfo.dcuc.auth.audit.service;
|
|
|
+
|
|
|
+import cn.hutool.core.util.StrUtil;
|
|
|
+import com.dragoninfo.dcuc.auth.audit.config.AuditConfig;
|
|
|
+import com.dragoninfo.dcuc.auth.audit.constance.AuditConstance;
|
|
|
+import com.dragoninfo.dcuc.auth.audit.dto.AuthorizeHandlerDto;
|
|
|
+import com.dragoninfo.dcuc.auth.audit.dto.AuthorizeLogDto;
|
|
|
+import com.dragoninfo.dcuc.auth.audit.dto.AuthorizeObjectDto;
|
|
|
+import com.dragoninfo.dcuc.auth.audit.dto.AuthorizeSubjectDto;
|
|
|
+import com.dragoninfo.dcuc.auth.audit.enums.AuthenticationTypeEnum;
|
|
|
+import com.dragoninfo.dcuc.auth.audit.enums.AuthorizeTypeEnum;
|
|
|
+import com.dragonsoft.auditlog.collection.qmtj.LogSendComponent;
|
|
|
+import com.dragonsoft.auditlog.collection.qmtj.pojo.req.AuthBusLog;
|
|
|
+import com.dragonsoft.duceap.commons.util.collections.CollectionUtils;
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
+
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.Date;
|
|
|
+import java.util.List;
|
|
|
+import java.util.stream.Collectors;
|
|
|
+
|
|
|
+
|
|
|
+ * @author mazq
|
|
|
+ * @date 2021/7/28
|
|
|
+ */
|
|
|
+@Slf4j
|
|
|
+@Service
|
|
|
+public class QmAuditPushService {
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private LogSendComponent logSendComponent;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private AuditConfig config;
|
|
|
+
|
|
|
+
|
|
|
+ public void PushAuthorizeLog(AuthorizeLogDto authorizeLogDto) {
|
|
|
+ String sysId = config.getSysId();
|
|
|
+ String logType = AuditConstance.AUDIT_LOG_TYPE_SQ;
|
|
|
+ List<AuthBusLog> busLogs = getAuthBusLog(authorizeLogDto);
|
|
|
+ if(CollectionUtils.isNotEmpty(busLogs)) {
|
|
|
+ logSendComponent.sendAuthBusLog(sysId, logType, busLogs);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private List<AuthBusLog> getAuthBusLog(AuthorizeLogDto authorizeLogDto) {
|
|
|
+ String authorizeType = authorizeLogDto.getAuthorizeType();
|
|
|
+ List<AuthBusLog> list = new ArrayList<>();
|
|
|
+ if(AuthorizeTypeEnum.GNSQ.getValue().equals(authorizeType)) {
|
|
|
+ list = getGnsqBusLog(authorizeLogDto);
|
|
|
+ }
|
|
|
+ return list;
|
|
|
+ }
|
|
|
+
|
|
|
+ private List<AuthBusLog> getGnsqBusLog(AuthorizeLogDto authorizeLogDto) {
|
|
|
+ List<AuthBusLog> list = new ArrayList<>();
|
|
|
+ Date createTime = authorizeLogDto.getCreateTime();
|
|
|
+ String timeStr = "";
|
|
|
+ if(null != createTime) {
|
|
|
+ long time = createTime.getTime();
|
|
|
+ timeStr = String.valueOf(time);
|
|
|
+ }
|
|
|
+ AuthorizeHandlerDto handlerDto = authorizeLogDto.getAuthorizeHandlers().get(0);
|
|
|
+ List<AuthorizeSubjectDto> subjectDtos = authorizeLogDto.getAuthorizeSubjects();
|
|
|
+ List<AuthorizeObjectDto> objectDtos = authorizeLogDto.getAuthorizeObjects();
|
|
|
+
|
|
|
+ for (AuthorizeSubjectDto subjectDto : subjectDtos) {
|
|
|
+ AuthBusLog authBusLog = new AuthBusLog();
|
|
|
+ authBusLog.setAuthType(AuditConstance.AUDIT_AUTH_TYPE_GNSQ);
|
|
|
+
|
|
|
+ authBusLog.setOperateType(AuditConstance.AUDIT_LOG_TYPE_SQ);
|
|
|
+ String operateUserId = handlerDto.getHandlerId();
|
|
|
+ authBusLog.setOperateUserId(operateUserId);
|
|
|
+ authBusLog.setOperateUserName(handlerDto.getHandlerName());
|
|
|
+ authBusLog.setOperateUserIdcard(handlerDto.getHandlerIdcard());
|
|
|
+ authBusLog.setOperateOrgCode(handlerDto.getHandlerOrgCode());
|
|
|
+ authBusLog.setOperateTime(timeStr);
|
|
|
+
|
|
|
+ String userId = subjectDto.getSubjectId();
|
|
|
+ authBusLog.setUserId(userId);
|
|
|
+ authBusLog.setUserName(subjectDto.getSubjectName());
|
|
|
+ String roleNames = objectDtos
|
|
|
+ .stream()
|
|
|
+ .map(AuthorizeObjectDto::getObjectName)
|
|
|
+ .collect(Collectors.joining(StrUtil.COMMA));
|
|
|
+
|
|
|
+ authBusLog.setRoleNames(roleNames);
|
|
|
+ list.add(authBusLog);
|
|
|
+ log.debug("getGnsqBusLog roleNames:{}, userId:{},operateUserId:{}", roleNames, userId, operateUserId);
|
|
|
+ }
|
|
|
+ return list;
|
|
|
+ }
|
|
|
+
|
|
|
+}
|