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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
package jnpf.service.impl;
 
import cn.hutool.core.collection.CollectionUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.github.yulichang.toolkit.JoinWrappers;
import com.github.yulichang.wrapper.MPJLambdaWrapper;
import jnpf.base.UserInfo;
import jnpf.base.entity.SuperBaseEntity;
import jnpf.base.service.SuperServiceImpl;
import jnpf.config.ConfigValueUtil;
import jnpf.constant.PermissionConst;
import jnpf.emnus.SysParamEnum;
import jnpf.entity.DocumentLogEntity;
import jnpf.mapper.DocumentMapper;
import jnpf.model.document.DocumentListVO;
import jnpf.model.document.DocumentShareForm;
import jnpf.model.document.DocumentTrashListVO;
import jnpf.model.document.FlowFileModel;
import jnpf.permission.OrganizeApi;
import jnpf.permission.PositionApi;
import jnpf.permission.entity.OrganizeEntity;
import jnpf.permission.entity.PositionEntity;
import jnpf.permission.entity.UserEntity;
import jnpf.service.DocumentLogService;
import jnpf.service.DocumentService;
import jnpf.service.DocumentShareService;
import jnpf.entity.DocumentEntity;
import jnpf.entity.DocumentShareEntity;
import jnpf.util.FileUtil;
import jnpf.util.RandomUtil;
import jnpf.util.StringUtil;
import jnpf.util.UserProvider;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
 
import java.util.*;
import java.util.stream.Collectors;
import java.util.stream.Stream;
 
/**
 * 知识文档
 *
 * @author JNPF开发平台组
 * @copyright 引迈信息技术有限公司
 * @date 2019年9月26日 上午9:18
 */
@Service
public class DocumentServiceImpl extends SuperServiceImpl<DocumentMapper, DocumentEntity> implements DocumentService {
 
    @Autowired
    private OrganizeApi organizeApi;
    @Autowired
    private PositionApi positionApi;
    @Autowired
    private DocumentShareService documentShareService;
    @Autowired
    private ConfigValueUtil configValueUtil;
    @Autowired
    private DocumentLogService documentLogService;
 
    @Override
    public List<DocumentEntity> getFolderList() {
        QueryWrapper<DocumentEntity> queryWrapper = new QueryWrapper<>();
        queryWrapper.lambda()
                .eq(DocumentEntity::getCreatorUserId, UserProvider.getUser().getUserId())
                .eq(DocumentEntity::getType, 0)
                .eq(DocumentEntity::getEnabledMark, 1)
                .orderByDesc(DocumentEntity::getCreatorTime);
        return this.list(queryWrapper);
    }
 
    @Override
    public List<DocumentEntity> getAllList(String parentId) {
        return this.getChildList(parentId, false);
    }
 
 
 
    @Override
    public List<DocumentEntity> getChildList(String parentId, boolean isShare) {
        QueryWrapper<DocumentEntity> queryWrapper = new QueryWrapper<>();
        if (!isShare) {
            queryWrapper.lambda().eq(DocumentEntity::getCreatorUserId, UserProvider.getUser().getUserId());
        }
        queryWrapper.lambda()
                .eq(DocumentEntity::getEnabledMark, 1)
                .eq(DocumentEntity::getParentId, parentId)
                .orderByAsc(DocumentEntity::getType)
                .orderByDesc(DocumentEntity::getCreatorTime);
        return this.list(queryWrapper);
    }
 
    @Override
    public List<DocumentEntity> getAllList(String parentId, String userId) {
        QueryWrapper<DocumentEntity> queryWrapper = new QueryWrapper<>();
        queryWrapper.lambda()
                .eq(DocumentEntity::getEnabledMark, 1)
                .eq(DocumentEntity::getParentId, parentId)
                .eq(DocumentEntity::getCreatorUserId, userId)
                .orderByAsc(DocumentEntity::getType)
                .orderByDesc(DocumentEntity::getCreatorTime);
        return this.list(queryWrapper);
    }
 
