Selaa lähdekoodia

审批回调修改。定时任务启动授权添加

mazq 1 vuosi sitten
vanhempi
sitoutus
7728f86eee

+ 29 - 1
dcuc-auth-service/src/main/java/com/dragoninfo/dcuc/auth/auth/service/impl/zerotrust/RoleAuthApplyServiceImpl.java

@@ -1,9 +1,9 @@
 package com.dragoninfo.dcuc.auth.auth.service.impl.zerotrust;
 
 import cn.hutool.core.bean.BeanUtil;
-import com.dragoninfo.dcuc.auth.auth.dto.zerotrust.authapply.RoleAuthApplyDto;
 import com.dragoninfo.dcuc.auth.auth.dto.zerotrust.approval.FlowApplyReqDto;
 import com.dragoninfo.dcuc.auth.auth.dto.zerotrust.approval.FlowSubmitRespDTO;
+import com.dragoninfo.dcuc.auth.auth.dto.zerotrust.authapply.RoleAuthApplyDto;
 import com.dragoninfo.dcuc.auth.auth.entity.zerotrust.RoleAuthApply;
 import com.dragoninfo.dcuc.auth.auth.enumresources.zerotrust.approval.ApprovalApplyTypeEnum;
 import com.dragoninfo.dcuc.auth.auth.enumresources.zerotrust.approval.AuthApplyStatusEnum;
@@ -20,6 +20,7 @@ import com.dragoninfo.dcuc.common.utils.ResponseUtil;
 import com.dragonsoft.duceap.base.entity.http.ResponseDTO;
 import com.dragonsoft.duceap.base.entity.http.ResponseStatus;
 import com.dragonsoft.duceap.base.entity.security.BaseSecurityUser;
+import com.dragonsoft.duceap.base.enums.BooleanEnum;
 import com.dragonsoft.duceap.base.utils.UserContextUtils;
 import com.dragonsoft.duceap.commons.util.UUIDUtils;
 import com.dragonsoft.duceap.commons.util.collections.CollectionUtils;
@@ -28,9 +29,11 @@ import com.dragonsoft.duceap.commons.util.string.StringUtils;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.data.domain.Example;
+import org.springframework.data.jpa.domain.Specification;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
+import javax.persistence.criteria.Predicate;
 import java.time.LocalDate;
 import java.time.format.DateTimeFormatter;
 import java.util.*;
@@ -96,6 +99,7 @@ public class RoleAuthApplyServiceImpl implements IRoleAuthApplyService {
         return format + "-" + applyUserName + "角色授权申请";
     }
 
