ny
昨天 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
package jnpf.flowable.mapper;
 
import cn.hutool.core.collection.CollectionUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import jnpf.base.UserInfo;
import jnpf.base.mapper.SuperMapper;
import jnpf.flowable.entity.CommonEntity;
import jnpf.util.RandomUtil;
import jnpf.util.StringUtil;
import jnpf.util.UserProvider;
 
import java.util.List;
 
/**
 * 类的描述
 *
 * @author JNPF@YinMai Info. Co., Ltd
 * @version 5.0.x
 * @since 2024/5/22 20:30
 */
public interface CommonMapper extends SuperMapper<CommonEntity> {
 
    default List<CommonEntity> getCommonByUserId(String userId) {
        QueryWrapper<CommonEntity> queryWrapper = new QueryWrapper<>();
        queryWrapper.lambda().eq(CommonEntity::getCreatorUserId, userId);
        return this.selectList(queryWrapper);
    }
 
    default int setCommonFLow(String flowId) {
 
        UserInfo userInfo = UserProvider.getUser();
        String userId = userInfo.getUserId();
 
        QueryWrapper<CommonEntity> queryWrapper = new QueryWrapper<>();
        queryWrapper.lambda().eq(CommonEntity::getFlowId, flowId)
                .eq(CommonEntity::getCreatorUserId, userId);
        List<CommonEntity> list = this.selectList(queryWrapper);
 
        if (CollectionUtil.isNotEmpty(list)) {
            this.deleteByIds(list);
            return 2;
        } else {
            CommonEntity entity = new CommonEntity();
            entity.setId(RandomUtil.uuId());
            entity.setFlowId(flowId);
            entity.setCreatorUserId(userId);
            this.insert(entity);
        }
        return 1;
    }
 
    default void deleteFlow(String flowId) {
        if (StringUtil.isNotEmpty(flowId)) {
            QueryWrapper<CommonEntity> common = new QueryWrapper<>();
            common.lambda().eq(CommonEntity::getFlowId, flowId);
            this.delete(common);
        }
    }
}