流程实例id绑定

This commit is contained in:
yangsong 2023-09-27 17:34:52 +08:00
parent 43d3b81754
commit 9e466f621b
9 changed files with 177 additions and 14 deletions

View File

@ -1,12 +1,17 @@
package cn.axzo.tyr.client.feign;
import javax.validation.Valid;
import javax.validation.constraints.NotNull;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;
import cn.axzo.framework.domain.web.result.ApiResult;
import cn.axzo.tyr.client.model.vo.BindWorkflowInstantceVO;
import cn.axzo.tyr.client.model.vo.PermissionPointApplyVO;
import cn.axzo.tyr.client.model.vo.SubmitPermissionPointApplyVO;
import cn.axzo.tyr.client.model.vo.UpdatePermissionPointApplyVO;
@ -23,4 +28,10 @@ public interface PermissionPointApplyApi {
@PostMapping(value = "/api/v1/permissionPoint/apply/update-detail")
ApiResult<Void> updateDetail(@RequestBody@Valid UpdatePermissionPointApplyVO updateDetail);
@PostMapping(value = "/api/v1/permissionPoint/apply/bind")
ApiResult<Void> bindWorkflowInstantce(@RequestBody@Valid BindWorkflowInstantceVO bind);
@GetMapping(value = "/api/v1/permissionPoint/apply/tree")
ApiResult<PermissionPointApplyVO> getApplyTree(@RequestParam("applyId")@NotNull Long applyId);
}

View File

@ -0,0 +1,27 @@
package cn.axzo.tyr.client.model.vo;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import lombok.Data;
/**
* Bind
*
* @author yangsong
* @version 2023/09/27 15:16
**/
@Data
public class BindWorkflowInstantceVO {
/**
* 权限申请id
*/
@NotNull
private Long applyId;
/**
* 流程实例id
*/
@NotBlank
private String workflowInstantceId;
}

View File

