1821349743@qq.com
2023-02-20 93dd9bc3f16b0f626761ec624f2dc78037568897
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
package com.product.data.entity;
 
import com.product.core.entity.FieldSetEntity;
import com.product.data.config.DatabaseType;
import com.product.data.utli.CommonUtils;
 
/**
 * @Author cheng
 * @Date 2022/2/10 13:45
 * @Desc 同步字段
 */
public class SyncFieldEntity {
 
    /**
     * 来源字段
     */
    private String sourceField;
    /**
     * 目标字段
     */
    private String targetField;
    /**
     * 字段类型 0 普通字段 1 增量标识字段 2 唯一标识字段 3 更新标识字段
     */
    private String fieldType;
 
    private DatabaseType dbType;
 
    public SyncFieldEntity(FieldSetEntity fse, DatabaseType dbType) {
        this.dbType = dbType;
        this.sourceField = fse.getString("source_field");
        this.targetField = fse.getString("target_field");
        this.fieldType = fse.getString("field_type");
    }
 
    @Override
    public String toString() {
        return "SyncFieldEntity{" +
                "sourceField='" + sourceField + '\'' +
                ", targetField='" + targetField + '\'' +
                ", fieldType=" + fieldType +
                '}';
    }
 
    public boolean isUnique() {
        return ("," + fieldType + ",").indexOf(",2,") != -1;
    }
 
    public boolean isIncrement() {
        return ("," + fieldType + ",").indexOf(",1,") != -1;
    }
 
    public boolean isUpdate() {
        return ("," + fieldType + ",").indexOf(",3,") != -1;
    }
 
 
    public String getSourceFieldName() {
        return sourceField;
    }
    public String getSourceField() {
        return CommonUtils.getFieldName(sourceField, dbType);
    }
 
    public void setSourceField(String sourceField) {
        this.sourceField = sourceField;
    }
 
    public String getTargetFieldName() {
        return targetField;
    }
 
    public String getTargetField() {
        return CommonUtils.getFieldName(targetField, DatabaseType.MySql);
    }
 
    public void setTargetField(String targetField) {
        this.targetField = targetField;
    }
 
    public String getFieldType() {
        return fieldType;
    }
 
    public void setFieldType(String fieldType) {
        this.fieldType = fieldType;
    }
}