Bläddra i källkod

创建时间字段补充

mazq 1 år sedan
förälder
incheckning
ebd2c7bac8

+ 13 - 0
dcuc-auth-service/src/main/java/com/dragoninfo/dcuc/auth/auth/service/impl/zerotrust/ApprovalResultServiceImpl.java

@@ -3,6 +3,8 @@ package com.dragoninfo.dcuc.auth.auth.service.impl.zerotrust;
 import com.dragoninfo.dcuc.auth.auth.entity.zerotrust.ApprovalResult;
 import com.dragoninfo.dcuc.auth.auth.repo.zerotrust.ApprovalResultRepository;
 import com.dragoninfo.dcuc.auth.auth.service.zerotrust.IApprovalResultService;
+import com.dragonsoft.duceap.base.entity.security.BaseSecurityUser;
+import com.dragonsoft.duceap.base.utils.UserContextUtils;
 import com.dragonsoft.duceap.commons.util.string.StringUtils;
 import org.apache.commons.collections4.CollectionUtils;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -10,7 +12,9 @@ import org.springframework.data.domain.Example;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
+import java.util.Date;
 import java.util.List;
+import java.util.Optional;
 import java.util.stream.Collectors;
 
 /**
@@ -27,14 +31,23 @@ public class ApprovalResultServiceImpl implements IApprovalResultService {
         this.repository = repository;
     }
 
+    @Transactional(rollbackFor = Exception.class)
     @Override
     public void save(ApprovalResult approvalResult) {
+        approvalResult.setCreateTime(new Date());
+        String userId = Optional.ofNullable(UserContextUtils.getCurrentUser())
+                .map(e -> ((BaseSecurityUser) e).getId()).orElse("");
+        approvalResult.setCreateUser(userId);
         repository.save(approvalResult);
     }
 
     @Transactional(rollbackFor = Exception.class)
     @Override
     public void update(ApprovalResult approvalResult) {
+        approvalResult.setUpdateTime(new Date());
+        String updateUserId = Optional.ofNullable(UserContextUtils.getCurrentUser())
+                .map(e -> ((BaseSecurityUser) e).getId()).orElse("");
+        approvalResult.setUpdateUser(updateUserId);
         repository.update(approvalResult);
     }
 

+ 2 - 0
dcuc-auth-service/src/main/java/com/dragoninfo/dcuc/auth/auth/service/impl/zerotrust/RoleAuthApplyServiceImpl.java

@@ -144,6 +144,8 @@ public class RoleAuthApplyServiceImpl implements IRoleAuthApplyService {
             roleAuthApply.setStartTime(startTime);
             roleAuthApply.setEndTime(endTime);
             roleAuthApply.setApprovalResult(AuthApplyStatusEnum.APPLYING.getValue());
+            roleAuthApply.setCreateTime(new Date());
+            roleAuthApply.setCreateUser(UserContextUtils.getCurrentUser().getId());
             return roleAuthApply;
         }).collect(Collectors.toList());
 

+ 2 - 0
dcuc-auth-service/src/main/java/com/dragoninfo/dcuc/auth/auth/service/impl/zerotrust/ServiceAuthApplyServiceImpl.java

@@ -118,6 +118,8 @@ public class ServiceAuthApplyServiceImpl implements IServiceAuthApplyService {
             authApply.setApprovalResult(AuthApplyStatusEnum.APPLYING.getValue());
             authApply.setStartTime(startTime);
             authApply.setEndTime(endTime);
+            authApply.setCreateTime(new Date());
+            authApply.setCreateUser(UserContextUtils.getCurrentUser().getId());
             return authApply;
         }).collect(Collectors.toList());