@ -30,7 +30,7 @@ public class PermissionPointApplyVO {
/**
* 流程实例id
*/
private Long workflowInstantceId;
private String workflowInstantceId;
/**
* 状态 0:初始化 1:权限配置 2:已发布dev 3:已发布test 4:已发布pre 5:已发布生产 6:产品已验收名称
*/

View File

@ -32,16 +32,23 @@ public class SubmitPermissionPointApplyVO {
@NotNull
private Long businessTypeId;
private Long personId;
/**
* 5运营人员目前固定传5
*/
private Integer identityType;
/**
* 人员id
*/
private Long identityId;
/**
* 工作台id
*/
private Long workspaceId;
private String realName;
@NotNull
private Long createBy;
@ -69,7 +76,6 @@ public class SubmitPermissionPointApplyVO {
* 元素code
*/
private String featureCode;
/**
* 菜单icon
*/
@ -90,10 +96,15 @@ public class SubmitPermissionPointApplyVO {
private String linkExt;
/**
* 小程序AppID
* 小程序appId 如果是小程序 需要提交该字段
*/
private String microAppItemId;
private String appId;
/**
* 小程序identity 如果是小程序 需要提交该字段
*/
private String appIdentity;
private String description;
/**
* 排序
*/

View File

@ -1,9 +1,11 @@
package cn.axzo.tyr.server.controller.permission;
import cn.axzo.tyr.client.model.vo.PermissionPointApplyVO;
import org.springframework.web.bind.annotation.RestController;
import cn.axzo.framework.domain.web.result.ApiResult;
import cn.axzo.tyr.client.feign.PermissionPointApplyApi;
import cn.axzo.tyr.client.model.vo.BindWorkflowInstantceVO;
import cn.axzo.tyr.client.model.vo.SubmitPermissionPointApplyVO;
import cn.axzo.tyr.client.model.vo.UpdatePermissionPointApplyVO;
import cn.axzo.tyr.server.service.SaasFeatureApplyService;
@ -30,4 +32,16 @@ public class PermissionPointApplyController implements PermissionPointApplyApi {
public ApiResult<Void> updateDetail(UpdatePermissionPointApplyVO updateDetail) {
return null;
}
@Override
public ApiResult<Void> bindWorkflowInstantce(BindWorkflowInstantceVO bind) {
saasFeatureApplyService.bindWorkflowInstantce(bind);
return ApiResult.ok();
}
@Override
public ApiResult<PermissionPointApplyVO> getApplyTree(Long applyId) {
return null;
}
}

View File

@ -28,7 +28,7 @@ public class SaasFeatureApply extends BaseEntity<SaasFeatureApply> implements Se
/**
* 流程实例id
*/
private Long workflowInstantceId;
private String workflowInstantceId;
/**
* 状态 0:初始化 1:权限配置 2:已发布dev 3:已发布test 4:已发布pre 5:已发布生产 6:产品已验收名称
*/

View File

@ -100,11 +100,11 @@ public class SaasFeatureApplyDetail extends BaseEntity<SaasFeatureApplyDetail> i
/**
* 网关专属字段是否认证 0:无需要认证 1:需要认证
*/
private Integer needCert;
private Boolean needCert;
/**
* 网关专属字段是否授权 0:无需要授权 1:需要授权
*/
private Integer needAuth;
private Boolean needAuth;
/**
* 业务id
*/

View File

@ -1,5 +1,6 @@
package cn.axzo.tyr.server.service;
import cn.axzo.tyr.client.model.vo.BindWorkflowInstantceVO;
import cn.axzo.tyr.client.model.vo.SubmitPermissionPointApplyVO;
/**
@ -10,4 +11,6 @@ import cn.axzo.tyr.client.model.vo.SubmitPermissionPointApplyVO;
**/
public interface SaasFeatureApplyService {
Long saveApply(SubmitPermissionPointApplyVO apply);
void bindWorkflowInstantce(BindWorkflowInstantceVO bind);
}

View File

@ -1,17 +1,27 @@
package cn.axzo.tyr.server.service.impl;
import java.util.*;
import java.util.function.Function;
import java.util.stream.Collectors;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import cn.axzo.basics.common.constant.enums.TableIsDeleteEnum;
import cn.axzo.basics.common.exception.ServiceException;
import cn.axzo.framework.jackson.utility.JSON;
import cn.axzo.tyr.client.model.enums.PermissionPointApplyStatus;
import cn.axzo.tyr.client.model.permission.PermissionPointTreeNode;
import cn.axzo.tyr.client.model.vo.BindWorkflowInstantceVO;
import cn.axzo.tyr.client.model.vo.SubmitPermissionPointApplyVO;
import cn.axzo.tyr.server.common.constants.PermissionConstant;
import cn.axzo.tyr.server.repository.dao.SaasFeatureApplyDao;
import cn.axzo.tyr.server.repository.dao.SaasFeatureApplyDetailDao;
import cn.axzo.tyr.server.repository.entity.SaasFeatureApply;
import cn.axzo.tyr.server.repository.entity.SaasFeatureApplyDetail;
import cn.axzo.tyr.server.service.PermissionPointService;
import cn.axzo.tyr.server.service.SaasFeatureApplyDetailService;
import cn.axzo.tyr.server.service.SaasFeatureApplyService;
import lombok.RequiredArgsConstructor;
@ -30,7 +40,7 @@ public class SaasFeatureApplyServiceImpl implements SaasFeatureApplyService {
private final SaasFeatureApplyDao saasFeatureApplyDao;
private final SaasFeatureApplyDetailDao saasFeatureApplyDetailDao;
private final SaasFeatureApplyDetailService saasFeatureApplyDetailService;
private final PermissionPointService permissionPointService;
@Override
@Transactional(rollbackFor = Exception.class)
@ -48,21 +58,108 @@ public class SaasFeatureApplyServiceImpl implements SaasFeatureApplyService {
return saasFeatureApply.getId();
}
private List<SaasFeatureApplyDetail> validAndBuildApplyDetail(SubmitPermissionPointApplyVO apply, Long applyId, Date now) {
@Override
@Transactional(rollbackFor = Exception.class)
public void bindWorkflowInstantce(BindWorkflowInstantceVO bind) {
SaasFeatureApply saasFeatureApply = saasFeatureApplyDao.lambdaQuery().eq(SaasFeatureApply::getId, bind.getApplyId())
.eq(SaasFeatureApply::getIsDelete, TableIsDeleteEnum.NORMAL.value).one();
if (saasFeatureApply == null) {
throw new ServiceException("权限申请不存在");
}
if (StringUtils.equals(saasFeatureApply.getWorkflowInstantceId(), bind.getWorkflowInstantceId())) {
return;
}
if (Objects.equals(saasFeatureApply.getStatus(), PermissionPointApplyStatus.INITIALIZED.getCode())) {
saasFeatureApplyDao.lambdaUpdate().set(SaasFeatureApply::getWorkflowInstantceId, bind.getWorkflowInstantceId())
.eq(SaasFeatureApply::getId, saasFeatureApply.getId()).update();
} else {
throw new ServiceException("权限申请不是初始化状态");
}
}
private List<SaasFeatureApplyDetail> validAndBuildApplyDetail(SubmitPermissionPointApplyVO apply, Long applyId,
Date now) {
List<SaasFeatureApplyDetail> details = new ArrayList<>();
List<SubmitPermissionPointApplyVO.SubmitPermissionPointInfoVO> permissionPoints = apply.getPermissionPoints();
List<SubmitPermissionPointApplyVO.SubmitPermissionPointInfoVO> flatPoints = apply.flatPermissionPoint();
List<Long> featureIds = flatPoints.stream().filter(p -> Objects.nonNull(p.getPermissionPointId()))
.map(SubmitPermissionPointApplyVO.SubmitPermissionPointInfoVO::getPermissionPointId).distinct().sorted()
.collect(Collectors.toList());
if (CollectionUtils.isEmpty(featureIds)) {
throw new ServiceException("数据错误, 父节点为空");
}
List<PermissionPointTreeNode> featureNodes = permissionPointService.listNodesByIds(featureIds);
if (featureNodes.size() != featureIds.size()) {
List<Long> existIds =
featureNodes.stream().map(PermissionPointTreeNode::getPermissionPointId).collect(Collectors.toList());
throw new ServiceException(
String.format("数据错误, 权限点【%s】不存在", JSON.toJSONString(CollectionUtils.subtract(featureIds, existIds))));
}
Map<Long, PermissionPointTreeNode> featureMap = featureNodes.stream().collect(
Collectors.toMap(PermissionPointTreeNode::getPermissionPointId, Function.identity(), (e1, e2) -> e2));
Map<String, List<SubmitPermissionPointApplyVO.SubmitPermissionPointInfoVO>> pointMap = flatPoints.stream()
.collect(Collectors.groupingBy(SubmitPermissionPointApplyVO.SubmitPermissionPointInfoVO::getTerminal));
.collect(Collectors.groupingBy(SubmitPermissionPointApplyVO.SubmitPermissionPointInfoVO::getTerminal));
Map<String, List<String>> featureCodes = new HashMap<>();
pointMap.forEach((k, v) -> featureCodes.put(k, saasFeatureApplyDetailService.getPermissionCode(k, v.size())));
for (SubmitPermissionPointApplyVO.SubmitPermissionPointInfoVO pp : permissionPoints) {
if (pp.getPermissionPointId() == null) {
throw new ServiceException("父节点权限id为空");
}
PermissionPointTreeNode parent = featureMap.get(pp.getPermissionPointId());
if (CollectionUtils.isNotEmpty(pp.getChildren())) {
pp.getChildren().forEach(c -> handleApplyDetail(applyId, now, apply.getCreateBy(),
"/" + parent.getPermissionPointId() + "/", parent, c, details, featureCodes, featureMap));
}
}
return details;
}
private void handleApplyDetail(String featurePath, SubmitPermissionPointApplyVO.SubmitPermissionPointInfoVO point, List<SaasFeatureApplyDetail> details) {
private void handleApplyDetail(Long applyId, Date now, Long createBy, String featurePath,
PermissionPointTreeNode parent, SubmitPermissionPointApplyVO.SubmitPermissionPointInfoVO point,
List<SaasFeatureApplyDetail> details, Map<String, List<String>> featureCodeMap,
Map<Long, PermissionPointTreeNode> featureMap) {
if (point.getPermissionPointId() == null) {
List<String> featureCodes = featureCodeMap.get(point.getTerminal());
String featureCode = featureCodes.get(0);
featureCodes.remove(0);
SaasFeatureApplyDetail detail = new SaasFeatureApplyDetail();
detail.setApplyId(applyId);
detail.setFeatureName(point.getPermissionName());
detail.setFeatureCode(featureCode);
detail.setIcon(point.getIcon());
detail.setLinkUrl(point.getLinkUrl());
detail.setLinkType(point.getLinkType());
detail.setLinkExt(point.getLinkExt());
detail.setAppId(point.getAppId());
detail.setAppIdentity(point.getAppIdentity());
detail.setFeaturePath(featurePath);
detail.setDescription(point.getDescription());
detail.setSort(point.getSort());
detail.setTerminal(point.getTerminal());
detail.setFeatureType(point.getFeatureType());
detail.setFitOuTypeBit(point.getFitOuTypeList() == null ? "" : JSON.toJSONString(point.getFitOuTypeList()));
detail.setFitOuNodeTypeBit(
point.getFitOuNodeTypeList() == null ? "" : JSON.toJSONString(point.getFitOuNodeTypeList()));
detail.setCreateBy(createBy);
detail.setCreateAt(now);
detail.setUpdateBy(createBy);
detail.setUpdateAt(now);
detail.setAppName(point.getAppName());
detail.setFeatureUrl(point.getFeatureUrl());
detail.setNeedCert(point.getNeedCert());
detail.setNeedAuth(point.getNeedAuth());
detail.setBusinessNo(PermissionConstant.FEATURE_BIZ_NO_PREFIX + System.currentTimeMillis());
detail.setParentBusinessNo(parent.getBusinessNo());
details.add(detail);
} else {
if (CollectionUtils.isNotEmpty(point.getChildren())) {
featurePath = featurePath + point.getPermissionPointId() + "/";
for (SubmitPermissionPointApplyVO.SubmitPermissionPointInfoVO d : point.getChildren()) {
handleApplyDetail(applyId, now, createBy, featurePath, featureMap.get(point.getPermissionPointId()),
d, details, featureCodeMap, featureMap);
}
}
}
}
}