    @Override
    public List<DocumentEntity> getSearchAllList(String keyword) {
        QueryWrapper<DocumentEntity> queryWrapper = new QueryWrapper<>();
        if (StringUtil.isNotEmpty(keyword)) {
            queryWrapper.lambda().like(DocumentEntity::getFullName, keyword);
            queryWrapper.lambda().eq(DocumentEntity::getType, 1);
        }
        queryWrapper.lambda()
                .eq(DocumentEntity::getCreatorUserId, UserProvider.getUser().getUserId())
                .eq(DocumentEntity::getEnabledMark, 1)
                .orderByAsc(DocumentEntity::getType)
                .orderByDesc(DocumentEntity::getCreatorTime);
        return this.list(queryWrapper);
    }
 
    @Override
    public List<DocumentTrashListVO> getTrashList(String keyword) {
        MPJLambdaWrapper<DocumentLogEntity> wrapper = new MPJLambdaWrapper<>(DocumentLogEntity.class)
                .leftJoin(DocumentEntity.class, DocumentEntity::getId, DocumentLogEntity::getDocumentId)
                .select(DocumentLogEntity::getId, DocumentLogEntity::getDocumentId)
                .select(DocumentEntity::getFullName, DocumentEntity::getDeleteTime, DocumentEntity::getFileSize,
                        DocumentEntity::getType, DocumentEntity::getFileExtension);
        if (StringUtil.isNotEmpty(keyword)) {
            wrapper.like(DocumentEntity::getFullName, keyword);
//            wrapper.eq(DocumentEntity::getType, 1);
        }
        wrapper.eq(DocumentLogEntity::getCreatorUserId, UserProvider.getUser().getUserId());
        wrapper.orderByAsc(DocumentEntity::getType).orderByDesc(DocumentLogEntity::getCreatorTime);
        List<DocumentTrashListVO> list = documentLogService.selectJoinList(DocumentTrashListVO.class, wrapper);
        return list;
    }
 
    @Override
    public List<DocumentEntity> getShareOutList() {
        QueryWrapper<DocumentEntity> queryWrapper = new QueryWrapper<>();
        queryWrapper.lambda()
                .eq(DocumentEntity::getCreatorUserId, UserProvider.getUser().getUserId())
                .eq(DocumentEntity::getEnabledMark, 1)
                .gt(DocumentEntity::getIsShare, 0)
                .orderByAsc(DocumentEntity::getType)
                .orderByDesc(DocumentEntity::getShareTime);
        return this.list(queryWrapper);
    }
 
    @Override
    public List<DocumentShareEntity> getShareTomeList() {
        UserInfo user = UserProvider.getUser();
 
        //获取用户角色
        List<String> roleIds = getRoleIds(user);
        //获取用户组织
        List<String> organizeIds = getOrganizeIds(user);
        //获取用户岗位
        List<String> permissionIds = getPermissionIds(user);
        //获取用户组
        List<String> userGroupIds = getUserGroupIds(user);
        roleIds.addAll(organizeIds);
        roleIds.addAll(permissionIds);
        roleIds.addAll(userGroupIds);
        roleIds.add(user.getUserId() + "--" + PermissionConst.USER);
        QueryWrapper<DocumentShareEntity> shareWrapper = new QueryWrapper<>();
        shareWrapper.lambda().in(DocumentShareEntity::getShareUserId, roleIds);
        return documentShareService.list(shareWrapper);
    }
    private List<String> getUserGroupIds(UserInfo user) {
        return user.getGroupIds().stream()
                .map(item -> item + "--" + PermissionConst.GROUP).collect(Collectors.toList());
    }
 