+    @Transactional(rollbackFor = Exception.class)
     @Override
     public ResponseStatus applyAndPushToApproval(RoleAuthApplyDto roleAuthApplyDto, String taskTypeClass) {
         String title = getRoleAuthApplyTitle(UserContextUtils.getCurrentUser().getName());
@@ -161,6 +165,30 @@ public class RoleAuthApplyServiceImpl implements IRoleAuthApplyService {
         repository.updateApprovalResult(processInstId, approvalResult);
     }
 
+    @Override
+    public List<RoleAuthApply> getStartToAuth() {
+        Specification<RoleAuthApply> specification = (root, query, cb) -> {
+            // 已经审批同意的申请单
+            Predicate approvalResult = cb.equal(root.get("approvalResult"), AuthApplyStatusEnum.AGREE.getValue());
+            // 待授权的记录
+            Predicate toAuth = cb.equal(root.get("toBeAuthed"), BooleanEnum.TRUE.getValue());
+            // 到达有效期内的申请内容
+            Predicate startTime = cb.lessThanOrEqualTo(root.get("startTime").as(Date.class), new Date());
+            return cb.and(approvalResult, toAuth, startTime);
+        };
+        return repository.findAll(specification);
+    }
+
+    @Transactional(rollbackFor = Exception.class)
+    @Override
+    public void setToBeAuthed(List<RoleAuthApply> tobeAuthed, String value) {
+        if (CollectionUtils.isEmpty(tobeAuthed)) {
+            return;
+        }
+        List<String> ids = tobeAuthed.stream().map(RoleAuthApply::getId).collect(Collectors.toList());
+        repository.setToBeAuthed(ids, value);
+    }
+
     private Map<String, String> getBizData(RoleAuthApplyDto applyDto) {
         Map<String, String> bizData = new HashMap<>();
         List<Map<String, String>> list = new ArrayList<>();

+ 28 - 3
dcuc-auth-service/src/main/java/com/dragoninfo/dcuc/auth/auth/service/impl/zerotrust/ServiceAuthApplyServiceImpl.java

@@ -2,23 +2,21 @@ package com.dragoninfo.dcuc.auth.auth.service.impl.zerotrust;
 
 import com.dragoninfo.dcuc.auth.auth.dto.zerotrust.approval.FlowApplyReqDto;
 import com.dragoninfo.dcuc.auth.auth.dto.zerotrust.approval.FlowSubmitRespDTO;
-import com.dragoninfo.dcuc.auth.auth.dto.zerotrust.authapply.RoleAuthApplyDto;
 import com.dragoninfo.dcuc.auth.auth.dto.zerotrust.authapply.ServiceAuthApplyDto;
 import com.dragoninfo.dcuc.auth.auth.entity.zerotrust.ServiceAuthApply;
 import com.dragoninfo.dcuc.auth.auth.enumresources.zerotrust.approval.ApprovalApplyTypeEnum;
 import com.dragoninfo.dcuc.auth.auth.enumresources.zerotrust.approval.AuthApplyStatusEnum;
 import com.dragoninfo.dcuc.auth.auth.repo.zerotrust.ServiceAuthApplyRepository;
 import com.dragoninfo.dcuc.auth.auth.service.zerotrust.IServiceAuthApplyService;
-import com.dragoninfo.dcuc.auth.auth.vo.zerotrust.roleauthapply.ApplyRoleInVo;
 import com.dragoninfo.dcuc.auth.business.zerotrust.IZeroTrustApprovalBusiness;
 import com.dragoninfo.dcuc.auth.config.zerotrust.ApprovalProperties;
 import com.dragoninfo.dcuc.auth.sub.vo.ApplyInfoVo;
-import com.dragoninfo.dcuc.auth.sub.vo.AuthUserVo;
 import com.dragoninfo.dcuc.auth.sub.vo.ServiceResourceVo;
 import com.dragoninfo.dcuc.common.utils.ResponseUtil;
 import com.dragonsoft.duceap.base.entity.http.ResponseDTO;
 import com.dragonsoft.duceap.base.entity.http.ResponseStatus;
 import com.dragonsoft.duceap.base.entity.security.BaseSecurityUser;
+import com.dragonsoft.duceap.base.enums.BooleanEnum;
 import com.dragonsoft.duceap.base.utils.UserContextUtils;
 import com.dragonsoft.duceap.commons.util.UUIDUtils;
 import com.dragonsoft.duceap.commons.util.collections.CollectionUtils;
@@ -27,9 +25,11 @@ import com.dragonsoft.duceap.commons.util.string.StringUtils;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.data.domain.Example;
+import org.springframework.data.jpa.domain.Specification;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
+import javax.persistence.criteria.Predicate;
 import java.time.LocalDate;
 import java.time.format.DateTimeFormatter;
 import java.util.*;
@@ -72,6 +72,7 @@ public class ServiceAuthApplyServiceImpl implements IServiceAuthApplyService {
         return format + "-" + applyUserName + "服务授权申请";
     }
 
+    @Transactional(rollbackFor = Exception.class)
     @Override
     public ResponseStatus applyAndPushToApproval(ServiceAuthApplyDto authApplyDto, String taskTypeClass) {
         String title = getAuthApplyTitle(UserContextUtils.getCurrentUser().getName());
@@ -136,6 +137,30 @@ public class ServiceAuthApplyServiceImpl implements IServiceAuthApplyService {
         repository.updateApprovalResult(processInstId, approvalResult);
     }
 
+    @Override
+    public List<ServiceAuthApply> getStartToAuth() {
+        Specification<ServiceAuthApply> specification = (root, query, cb) -> {
+            // 已经审批同意的申请单
+            Predicate approvalResult = cb.equal(root.get("approvalResult"), AuthApplyStatusEnum.AGREE.getValue());
+            // 待授权的记录
+            Predicate toAuth = cb.equal(root.get("toBeAuthed"), BooleanEnum.TRUE.getValue());
+            // 到达有效期内的申请内容
+            Predicate startTime = cb.lessThanOrEqualTo(root.get("startTime").as(Date.class), new Date());
+            return cb.and(approvalResult, toAuth, startTime);
+        };
+        return repository.findAll(specification);
+    }
+
+    @Transactional(rollbackFor = Exception.class)
+    @Override
+    public void setToBeAuthed(List<ServiceAuthApply> tobeAuthed, String value) {
+        if (CollectionUtils.isEmpty(tobeAuthed)) {
+            return;
+        }
+        List<String> ids = tobeAuthed.stream().map(ServiceAuthApply::getId).collect(Collectors.toList());
+        repository.setToBeAuthed(ids, value);
+    }
+
     private Map<String, String> getBizData(ServiceAuthApplyDto applyDto) {
         Map<String, String> bizData = new HashMap<>();
         List<Map<String, String>> list = new ArrayList<>();