whycxzp
2021-11-04 0f7af5b2679669b521e692836d0328e0d9e1febb
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
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.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.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<Integer> getActionTypeList(Integer type, Integer linkType, Integer roleType) {
        QueryWrapper<WorkflowAction> wrapper = Wrappers.query();
        wrapper.eq("type",type)
                .eq("link_type",linkType)
                .eq("role_type",roleType);
        return mapper.selectList(wrapper).stream().map(WorkflowAction::getActionType).collect(Collectors.toList());
 
    }
}