    /**
     * 获取用户所在岗位ids
     *
     * @param userInfo 用户信息
     * @return 用户岗位ids
     */
    private List<String> getPermissionIds(UserInfo userInfo) {
 
        List<PositionEntity> list = positionApi.list();
        List<String> collect = userInfo.getPositionIds();
        List<String> strings = collect.stream()
                .flatMap(item -> Stream.of(
                        item + "--" + SysParamEnum.POS.getCode(),
                        item + "--" + SysParamEnum.SUBPOS.getCode(),
                        item + "--" + SysParamEnum.PROGENYPOS.getCode()
                ))
                .collect(Collectors.toList());
        List<String> fatherPositionList = findFatherPositionList(collect, list);
        fatherPositionList.addAll(strings);
        return fatherPositionList.stream().distinct().collect(Collectors.toList());
 
    }
 
    /**
     * 获取用户所在组织ids
     *
     * @param userInfo 用户
     * @return 返回用户所在组织ids
     */
    private List<String> getOrganizeIds(UserInfo userInfo) {
 
        List<OrganizeEntity> list = organizeApi.list();
        List<String> collect = userInfo.getOrganizeIds();
        List<String> strings = collect.stream()
                .map(item -> item + "--" + SysParamEnum.ORG.getCode())
                .collect(Collectors.toList());
 
 
        List<String> stringArrayList = findFatherOrganizeList(collect, list);
        stringArrayList.addAll(strings);
        return stringArrayList.stream().distinct().collect(Collectors.toList());
    }
 
    private List<String> findFatherOrganizeList(List<String> collect, List<OrganizeEntity> list) {
 
        List<String> stringArrayList = new ArrayList<>();
        List<String> grandFatherList = new ArrayList<>();
        for (String string : collect) {
            List<OrganizeEntity> collected = list.stream().filter(item -> item.getId().equals(string))
                    .collect(Collectors.toList());
            if (collected.isEmpty() || "-1".equals(collected.get(0).getParentId())
                    || StringUtil.isEmpty(collected.get(0).getParentId())) {
                continue;
            }
            OrganizeEntity info = collected.get(0);
            grandFatherList.add(info.getParentId());
            String faId = info.getParentId() + "--" + SysParamEnum.SUBORG.getCode();
            String grandFaId = info.getParentId() + "--" + SysParamEnum.PROGENYORG.getCode();
            stringArrayList.add(faId);
            stringArrayList.add(grandFaId);
        }
        for (String string : grandFatherList) {
            List<OrganizeEntity> collected = list.stream().filter(item -> item.getId().equals(string))
                    .collect(Collectors.toList());
            if (collected.isEmpty() || "-1".equals(collected.get(0).getParentId())
                    || StringUtil.isEmpty(collected.get(0).getParentId())) {
                continue;
            }
            OrganizeEntity info = collected.get(0);
 
            String gfaId = info.getParentId() + "--" + SysParamEnum.PROGENYORG.getCode();
            stringArrayList.add(gfaId);
        }
        return stringArrayList;
    }
 
    private List<String> findFatherPositionList(List<String> collect, List<PositionEntity> list) {
 
        List<String> stringArrayList = new ArrayList<>();
        List<String> grandFatherList = new ArrayList<>();
        for (String string : collect) {
            List<PositionEntity> collected = list.stream().filter(item -> item.getId().equals(string))
                    .collect(Collectors.toList());
            if (collected.isEmpty() || "-1".equals(collected.get(0).getParentId())
                    || StringUtil.isEmpty(collected.get(0).getParentId())) {
                continue;
            }
            PositionEntity info = collected.get(0);
            grandFatherList.add(info.getParentId());
            String faId = info.getParentId() + "--" + SysParamEnum.SUBPOS.getCode();
            String grandFaId = info.getParentId() + "--" + SysParamEnum.PROGENYPOS.getCode();
            stringArrayList.add(faId);
            stringArrayList.add(grandFaId);
        }
        for (String string : grandFatherList) {
            List<PositionEntity> collected = list.stream().filter(item -> item.getId().equals(string))
                    .collect(Collectors.toList());
            if (collected.isEmpty() || "-1".equals(collected.get(0).getParentId())
                    || StringUtil.isEmpty(collected.get(0).getParentId())) {
                continue;
            }
            PositionEntity info = collected.get(0);
 
            String gfaId = info.getParentId() + "--" + SysParamEnum.PROGENYPOS.getCode();
            stringArrayList.add(gfaId);
        }
        return stringArrayList;
    }
 
