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
package jnpf.flowable.mapper;
 
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import jnpf.base.UserInfo;
import jnpf.base.mapper.SuperMapper;
import jnpf.exception.WorkFlowException;
import jnpf.flowable.entity.CommentEntity;
import jnpf.flowable.model.comment.CommentPagination;
import jnpf.util.RandomUtil;
import jnpf.util.UserProvider;
 
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
 
/**
 * 流程评论
 *
 * @author JNPF开发平台组
 * @version V3.1.0
 * @copyright 引迈信息技术有限公司
 */
public interface CommentMapper extends SuperMapper<CommentEntity> {
 
    default List<CommentEntity> getlist(CommentPagination pagination) {
        QueryWrapper<CommentEntity> queryWrapper = new QueryWrapper<>();
        queryWrapper.lambda().eq(CommentEntity::getTaskId, pagination.getTaskId());
        queryWrapper.lambda().isNull(CommentEntity::getDeleteMark);
        queryWrapper.lambda().orderByDesc(CommentEntity::getCreatorTime);
        Page<CommentEntity> page = new Page<>(pagination.getCurrentPage(), pagination.getPageSize());
        IPage<CommentEntity> userIPage = this.selectPage(page, queryWrapper);
        return pagination.setData(userIPage.getRecords(), page.getTotal());
    }
 
    default List<CommentEntity> getList() {
        QueryWrapper<CommentEntity> queryWrapper = new QueryWrapper<>();
        return this.selectList(queryWrapper);
    }
 
    default List<CommentEntity> getlist(List<String> idList) {
        List<CommentEntity> list = new ArrayList<>();
        if (!idList.isEmpty()) {
            QueryWrapper<CommentEntity> queryWrapper = new QueryWrapper<>();
            queryWrapper.lambda().in(CommentEntity::getId, idList);
            list.addAll(this.selectList(queryWrapper));
        }
        return list;
    }
 
    default CommentEntity getInfo(String id) {
        QueryWrapper<CommentEntity> queryWrapper = new QueryWrapper<>();
        queryWrapper.lambda().eq(CommentEntity::getId, id);
        return this.selectOne(queryWrapper);
    }
 
    default void create(CommentEntity entity) throws WorkFlowException {
        entity.setCreatorTime(new Date());
        entity.setCreatorUserId(UserProvider.getUser().getUserId());
        entity.setId(RandomUtil.uuId());
        this.insert(entity);
    }
 
    default void update(String id, CommentEntity entity) {
        entity.setId(id);
        this.updateById(entity);
    }
 
    default void delete(CommentEntity entity, boolean delComment) {
        if (entity != null) {
            UserInfo userInfo = UserProvider.getUser();
            if (delComment) {
                entity.setDeleteShow(1);
            } else {
                entity.setDeleteMark(1);
            }
            entity.setDeleteTime(new Date());
            entity.setDeleteUserId(userInfo.getUserId());
            this.updateById(entity);
        }
    }
}