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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
package jnpf.portal.mapper;
 
 
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import jnpf.base.MyBatisPrimaryBase;
import jnpf.base.mapper.SuperMapper;
import jnpf.constant.MsgCode;
import jnpf.portal.entity.PortalDataEntity;
import jnpf.portal.model.PortalCustomPrimary;
import jnpf.portal.model.PortalModPrimary;
import jnpf.portal.model.PortalReleasePrimary;
import jnpf.util.DateUtil;
 
import java.util.List;
 
/**
 * <p>
 * Mapper 接口
 * </p>
 *
 * @author YanYu
 * @since 2023-04-19
 */
public interface PortalDataMapper extends SuperMapper<PortalDataEntity> {
 
    default String getModelDataForm(PortalModPrimary primary) throws Exception {
        PortalDataEntity one = selectOne(primary.getQuery());
        if (one != null) {
            return one.getFormData();
        } else {
            insert(primary.getEntity());
        }
        return "";
    }
 
    default void deleteAll(String portalId) {
        QueryWrapper<PortalDataEntity> query = new QueryWrapper<>();
        query.lambda().eq(PortalDataEntity::getPortalId, portalId);
        this.deleteByIds(this.selectList(query));
    }
 
    /**
     * 创建或更新
     * <p>
     * 门户ID ->(平台、系统ID、用户ID)-> 排版信息
     * 基础:门户ID绑定排版信息(一对多)、 条件:平台、系统ID、用户ID
     */
    default void createOrUpdate(PortalCustomPrimary primary, String formData) throws Exception {
        creUpCom(primary, formData);
    }
 
    default void createOrUpdate(PortalModPrimary primary, String formData) throws Exception {
        creUpCom(primary, formData);
    }
 
    default void createOrUpdate(PortalReleasePrimary primary, String formData) throws Exception {
        creUpCom(primary, formData);
    }
 
    default void creUpCom(MyBatisPrimaryBase<PortalDataEntity> primary, String formData) throws Exception {
        // 自定义数据变量条件:0、门户 1、用户 2、系统 3、平台
        List<PortalDataEntity> list = this.selectList(primary.getQuery());
        if (list.size() < 1) {
            PortalDataEntity creEntity = primary.getEntity();
            creEntity.setFormData(formData);
            insert(creEntity);
        } else if (list.size() == 1) {
            PortalDataEntity upEntity = list.get(0);
            upEntity.setFormData(formData);
            upEntity.setLastModifyTime(DateUtil.getNowDate());
            updateById(upEntity);
        } else {
            throw new Exception(MsgCode.VS414.get());
        }
    }
}