    /**
     * 获取用户所有角色
     *
     * @param userInfo 用户id
     * @return 返回用户所有角色
     */
    private List<String> getRoleIds(UserInfo userInfo) {
        return userInfo.getRoleIds().stream()
                .map(item -> item + "--" + PermissionConst.ROLE).collect(Collectors.toList());
    }
    @Override
    public List<DocumentEntity> getInfoByIds(List<String> ids) {
        if (CollectionUtils.isNotEmpty(ids)) {
            QueryWrapper<DocumentEntity> queryWrapper = new QueryWrapper<>();
            queryWrapper.lambda().in(DocumentEntity::getId, ids);
            queryWrapper.lambda().eq(DocumentEntity::getEnabledMark, 1);
            queryWrapper.lambda().orderByAsc(DocumentEntity::getType)
                    .orderByDesc(DocumentEntity::getCreatorTime);
            return this.list(queryWrapper);
        }
        return new ArrayList<>();
    }
 
    @Override
    public List<DocumentShareEntity> getShareUserList(String documentId) {
        QueryWrapper<DocumentShareEntity> queryWrapper = new QueryWrapper<>();
        queryWrapper.lambda().eq(DocumentShareEntity::getDocumentId, documentId);
        return documentShareService.list(queryWrapper);
    }
 
    @Override
    public DocumentEntity getInfo(String id) {
        QueryWrapper<DocumentEntity> queryWrapper = new QueryWrapper<>();
        queryWrapper.lambda().eq(DocumentEntity::getId, id);
        return this.getOne(queryWrapper);
    }
 
    @Override
    public void delete(DocumentEntity entity) {
        entity.setDeleteTime(new Date());
        entity.setDeleteUserId(UserProvider.getUser().getUserId());
        entity.setEnabledMark(0);
        this.updateById(entity);
 
    }
 
    @Override
    public void create(DocumentEntity entity) {
        entity.setId(RandomUtil.uuId());
        if (StringUtil.isBlank(entity.getCreatorUserId())) {
            entity.setCreatorUserId(UserProvider.getUser().getUserId());
        }
        entity.setEnabledMark(1);
        this.save(entity);
    }
 
    @Override
    public boolean update(String id, DocumentEntity entity) {
        entity.setId(id);
        entity.setLastModifyTime(new Date());
        entity.setLastModifyUserId(UserProvider.getUser().getUserId());
        return this.updateById(entity);
    }
 
    @Override
    @Transactional
    public void sharecreate(DocumentShareForm documentShareForm) {
        List<String> ids = documentShareForm.getIds();
        List<String> userIds = documentShareForm.getUserIds();
        String creatorUserId = documentShareForm.getCreatorUserId();
        if (CollectionUtils.isEmpty(ids) || CollectionUtils.isEmpty(userIds)) {
            return;
        }
        for (String docId : ids) {
            DocumentEntity entity = this.getInfo(docId);
            if (entity != null) {
                //共享当前文件或者文件夹(文件夹内部文件可以直接查询)
                int n = (entity.getIsShare() == null ? 0 : entity.getIsShare()) + userIds.size();
                entity.setIsShare(n);
                entity.setShareTime(new Date());
                this.updateById(entity);
                for (String userId : userIds) {
                    DocumentShareEntity one = documentShareService.getByDocIdAndShareUserId(docId, userId);
                    if (one != null) {
                        one.setShareTime(new Date());
                        documentShareService.updateById(one);
                        continue;
                    }
                    DocumentShareEntity documentShare = new DocumentShareEntity();
                    documentShare.setId(RandomUtil.uuId());
                    documentShare.setDocumentId(docId);
                    documentShare.setShareUserId(userId);
                    documentShare.setShareTime(new Date());
                    documentShare.setCreatorUserId(creatorUserId);
                    documentShareService.save(documentShare);
                }
            }
        }
    }
 
