whycxzp
2021-11-05 c1aab916a7cccbbb2a2d8cc2b2e95a80dc64f40f
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
package com.whyc.service;
 
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
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.mapper.WorkflowActionMapper;
import com.whyc.pojo.WorkflowAction;
import org.springframework.stereotype.Service;
 
import javax.annotation.Resource;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
 
@Service
public class WorkflowActionService {
 
    @Resource
    private WorkflowActionMapper mapper;
 
 
    public void add(WorkflowAction workflowAction) {
        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);
 
            actionList.add(actionTemp);
        });
        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);
        //再新增
        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);
 
            actionList.add(actionTemp);
        });
        mapper.insertBatchSomeColumn(actionList);
    }
 
    public List<WorkflowAction> getActionTypeList(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);
    }
}