yangys
2025-04-11 120755e6874893d284fda5f617924d46960286c0
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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.qianwen.smartman.modules.system.mapper.CustomTemplateFieldRelationMapper">
 
    <select id="getConditionFields" parameterType="long"
            resultType="com.qianwen.smartman.modules.system.vo.CustomConditionFieldInfoVO">
        SELECT tf.id fieldId,
        tf.field_name fieldName,
        tf.field_description fieldDescription,
        tf.field_code fieldCode,
        tfr.id relationId,
        <if test="_databaseId == 'mysql' ">
            IF
            (tfr.id IS NULL, 0, 1) querySupport,
        </if>
        <if test="_databaseId == 'dm' ">
            IF
            (tfr.id IS NULL, 0, 1) querySupport,
        </if>
        <if test="_databaseId == 'oracle' ">
            CASE
            WHEN
            tfr.id IS NULL THEN
            0 ELSE 1
            END ,
        </if>
        tfr.sort querySort,
        tf.system_field systemField
        FROM
        blade_custom_template_field tf
        LEFT JOIN blade_custom_field_relation tfr ON tfr.field_id = tf.id
        AND tfr.is_deleted = 0
        AND tfr.config_type = 5
        AND tfr.template_id = #{templateId}
        WHERE
        tf.is_deleted = 0
        AND tf.support_query = 1
        and tf.business_type = #{businessType}
        ORDER BY
        tf.id
    </select>
 
 
    <select id="getInsertField" parameterType="long"
            resultType="com.qianwen.smartman.modules.system.vo.CustomTemplateFieldRelationVO">
        SELECT tf.id fieldId,
        tf.field_name fieldName,
        tf.field_code fieldCode,
        tf.field_type fieldType,
        tfr.id relationId,
        tfr.sort import_sort,
        tf.system_field systemField
        FROM blade_custom_field_relation tfr
        LEFT JOIN blade_custom_template_field tf ON tfr.field_id = tf.id
        AND tf.id IS NOT NULL
        WHERE tfr.is_deleted = 0
        AND tfr.config_type = 1
        AND tfr.template_id = #{query.templateId}
        <if test="query.fieldNames != null and query.fieldNames.size > 0">
            AND tf.field_name IN
            <foreach collection="query.fieldNames" separator="," item="item" open="(" close=")" index="">
                #{item}
            </foreach>
        </if>
        <if test="query.relationIds != null and query.relationIds.size > 0">
            AND tfr.id IN
            <foreach collection="query.relationIds" separator="," item="item" open="(" close=")" index="">
                #{item}
            </foreach>
        </if>
        order by tfr.sort
    </select>
 
 
    <select id="getSystemFieldMaxSort" resultType="int">
        SELECT max(sort)
        FROM blade_custom_field_relation tfr
                 left join blade_custom_template_field tf on tfr.field_id = tf.id
        WHERE tfr.is_deleted = 0
          and tfr.template_id = #{templateId}
          and tfr.config_type = #{configType}
          and tf.system_field = 1
    </select>
 
    <select id="getImportFieldsByBusinessType"
            resultType="com.qianwen.smartman.modules.system.vo.CustomImportFieldInfoVO">
        SELECT tf.id           fieldId,
               tf.field_name   fieldName,
               tf.field_code   fieldCode,
               tf.system_field systemField,
               tf.must_import  mustField,
               tf.must_import  importField,
               tf.import_sort  importSort
        FROM blade_custom_template_field tf
        WHERE tf.is_deleted = 0
          AND tf.support_import = 1
          and tf.add_show = 1
          AND tf.business_type = #{businessType}
        order by tf.import_sort asc
    </select>
    <select id="getImportFields"
            resultType="com.qianwen.smartman.modules.system.dto.CustomTemplateFieldRelationDTO">
        SELECT
        tf.field_name fieldName,
        tf.field_code fieldCode,
        tfr.id id,
        tf.system_field systemField,
        tfr.must_field mustField,
        tfr.template_id templateId,
        ct.template_name templateName,
        tf.must_import mustImport
        FROM blade_custom_field_relation tfr
        LEFT JOIN blade_custom_template_field tf ON tfr.field_id = tf.id
        LEFT JOIN blade_custom_template ct ON tfr.template_id = ct.id
        WHERE tf.is_deleted = 0
        AND tfr.is_deleted = 0
        AND tfr.config_type = 1
        and tf.add_show = 1
        AND tfr.template_id in
        <foreach collection="templateIds" separator="," item="item" open="(" close=")" index="index">
            #{item}
        </foreach>
        order by tf.import_sort asc
    </select>
    <select id="getOldstRelation"
            resultType="com.qianwen.smartman.modules.system.vo.CustomImportFieldInfoVO">
        SELECT tf.id            fieldId,
               tf.field_name    fieldName,
               tf.field_code    fieldCode,
               tfr.id           id,
               tf.system_field  systemField,
               tfr.must_field   mustField,
               tfr.template_id  templateId,
               ct.template_name templateName,
               tf.must_import   mustImport,
               tfr.sort         sort
        FROM blade_custom_field_relation tfr
                 LEFT JOIN blade_custom_template_field tf ON tfr.field_id = tf.id
                 LEFT JOIN blade_custom_template ct ON tfr.template_id = ct.id
        WHERE tf.system_field = 1
          AND tfr.config_type = #{configType}
          AND tfr.template_id = #{templateId}
        order by tfr.create_time asc
    </select>
 
</mapper>