广州市综治平台后端
xusd
2025-06-07 36306491396230522fa20585c2621a7fc899849a
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
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
<?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">
<!-- 
 * @title: 附件信息表
 * @description: 自定义sql,请自行实现业务逻辑
 * @company: hugeinfo
 * @author: liyj
 * @time:2024-08-28 20:06:18
 * @version 1.0.0
-->
<mapper namespace="cn.huge.module.file.dao.mapper.FileInfoMapper">
    <!-- 结果集 -->
    <resultMap id="dataResult" type="cn.huge.module.file.domain.po.FileInfo">
        <result property="id" column="id"/>
        <result property="name" column="name"/>
        <result property="trueName" column="true_name"/>
        <result property="fileName" column="file_name"/>
        <result property="suffix" column="suffix"/>
        <result property="cat" column="cat"/>
        <result property="size" column="size"/>
        <result property="unit" column="unit"/>
        <result property="md5Code" column="md5_code"/>
        <result property="storeWay" column="store_way"/>
        <result property="path" column="path"/>
        <result property="fullPath" column="full_path"/>
        <result property="showUrl" column="show_url"/>
        <result property="downUrl" column="down_url"/>
        <result property="zipUrl" column="zip_url"/>
        <result property="deleteStatus" column="delete_status"/>
        <result property="custId" column="cust_id"/>
        <result property="updateTime" column="update_time"/>
        <result property="createTime" column="create_time"/>
        <result property="ownerId" column="owner_id"/>
        <result property="ownerCat" column="owner_cat"/>
        <result property="ownerType" column="owner_type"/>
        <result property="uploaderId" column="uploader_id"/>
        <result property="uploaderName" column="uploader_name"/>
    </resultMap>
    <resultMap id="fileResult" type="cn.huge.module.file.domain.po.FileInfo">
            <result property="id" column="id"/>
            <result property="name" column="name"/>
            <result property="trueName" column="true_name"/>
            <result property="fileName" column="file_name"/>
            <result property="suffix" column="suffix"/>
            <result property="cat" column="cat"/>
            <result property="size" column="size"/>
            <result property="unit" column="unit"/>
            <result property="md5Code" column="md5_code"/>
            <result property="storeWay" column="store_way"/>
            <result property="path" column="path"/>
            <result property="fullPath" column="full_path"/>
            <result property="showUrl" column="show_url"/>
            <result property="downUrl" column="down_url"/>
            <result property="zipUrl" column="zip_url"/>
            <result property="deleteStatus" column="delete_status"/>
            <result property="custId" column="cust_id"/>
            <result property="updateTime" column="update_time"/>
            <result property="createTime" column="create_time"/>
            <result property="ownerId" column="owner_id"/>
            <result property="ownerCat" column="owner_cat"/>
            <result property="ownerType" column="owner_type"/>
            <result property="uploaderId" column="uploader_id"/>
            <result property="uploaderName" column="uploader_name"/>
    </resultMap>
    <!-- 表 -->
    <sql id='table-name'>dyh_file_info</sql>
    <!-- 字段 -->
    <sql id="column-part">
        id,
        name,
        true_name,
        file_name,
        suffix,
        cat,
        size,
        unit,
        md5_code,
        store_way,
        path,
        full_path,
        show_url,
        down_url,
        zip_url,
        delete_status,
        cust_id,
        update_time,
        create_time
    </sql>
    <!-- 字段 -->
    <sql id="column-part-t">
        t1.id,
        t1.name,
        t1.true_name,
        t1.file_name,
        t1.suffix,
        t1.cat,
        t1.size,
        t1.unit,
        t1.md5_code,
        t1.store_way,
        t1.path,
        t1.full_path,
        t1.show_url,
        t1.down_url,
        t1.zip_url,
        t1.delete_status,
        t1.cust_id,
        t1.update_time,
        t1.create_time
    </sql>
    <!-- 更新实体字段 -->
    <sql id="set-part">
            <if test="entity.name != null">name = #{entity.name},</if>
            <if test="entity.trueName != null">true_name = #{entity.trueName},</if>
            <if test="entity.fileName != null">file_name = #{entity.fileName},</if>
            <if test="entity.suffix != null">suffix = #{entity.suffix},</if>
            <if test="entity.cat != null">cat = #{entity.cat},</if>
            <if test="entity.size != null">size = #{entity.size},</if>
            <if test="entity.unit != null">unit = #{entity.unit},</if>
            <if test="entity.md5Code != null">md5_code = #{entity.md5Code},</if>
            <if test="entity.storeWay != null">store_way = #{entity.storeWay},</if>
            <if test="entity.path != null">path = #{entity.path},</if>
            <if test="entity.fullPath != null">full_path = #{entity.fullPath},</if>
            <if test="entity.showUrl != null">show_url = #{entity.showUrl},</if>
            <if test="entity.downUrl != null">down_url = #{entity.downUrl},</if>
            <if test="entity.zipUrl != null">zip_url = #{entity.zipUrl},</if>
            <if test="entity.deleteStatus != null">delete_status = #{entity.deleteStatus},</if>
            <if test="entity.custId != null">cust_id = #{entity.custId},</if>
            <if test="entity.updateTime != null">update_time = #{entity.updateTime},</if>
            <if test="entity.createTime != null">create_time = #{entity.createTime}</if>
    </sql>
    <!-- 条件 -->
    <sql id="where-part">
        <if test="terms != null">
            <where>
                <if test="terms.id != null and terms.id !=''">
                    and id = #{terms.id}
                </if>
                <if test="terms.name != null and terms.name !=''">
                    and name = #{terms.name}
                </if>
                <if test="terms.trueName != null and terms.trueName !=''">
                    and true_name = #{terms.trueName}
                </if>
                <if test="terms.fileName != null and terms.fileName !=''">
                    and file_name = #{terms.fileName}
                </if>
                <if test="terms.suffix != null and terms.suffix !=''">
                    and suffix = #{terms.suffix}
                </if>
                <if test="terms.cat != null and terms.cat !=''">
                    and cat = #{terms.cat}
                </if>
                <if test="terms.size != null and terms.size !=''">
                    and size = #{terms.size}
                </if>
                <if test="terms.unit != null and terms.unit !=''">
                    and unit = #{terms.unit}
                </if>
                <if test="terms.md5Code != null and terms.md5Code !=''">
                    and md5_code = #{terms.md5Code}
                </if>
                <if test="terms.storeWay != null and terms.storeWay !=''">
                    and store_way = #{terms.storeWay}
                </if>
                <if test="terms.path != null and terms.path !=''">
                    and path = #{terms.path}
                </if>
                <if test="terms.fullPath != null and terms.fullPath !=''">
                    and full_path = #{terms.fullPath}
                </if>
                <if test="terms.showUrl != null and terms.showUrl !=''">
                    and show_url = #{terms.showUrl}
                </if>
                <if test="terms.downUrl != null and terms.downUrl !=''">
                    and down_url = #{terms.downUrl}
                </if>
                <if test="terms.zipUrl != null and terms.zipUrl !=''">
                    and zip_url = #{terms.zipUrl}
                </if>
                <if test="terms.deleteStatus = null and terms.deleteStatus =''">
                    and delete_status = 0
                </if>
                <if test="terms.deleteStatus != null and terms.deleteStatus !=''">
                    and delete_status = #{terms.deleteStatus}
                </if>
                <if test="terms.custId != null and terms.custId !=''">
                    and cust_id = #{terms.custId}
                </if>
                <if test="terms.updateTime != null and terms.updateTime !=''">
                    and DATE_FORMAT(update_time,'%Y-%m-%d') = #{terms.updateTime}
                </if>
                <if test="terms.updateStart != null and terms.updateStart !='' and terms.updateEnd != null and terms.updateEnd !=''">
                    and (DATE_FORMAT(update_time,'%Y-%m-%d') <![CDATA[ >= ]]> #{terms.updateStart}
                        and DATE_FORMAT(update_time,'%Y-%m-%d') <![CDATA[ <= ]]> #{terms.updateEnd})
                </if>
                <if test="terms.createTime != null and terms.createTime !=''">
                    and DATE_FORMAT(create_time,'%Y-%m-%d') = #{terms.createTime}
                </if>
                <if test="terms.createStart != null and terms.createStart !='' and terms.createEnd != null and terms.createEnd !=''">
                    and (DATE_FORMAT(create_time,'%Y-%m-%d') <![CDATA[ >= ]]> #{terms.createStart}
                        and DATE_FORMAT(create_time,'%Y-%m-%d') <![CDATA[ <= ]]> #{terms.createEnd})
                </if>
            </where>
        </if>
    </sql>
    <!-- 更新对象 -->
    <update id="updateFileInfo">
        update
        <include refid="table-name"/>
        <set>
            <include refid="set-part"/>
        </set>
        <where>
            id = #{entity.id}
        </where>
    </update>
    <!-- 条件更新对象 -->
    <update id="updateFileInfoTerms">
        update
        <include refid="table-name"/>
        <set>
            <include refid="set-part"/>
        </set>
        <include refid="where-part"/>
    </update>
    <!--  根据编号物理删除  -->
    <delete id="deleteFileInfo">
        delete from
        <include refid="table-name" />
        where id = #{id}
    </delete>
    <!--  根据条件查询  -->
    <select id="listTerms" resultMap="dataResult">
        select
        <include refid="column-part"/>
        from
        <include refid="table-name" />
        <include refid="where-part"/>
    </select>
    <!--  根据条件统计  -->
    <select id="countTerms" resultType="java.lang.Long">
        select
        COUNT(1)
        from
        <include refid="table-name" />
        <include refid="where-part"/>
    </select>
    <!--  根据条件分页查询  -->
    <select id="pageTerms" resultMap="dataResult">
        SELECT
        <include refid="column-part"/>
        FROM
        <include refid="table-name" />
        <include refid="where-part"/>
        <if test="page.sort != null">
            <foreach collection="page.sort" item="s" index="index" separator="," open="order by ">
                isnull(${s.property}), ${s.property} ${s.direction}
            </foreach>
        </if>
        <if test="page.sort == null">
            order by isnull(create_time), create_time desc
        </if>
        limit #{page.offset}, #{page.size}
    </select>
 
 
    <!-- 查看附件组件-分类查询附件 -->
    <sql id="listFileByCatTerms-where-part">
        <if test="terms != null">
            <where>
                <if test="terms.mainId != null and terms.mainId !=''">
                    and t2.main_id = #{terms.mainId}
                </if>
                <if test="terms.ownerCat != null and terms.ownerCat !=''">
                    and t2.owner_cat = #{terms.ownerCat}
                </if>
                <if test="terms.uploaderType != null and terms.uploaderType !=''">
                    and t2.uploader_type = #{terms.uploaderType}
                </if>
                <if test="terms.createStart != null and terms.createStart !='' and terms.createEnd != null and terms.createEnd !=''">
                    and (DATE_FORMAT(create_time,'%Y-%m-%d') <![CDATA[ >= ]]> #{terms.createStart}
                    and DATE_FORMAT(create_time,'%Y-%m-%d') <![CDATA[ <= ]]> #{terms.createEnd})
                </if>
                <if test="terms.deleteStatus = null and terms.deleteStatus =''">
                    and delete_status = 0
                </if>
                <if test="terms.deleteStatus != null and terms.deleteStatus !=''">
                    and delete_status = #{terms.deleteStatus}
                </if>
            </where>
        </if>
    </sql>
    <!--  查看附件组件-分类查询附件  -->
    <select id="listFileByCatTerms" resultType="cn.huge.module.file.domain.dto.FileForCatDTO">
        select t1.id, t1.name, t1.true_name as trueName,
        t1.suffix, t1.size, t1.unit, t1.show_url as showUrl, t1.down_url as downUrl,
        t2.owner_cat as ownerCat, t2.uploader_id as uploaderId, t2.uploader_name as uploaderName,
        t2.uploader_type as uploaderType, t2.create_time as uploadTime
        from dyh_file_info t1
        left join dyh_file_relate t2 on t1.id = t2.file_id
        <include refid="listFileByCatTerms-where-part"/>
    </select>
 
    <!-- 根据多个编号查询 -->
    <select id="listFile" resultMap="fileResult">
        SELECT t2.owner_id, t2.owner_cat, t2.owner_type, t2.uploader_id, t2.uploader_name,
        <include refid="column-part-t"/>
        FROM dyh_file_info t1
        LEFT JOIN dyh_file_relate t2 ON t1.id = t2.file_id
        WHERE
        t1.delete_status = 0
        and t2.main_id = #{terms.mainId}
        <if test="terms.ownerIds != null and terms.ownerIds !=''">
            and t2.owner_id in (${terms.ownerIds})
        </if>
        <if test="terms.types != null and terms.types !=''">
            and t2.owner_type in (${terms.types})
        </if>
        <if test="terms.typeList != null and terms.typeList.size > 0 ">
            and t2.owner_type in
            <foreach item="type" collection="terms.typeList" separator="," open="(" close=")" index="">
                #{type}
            </foreach>
        </if>
    </select>
 
    <select id="listFileByType" resultMap="fileResult">
        SELECT t2.owner_id, t2.owner_cat, t2.owner_type, t2.uploader_id, t2.uploader_name,
        <include refid="column-part-t"/>
        FROM dyh_file_info t1
        LEFT JOIN dyh_file_relate t2 ON t1.id = t2.file_id
        WHERE
        t1.delete_status = 0
        and t2.main_id = #{terms.mainId}
        and t2.owner_type = #{terms.ownerType}
    </select>
 
    <!--  根据条件查询附件  -->
    <select id="listFileInfoByTerms" resultType="cn.huge.module.sys.dto.FileInfoBaseDTO">
        select t1.id, t1.name, t1.true_name as trueName, t1.file_name as fileName, t1.suffix,
        t1.cat, t1.size, t1.unit, t1.show_url as showUrl, t1.down_url as downUrl, t1.zip_url as zipUrl,
        t2.main_id as mainId, t2.owner_id as ownerId, t2.owner_cat as ownerCat, t1.full_path as fullPath,
        t2.owner_cat as ownerCat, t2.uploader_id as uploaderId, t2.uploader_name as uploaderName,
        t2.uploader_type as uploaderType, t2.create_time as createTime, t2.update_time as updateTime
        from dyh_file_info t1
        left join dyh_file_relate t2 on t1.id = t2.file_id
        WHERE t1.delete_status = 0
        <if test="terms.mainId != null and terms.mainId !=''">
            and t2.main_id = #{terms.mainId}
        </if>
        <if test="terms.ownerId != null and terms.ownerId !=''">
            and t2.owner_id = #{terms.ownerId}
        </if>
        <if test="terms.ownerCat != null and terms.ownerCat !=''">
            and t2.owner_cat = #{terms.ownerCat}
        </if>
        <if test="terms.ownerType != null and terms.ownerType !=''">
            and t2.owner_type = #{terms.ownerType}
        </if>
 
        <if test="terms.mainIdList != null and terms.mainIdList.size > 0 ">
            and t2.main_id in
            <foreach item="mainId" collection="terms.mainIdList" separator="," open="(" close=")" index="">
                #{mainId}
            </foreach>
        </if>
        <if test="terms.ownerIdList != null and terms.ownerIdList.size > 0 ">
            and t2.owner_id in
            <foreach item="ownerId" collection="terms.ownerIdList" separator="," open="(" close=")" index="">
                #{ownerId}
            </foreach>
        </if>
        <if test="terms.ownerCatList != null and terms.ownerCatList.size > 0 ">
            and t2.owner_cat in
            <foreach item="ownerCat" collection="terms.ownerCatList" separator="," open="(" close=")" index="">
                #{ownerCat}
            </foreach>
        </if>
        <if test="terms.ownerTypeList != null and terms.ownerTypeList.size > 0 ">
            and t2.owner_type in
            <foreach item="ownerType" collection="terms.ownerTypeList" separator="," open="(" close=")" index="">
                #{ownerType}
            </foreach>
        </if>
 
    </select>
 
 
<!--    &lt;!&ndash; 根据多个编号查询 &ndash;&gt;-->
<!--    <select id="listByIdsTypes" resultMap="fileResult">-->
<!--        SELECT t2.owner_id, t2.owner_cat, t2.owner_type, t2.uploader_id, t2.uploader_name,-->
<!--        <include refid="column-part-t"/>-->
<!--        FROM dyh_file_info t1-->
<!--        LEFT JOIN dyh_file_relate t2 ON t1.id = t2.file_id-->
<!--        WHERE t2.owner_id in (${ownerIds})-->
<!--        and t2.main_id = #{mainId}-->
<!--        and t2.owner_type in (${types})-->
<!--    </select>-->
</mapper>