dengzedong
2024-12-12 94c169d9c7809ae78927608ef55c61d24459fdab
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
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
<?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.iailab.module.model.mpk.dao.MpkFileDao">
 
    <resultMap id="mpkFile" type="com.iailab.module.model.mpk.dto.MpkFileDTO">
        <id property="id" column="id"/>
        <result property="pyName" column="py_name"/>
        <result property="pyChineseName" column="py_chinese_name"/>
        <result property="filePath" column="file_path"/>
        <result property="pyType" column="py_type"/>
        <result property="pkgName" column="pkg_name"/>
        <result property="className" column="class_name"/>
        <result property="pyModule" column="py_module"/>
        <result property="icon" column="icon"/>
        <result property="menuName" column="menu_name"/>
        <result property="groupName" column="group_name"/>
        <result property="remark" column="remark"/>
        <result property="creator" column="creator"/>
        <result property="createDate" column="create_date"/>
        <result property="updater" column="updater"/>
        <result property="updateDate" column="update_date"/>
        <collection property="modelMethods" ofType="com.iailab.module.model.mpk.dto.ModelMethodDTO">
            <id property="id" column="method_id"/>
            <result property="methodName" column="method_name"/>
            <result property="dataLength" column="data_length"/>
            <result property="model" column="model"/>
            <result property="resultKey" column="result_key"/>
            <collection property="methodSettings" ofType="com.iailab.module.model.mpk.dto.MethodSettingDTO">
                <id property="id" column="setting_id"/>
                <result property="settingKey" column="setting_key"/>
                <result property="name" column="setting_name"/>
                <result property="value" column="value"/>
                <result property="type" column="type"/>
                <result property="valueType" column="value_type"/>
                <result property="max" column="max"/>
                <result property="min" column="min"/>
                <collection property="settingSelects" ofType="com.iailab.module.model.mpk.dto.SettingSelectDTO">
                    <id property="id" column="select_id"/>
                    <result property="selectKey" column="select_key"/>
                    <result property="name" column="select_name"/>
                </collection>
            </collection>
        </collection>
    </resultMap>
 
    <select id="get" resultMap="mpkFile">
        SELECT
            a.*,
            b.id method_id,
            b.method_name,
            b.data_length,
            b.model,
            b.result_key,
            c.id setting_id,
            c.setting_key,
            c.name setting_name,
            c.value,
            c.type,
            c.value_type,
            c.max,
            c.min,
            d.id select_id,
            d.select_key,
            d.name select_name
        FROM
            t_mpk_file a
            LEFT JOIN t_mpk_model_method b ON a.id = b.mpk_file_id
            LEFT JOIN t_mpk_method_setting c ON b.id = c.method_id
            LEFT JOIN t_mpk_setting_select d ON c.id = d.setting_id
        WHERE a.id = #{id}
        ORDER BY b.sort,c.sort,d.sort
    </select>
    <select id="selectByIds" resultMap="mpkFile">
        SELECT
            a.*,
            b.id method_id,
            b.method_name,
            b.data_length,
            b.model,
            b.result_key,
            c.id setting_id,
            c.setting_key,
            c.name setting_name,
            c.value,
            c.type,
            c.value_type,
            c.max,
            c.min,
            d.id select_id,
            d.select_key,
            d.name select_name
        FROM
            t_mpk_file a
                LEFT JOIN t_mpk_model_method b ON a.id = b.mpk_file_id
                LEFT JOIN t_mpk_method_setting c ON b.id = c.method_id
                LEFT JOIN t_mpk_setting_select d ON c.id = d.setting_id
                LEFT JOIN t_mpk_file_menu e ON e.name = a.menu_name
                LEFT JOIN t_mpk_file_group f ON f.menu_id = e.id and f.name = a.group_name
        WHERE a.id in
        <foreach collection="ids" item="item" open="(" close=")" separator=",">
            #{item}
        </foreach>
        ORDER BY b.sort,c.sort,d.sort,e.sort,f.sort,a.create_date
    </select>
    <select id="list" resultMap="mpkFile" parameterType="java.util.Map">
        SELECT
        a.*,
        b.id method_id,
        b.method_name,
        b.data_length,
        b.model,
        b.result_key,
        c.id setting_id,
        c.setting_key,
        c.name setting_name,
        c.value,
        c.type,
        c.value_type,
        c.max,
        c.min,
        d.id select_id,
        d.select_key,
        d.name select_name
        FROM
        t_mpk_file a
        LEFT JOIN t_mpk_model_method b ON a.id = b.mpk_file_id
        LEFT JOIN t_mpk_method_setting c ON b.id = c.method_id
        LEFT JOIN t_mpk_setting_select d ON c.id = d.setting_id
        LEFT JOIN t_mpk_file_menu e ON e.name = a.menu_name
        LEFT JOIN t_mpk_file_group f ON f.menu_id = e.id and f.name = a.group_name
        <where>
            <if test="params.pyType != null and params.pyType != ''">
                AND a.py_type = #{params.pyType}
            </if>
        </where>
        ORDER BY b.sort,c.sort,d.sort,e.sort,f.sort,a.create_date
    </select>
    <select id="getProjectModelCount" resultType="java.lang.Integer" parameterType="java.lang.String">
        SELECT
            count(*)
        FROM
            t_mpk_project_model
        WHERE
            project_id = #{projectId}
    </select>
    <select id="getProjectModel" resultMap="mpkFile">
        SELECT
            t3.*,
            t4.id method_id,
            t4.method_name,
            t4.data_length,
            t4.model,
            t4.result_key,
            t5.id setting_id,
            t5.setting_key,
            t5.name setting_name,
            t5.value,
            t5.type,
            t5.value_type,
            t5.max,
            t5.min,
            t6.id select_id,
            t6.select_key,
            t6.name select_name
        FROM
            (
                SELECT
                    t2.*
                FROM
                    t_mpk_project_model t1
                        LEFT JOIN t_mpk_file t2 ON t1.model_id = t2.id
                WHERE
                    t1.project_id = #{params.projectId}
                    <if test="params.pyName != null and params.pyName != ''">
                        AND t2.py_name LIKE CONCAT('%',#{params.pyName},'%')
                    </if>
                ORDER BY
                    t2.create_date DESC
                    LIMIT #{params.offset},#{params.pageSize}
            ) t3
                LEFT JOIN t_mpk_model_method t4 ON t3.id = t4.mpk_file_id
                LEFT JOIN t_mpk_method_setting t5 ON t4.id = t5.method_id
                LEFT JOIN t_mpk_setting_select t6 ON t5.id = t6.setting_id
    </select>
    <select id="selectByProjectId" resultMap="mpkFile" parameterType="java.lang.String">
        SELECT
        a.*,
        b.id method_id,
        b.method_name,
        b.data_length,
        b.model,
        b.result_key,
        c.id setting_id,
        c.setting_key,
        c.name setting_name,
        c.value,
        c.type,
        c.value_type,
        c.max,
        c.min,
        d.id select_id,
        d.select_key,
        d.name select_name
        FROM
        t_mpk_file a
        LEFT JOIN t_mpk_project_model p ON a.id = p.model_id
        LEFT JOIN t_mpk_model_method b ON a.id = b.mpk_file_id
        LEFT JOIN t_mpk_method_setting c ON b.id = c.method_id
        LEFT JOIN t_mpk_setting_select d ON c.id = d.setting_id
        LEFT JOIN t_mpk_file_menu e ON e.name = a.menu_name
        LEFT JOIN t_mpk_file_group f ON f.menu_id = e.id and f.name = a.group_name
        WHERE p.project_id = #{projectId}
        ORDER BY b.sort,c.sort,d.sort,e.sort,f.sort,a.create_date
    </select>
</mapper>