lxw
2023-08-15 160e150009b51a39fa95d9462c3798ba28d51a09
src/main/java/com/whyc/service/WorkflowActionService.java
@@ -4,6 +4,7 @@
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.google.gson.internal.$Gson$Preconditions;
import com.whyc.constant.RoleEnum;
import com.whyc.mapper.WorkflowActionMapper;
import com.whyc.pojo.WorkflowAction;
import org.springframework.stereotype.Service;
@@ -36,33 +37,62 @@
        mapper.insertBatchSomeColumn(actionList);
    }
    public void update(WorkflowAction workflowAction) {
        //先删除
        UpdateWrapper<WorkflowAction> wrapper = Wrappers.update();
        wrapper.eq("type",workflowAction.getType())
                .eq("link_type",workflowAction.getLinkType())
                .eq("role_type",workflowAction.getRoleType());
        mapper.delete(wrapper);
        //再新增
    public void update(List<WorkflowAction> workflowActionList) {
        List<WorkflowAction> actionList = new LinkedList<>();
        List<Integer> actionTypeList = workflowAction.getActionTypeList();
        actionTypeList.stream().forEach(actionType -> {
            WorkflowAction actionTemp = new WorkflowAction();
            actionTemp.setLinkType(workflowAction.getLinkType());
            actionTemp.setRoleType(workflowAction.getRoleType());
            actionTemp.setType(workflowAction.getType());
            actionTemp.setActionType(actionType);
        workflowActionList.stream().forEach(workflowAction -> {
            //先删除
            UpdateWrapper<WorkflowAction> wrapper = Wrappers.update();
            wrapper.eq("type",workflowAction.getType())
                    .eq("link_type",workflowAction.getLinkType())
                    .eq("role_type",workflowAction.getRoleType());
            mapper.delete(wrapper);
            //再新增
            List<Integer> actionTypeList = workflowAction.getActionTypeList();
            actionTypeList.stream().forEach(actionType -> {
                WorkflowAction actionTemp = new WorkflowAction();
                actionTemp.setLinkType(workflowAction.getLinkType());
                actionTemp.setRoleType(workflowAction.getRoleType());
                actionTemp.setType(workflowAction.getType());
                actionTemp.setActionType(actionType);
            actionList.add(actionTemp);
                actionList.add(actionTemp);
            });
        });
        mapper.insertBatchSomeColumn(actionList);
    }
    public List<WorkflowAction> getActionTypeList(Integer type, Integer linkType) {
    public List<WorkflowAction> getActionTypeList4Link(Integer type, Integer linkType) {
        QueryWrapper<WorkflowAction> wrapper = Wrappers.query();
        wrapper.eq("type",type)
                .eq("link_type",linkType);
        //Map<Integer, List<WorkflowAction>> collect = mapper.selectList(wrapper).stream().collect(Collectors.groupingBy(WorkflowAction::getRoleType));
        return mapper.selectList(wrapper);
    }
    public List<WorkflowAction> getActionTypeList(Integer type, Integer status, int userRole) {
        QueryWrapper<WorkflowAction> wrapper = Wrappers.query();
        Integer linkType = null;
        Integer roleType = null;
        //Map<Integer, List<WorkflowAction>> collect = mapper.selectList(wrapper).stream().collect(Collectors.groupingBy(WorkflowAction::getRoleType));
        //表示处于1级节点
        if(status == 2 ||status ==3){
            linkType = 1;
        }
        else if(status ==4){ //表示处于2级节点
            linkType = 2;
        }
        //角色类型
        if(userRole == RoleEnum.ADMIN.getId()){
            roleType = 0;
        }
        else{
            roleType = 1;
        }
        wrapper.select("action_type")
                .eq("type",type)
                .eq("link_type",linkType)
                .eq("role_type",roleType);
        return mapper.selectList(wrapper);
    }
}