ny
23 小时以前 b6f169fe43a2b13f351aefc152374fc7f0bc8cb7
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
package jnpf.flowable.mapper;
 
import cn.hutool.core.collection.CollectionUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import jnpf.base.mapper.SuperMapper;
import jnpf.flowable.entity.SubtaskDataEntity;
import jnpf.flowable.model.task.FlowModel;
import jnpf.util.JsonUtil;
import jnpf.util.RandomUtil;
 
import java.util.ArrayList;
import java.util.List;
 
/**
 * 类的描述
 *
 * @author JNPF@YinMai Info. Co., Ltd
 * @version 5.0.x
 * @since 2024/12/6 15:32
 */
public interface SubtaskDataMapper extends SuperMapper<SubtaskDataEntity> {
 
    default List<SubtaskDataEntity> getList(String parentId, String parentCode) {
        QueryWrapper<SubtaskDataEntity> queryWrapper = new QueryWrapper<>();
        queryWrapper.lambda().eq(SubtaskDataEntity::getParentId, parentId).eq(SubtaskDataEntity::getNodeCode, parentCode)
                .orderByAsc(SubtaskDataEntity::getSortCode);
        return this.selectList(queryWrapper);
    }
 
    default void save(List<FlowModel> subTaskData) {
        if (CollectionUtil.isEmpty(subTaskData)) {
            return;
        }
        List<SubtaskDataEntity> list = new ArrayList<>();
        for (int i = 0; i < subTaskData.size(); i++) {
            FlowModel model = subTaskData.get(i);
            SubtaskDataEntity entity = new SubtaskDataEntity();
            entity.setId(RandomUtil.uuId());
            entity.setParentId(model.getParentId());
            entity.setNodeCode(model.getSubCode());
            entity.setSubtaskJson(JsonUtil.getObjectToString(model));
            int sortCode = i + 1;
            entity.setSortCode((long) sortCode);
            list.add(entity);
        }
        if (CollectionUtil.isNotEmpty(list)) {
            this.insert(list);
        }
    }
}