    @Override
    @Transactional
    public void shareCancel(List<String> documentIds) {
        for (String documentId : documentIds) {
            QueryWrapper<DocumentEntity> queryWrapper = new QueryWrapper<>();
            queryWrapper.lambda().eq(DocumentEntity::getId, documentId);
            DocumentEntity entity = this.getOne(queryWrapper);
            if (entity != null) {
                entity.setIsShare(0);
                entity.setShareTime(new Date());
                this.updateById(entity);
                QueryWrapper<DocumentShareEntity> wrapper = new QueryWrapper<>();
                wrapper.lambda().eq(DocumentShareEntity::getDocumentId, documentId);
                documentShareService.remove(wrapper);
            }
        }
    }
 
    @Override
    @Transactional
    public void shareAdjustment(String id, List<String> userIds) {
        DocumentEntity entity = this.getInfo(id);
        if (entity != null) {
            entity.setIsShare(userIds.size());
            entity.setShareTime(new Date());
            this.updateById(entity);
            QueryWrapper<DocumentShareEntity> wrapper = new QueryWrapper<>();
            wrapper.lambda().eq(DocumentShareEntity::getDocumentId, entity.getId());
            documentShareService.remove(wrapper);
            for (String userId : userIds) {
                DocumentShareEntity documentShare = new DocumentShareEntity();
                documentShare.setId(RandomUtil.uuId());
                documentShare.setDocumentId(id);
                documentShare.setShareUserId(userId);
                documentShare.setShareTime(new Date());
                documentShareService.save(documentShare);
            }
        }
    }
 
    @Override
    @Transactional
    public void trashdelete(List<String> folderIds) {
        List<String> pathList = new ArrayList<>();
        for (String logId : folderIds) {
            DocumentLogEntity logEntity = documentLogService.getById(logId);
            DocumentEntity entity = this.getInfo(logEntity.getDocumentId());
            if (entity != null) {
                if (Objects.equals(entity.getType(), 0)) {
                    String childDocument = logEntity.getChildDocument();
                    String[] allFile = childDocument.split(",");
                    for (String item : allFile) {
                        this.removeById(item);
                    }
                } else {
                    this.removeById(logEntity.getDocumentId());
                }
                pathList.add(configValueUtil.getDocumentFilePath() + entity.getFilePath());
            }
            documentLogService.removeById(logEntity);
        }
        //先移除数据再移除文件,以便回滚(移除文件夹里面的文件也会删除所以不用递归)
        for (String path : pathList) {
            FileUtil.deleteFile(path);
        }
    }
 
    @Override
    @Transactional
    public void trashRecoveryConstainSrc(List<String> ids) {
        for (String logId : ids) {
            DocumentLogEntity logEntity = documentLogService.getById(logId);
            if (logEntity == null) {
                continue;
            }
            DocumentEntity entity = this.getInfo(logEntity.getDocumentId());
            if (entity != null) {
                if (!"0".equals(entity.getParentId())) {
                    //查询父级菜单是否存在,如果存在还原到原菜单里,如果不存在则放在最外层
                    DocumentEntity parentInfo = this.getInfo(entity.getParentId());
                    if (parentInfo == null || Objects.equals(parentInfo.getEnabledMark(), 0)) {
                        this.trashRecovery(entity.getId(), true);
                    } else {
                        this.trashRecovery(entity.getId(), false);
                    }
                } else {
                    this.trashRecovery(entity.getId(), false);
                }
                String childDocument = logEntity.getChildDocument();
                List<String> childList = Arrays.asList(childDocument.split(",")).stream().filter(t -> !t.equals(entity.getId())).collect(Collectors.toList());
                //还原文件夹内的所有文件。
                for (String item : childList) {
                    this.trashRecovery(item, false);
                }
            }
            documentLogService.removeById(logEntity);
        }
    }
 
