yangys
2024-10-15 131d4bcb26e721c09c89d330f78639af7a0eda72
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
<?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.CustomTemplateFieldMapper">
 
    <select id="getSelectBox" resultType="com.qianwen.smartman.modules.system.vo.CustomFieldRelationInfoVO">
        SELECT tf.id fieldId,
        tf.field_name fieldName,
        tf.field_code fieldCode,
        tf.modify_field_code modifyFieldCode,
        tf.field_type fieldType,
        tf.property_json propertyJson,
        tf.system_field systemField,
        tf.sys_field_must sysFieldMust,
        tfr.sort,
        tfr.id relationId
        FROM blade_custom_template_field tf
        LEFT JOIN blade_custom_field_relation tfr ON tf.id = tfr.field_id
        AND tfr.template_id = #{templateId}
        AND tfr.config_type = #{configType}
        AND tfr.is_deleted = 0
        WHERE tf.is_deleted = 0
        and tf.business_type = #{businessType}
        <if test="configType == 1 ">
            and tf.add_show=1
        </if>
        <if test="configType == 2 ">
            and tf.update_show=1
        </if>
        <if test="configType == 3 ">
            and tf.view_show=1
        </if>
        <if test="_databaseId=='mysql'">
            ORDER BY tfr.sort is null,tfr.sort,tf.id ASC
        </if>
        <if test="_databaseId=='dm'">
            ORDER BY tfr.sort nulls last,tf.id ASC
        </if>
        <if test="_databaseId=='oracle'">
            ORDER BY tfr.sort,tf.id ASC
        </if>
    </select>
 
    <select id="listField" resultType="com.qianwen.smartman.modules.system.vo.CustomTemplateFieldListVO">
        SELECT tf.id fieldId,
        tf.field_name fieldName,
        tf.sys_field_must sysFieldMust,
        tf.field_description fieldDescription,
        tf.default_value defaultValue,
        tfr.must_field mustField,
        tf.support_update supportUpdate,
        tf.system_field systemField,
        tfr.id id,
        tfr.config_type
        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 tf.id is not null
        AND tfr.template_id = #{templateId}
        <if test="configType != null ">
            AND tfr.config_type = #{configType}
        </if>
        ORDER BY tfr.sort ASC
    </select>
    <!--根据模版id获取绑定的字段信息-->
    <select id="getColumns" resultType="com.qianwen.smartman.modules.system.dto.CustomTemplateColumnDTO">
        SELECT
        ct.id as templateId,
        ct.template_name as templateName,
        tf.id as fieldId,
        tf.field_name as fieldName,
        tf.field_code as fieldCode,
        tf.modify_field_code as modifyFieldCode,
        tf.query_field_code as queryFieldCode,
        tf.field_description as fieldDescription,
        tf.field_type as fieldType,
        tf.property_json as propertyJson,
        tf.system_field as systemField,
        tf.sys_field_must as sysFieldMust,
        tf.default_value as defaultValue,
        tf.support_query as supportQuery,
        tf.support_update as supportUpdate,
        tf.support_export as supportExport,
        tfr.must_field as mustField
        FROM
        blade_custom_template_field tf
        LEFT JOIN blade_custom_field_relation tfr ON tfr.field_id = tf.id
        LEFT JOIN blade_custom_template ct ON ct.id = tfr.template_id
        where
        tf.is_deleted=0
        and tfr.is_deleted=0 and tf.is_deleted=0
        <choose>
            <when test="templateId !=null">
                and ct.id=#{templateId}
            </when>
            <otherwise>
                and tf.business_type=2
                and ct.id is not null
            </otherwise>
        </choose>
        AND tfr.config_type=#{configType}  ORDER BY tfr.sort ASC
    </select>
</mapper>