Newer
Older
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
package com.ic.er;
import com.ic.er.bean.entity.EntityDO;
import com.ic.er.bean.entity.RelationshipDO;
import com.ic.er.common.Cardinality;
import com.ic.er.common.ResultState;
import com.ic.er.common.Utils;
import lombok.Data;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.UUID;
@Data
public class Relationship {
private Long ID;
private String name;
private Long viewID;
private Long firstEntityID;
private Long secondEntityID;
private Long firstAttributeID;
private Long secondAttributeID;
private Cardinality cardinality;
private Date gmtCreate;
private Date gmtModified;
public Relationship(Long ID, String name, Long viewID, Long firstEntityID, Long secondEntityID, Long firstAttributeID, Long secondAttributeID, Cardinality cardinality, Date gmtCreate, Date gmtModified) {
this.ID = ID;
this.name = name;
this.viewID = viewID;
this.firstEntityID = firstEntityID;
this.secondEntityID = secondEntityID;
this.firstAttributeID = firstAttributeID;
this.secondAttributeID = secondAttributeID;
this.cardinality = cardinality;
this.gmtCreate = gmtCreate;
this.gmtModified = gmtModified;
if (this.ID == 0) {
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
return ER.relationshipMapper.insert(new RelationshipDO(
0L,
this.name,
this.viewID,
this.firstEntityID,
this.secondEntityID,
this.firstAttributeID,
this.secondAttributeID,
this.cardinality,
0,
this.gmtCreate,
this.gmtModified
));
}
public static Relationship TransformFromDB(RelationshipDO relationshipDO) {
return new Relationship(relationshipDO.getId(), relationshipDO.getName(), relationshipDO.getView_id(),
relationshipDO.getFirst_entity_id(), relationshipDO.getSecond_entity_id(),
relationshipDO.getFirst_attribute_id(), relationshipDO.getSecond_attribute_id(),
relationshipDO.getCardinality(),
relationshipDO.getGmt_create(), relationshipDO.getGmt_modified());
}
public static List<Relationship> TransListFormFromDB(List<RelationshipDO> doList) {
List<Relationship> ret = new ArrayList<>();
for (RelationshipDO RelationshipDO : doList) {
ret.add(TransformFromDB(RelationshipDO));
}
return ret;
}
public static List<Relationship> queryByRelationship(RelationshipDO RelationshipDO) {
return TransListFormFromDB(ER.relationshipMapper.selectByRelationship(RelationshipDO));
}
ResultState deleteDB() {
int res = ER.relationshipMapper.deleteById(this.ID);
if (res == 0) {
return ResultState.ok();
} else {
return ResultState.build(1, "db error");
}
}
ResultState updateDB() {