    @Override
    public boolean trashRecovery(String id, boolean initParent) {
        UpdateWrapper<DocumentEntity> updateWrapper = new UpdateWrapper<>();
        if (initParent) {
            updateWrapper.lambda().set(DocumentEntity::getParentId, "0");
        }
        updateWrapper.lambda().set(DocumentEntity::getEnabledMark, 1);
        updateWrapper.lambda().set(DocumentEntity::getDeleteTime, null);
        updateWrapper.lambda().set(DocumentEntity::getDeleteUserId, null);
        updateWrapper.lambda().eq(DocumentEntity::getId, id);
        return this.update(updateWrapper);
    }
 
    @Override
    public boolean moveTo(String id, String toId) {
        DocumentEntity entity = this.getInfo(id);
        if (entity != null) {
            entity.setParentId(toId);
            this.updateById(entity);
            return true;
        }
        return false;
    }
 
    @Override
    public boolean isExistByFullName(String fullName, String id, String parentId) {
        String userId = UserProvider.getUser().getUserId();
        QueryWrapper<DocumentEntity> queryWrapper = new QueryWrapper<>();
        queryWrapper.lambda().eq(DocumentEntity::getFullName, fullName).eq(DocumentEntity::getEnabledMark, 1).eq(DocumentEntity::getCreatorUserId, userId);
        queryWrapper.lambda().eq(DocumentEntity::getParentId, parentId);
        if (!StringUtil.isEmpty(id)) {
            queryWrapper.lambda().ne(DocumentEntity::getId, id);
        }
        return this.count(queryWrapper) > 0 ? true : false;
    }
 
    @Override
    public void getChildSrcList(String pId, List<DocumentEntity> list, Integer enabledMark) {
        QueryWrapper<DocumentEntity> queryWrapper = new QueryWrapper<>();
        if (enabledMark != null) {
            queryWrapper.lambda().eq(DocumentEntity::getEnabledMark, enabledMark);
        }
        queryWrapper.lambda()
                .eq(DocumentEntity::getParentId, pId)
                .orderByAsc(DocumentEntity::getType)
                .orderByDesc(DocumentEntity::getCreatorTime);
        List<DocumentEntity> allList = this.list(queryWrapper);
        if (CollectionUtils.isNotEmpty(allList)) {
            list.addAll(allList);
            for (DocumentEntity doc : allList) {
                this.getChildSrcList(doc.getId(), list, enabledMark);
            }
        }
    }
 
    @Override
    public DocumentShareEntity getShareByParentId(String parentId) {
        List<DocumentShareEntity> shareTomeList = this.getShareTomeList();
 
        return this.getDocByParentId(parentId, shareTomeList);
 
 
    }
    public DocumentShareEntity getDocByParentId(String parentId, List<DocumentShareEntity> shareTomeList) {
        List<DocumentShareEntity> collect = shareTomeList.stream().filter(t -> t.getDocumentId().equals(parentId))
                .collect(Collectors.toList());
        if (CollectionUtils.isNotEmpty(collect)) {
            return collect.get(0);
        }
        DocumentEntity info = this.getInfo(parentId);
        return getDocByParentId(info.getParentId(), shareTomeList);
    }
 
    @Override
    public List<Map<String, Object>> getFlowFile(FlowFileModel model) {
        String userId = model.getUserId();
        String templateId = model.getTemplateId();
 
        QueryWrapper<DocumentShareEntity> shareWrapper = new QueryWrapper<>();
        shareWrapper.lambda().eq(DocumentShareEntity::getShareUserId, userId);
        List<DocumentShareEntity> shareList = documentShareService.list(shareWrapper);
        List<String> docIds = new ArrayList<>();
        if (CollectionUtil.isNotEmpty(shareList)) {
            docIds = shareList.stream().map(DocumentShareEntity::getDocumentId).collect(Collectors.toList());
        }
        QueryWrapper<DocumentEntity> wrapper = new QueryWrapper<>();
        wrapper.lambda().eq(DocumentEntity::getEnabledMark, 1).like(DocumentEntity::getDescription, templateId);
        List<String> finalDocIds = docIds;
        wrapper.lambda().and(t -> {
            t.eq(DocumentEntity::getCreatorUserId, userId);
            if (!finalDocIds.isEmpty()) {
                t.or(e -> e.in(DocumentEntity::getId, finalDocIds));
            }
        });
 
        wrapper.lambda().orderByDesc(DocumentEntity::getCreatorTime);
        Page<DocumentEntity> page = this.page(new Page<>(1,5), wrapper);
        List<DocumentEntity> documentList = page.getRecords();
        List<Map<String, Object>> list = new ArrayList<>();
        if (!documentList.isEmpty()) {
            for (DocumentEntity document : documentList) {
                Map<String, Object> map = new HashMap<>();
                map.put("id", document.getId());
                map.put("fileName", document.getFullName());
                map.put("fileDate", document.getCreatorTime());
                map.put("uploaderUrl", document.getUploaderUrl());
                list.add(map);
            }
        }
        return list;
    }
 
    @Override
    public List<DocumentListVO> getChildListUserName(String parentId, boolean isShare) {
        MPJLambdaWrapper<DocumentEntity> queryWrapper = JoinWrappers.lambda(DocumentEntity.class);
        queryWrapper.leftJoin(UserEntity.class, SuperBaseEntity.SuperIBaseEntity::getId, DocumentEntity::getCreatorUserId);
        queryWrapper.selectAs(UserEntity::getRealName, DocumentListVO::getCreatorUserName);
        queryWrapper.selectAs(UserEntity::getAccount, DocumentListVO::getCreatorUserAccount);
        queryWrapper.selectAs(DocumentEntity::getId, DocumentListVO::getId);
        queryWrapper.selectAs(DocumentEntity::getCreatorUserId, DocumentListVO::getCreatorUserId);
        queryWrapper.selectAs(DocumentEntity::getType, DocumentListVO::getType);
        queryWrapper.selectAs(DocumentEntity::getFilePath, DocumentListVO::getFilePath);
        queryWrapper.selectAs(DocumentEntity::getUploaderUrl, DocumentListVO::getUploaderUrl);
        queryWrapper.selectAs(DocumentEntity::getIsShare, DocumentListVO::getIsShare);
        queryWrapper.selectAs(DocumentEntity::getCreatorTime, DocumentListVO::getCreatorTime);
        queryWrapper.selectAs(DocumentEntity::getFullName, DocumentListVO::getFullName);
        queryWrapper.selectAs(DocumentEntity::getParentId, DocumentListVO::getParentId);
        queryWrapper.selectAs(DocumentEntity::getShareTime, DocumentListVO::getShareTime);
        queryWrapper.selectAs(DocumentEntity::getFileExtension, DocumentListVO::getFileExtension);
        queryWrapper.selectAs(DocumentEntity::getFileSize, DocumentListVO::getFileSize);
        if (!isShare) {
            queryWrapper.and(t -> t.eq(DocumentEntity::getCreatorUserId, UserProvider.getUser().getUserId()));
        }
        queryWrapper.and(t -> t.eq(DocumentEntity::getEnabledMark, 1)
                .eq(DocumentEntity::getParentId, parentId));
        queryWrapper.orderByAsc(DocumentEntity::getType);
        queryWrapper.orderByAsc(DocumentEntity::getCreatorTime);
 
 
        return this.selectJoinList(DocumentListVO.class, queryWrapper);
    }
}