yanghb
2025-02-18 031748e56f04bf939927fdc54f31df29660d9363
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
<?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.zzg.system.mapper.system.SysFilesMapper">
 
    <resultMap type="SysFiles" id="SysFilesResult">
        <result property="id" column="id"/>
        <result property="fileId" column="file_id"/>
        <result property="title" column="title"/>
        <result property="path" column="path"/>
        <result property="md5" column="md5"/>
        <result property="createBy" column="create_by"/>
        <result property="createTime" column="create_time"/>
        <result property="realPath" column="real_path"/>
    </resultMap>
 
    <sql id="selectSysFilesVo">
        select id,
               file_id,
               title,
               path,
               md5,
               create_by,
               create_time,
               real_path
        from sys_files
    </sql>
 
    <select id="selectSysFilesList" parameterType="SysFiles" resultMap="SysFilesResult">
        <include refid="selectSysFilesVo"/>
        <where>
            <if test="fileId != null and fileId != ''">and file_id = #{fileId},</if>
            <if test="title != null  and title != ''">and title = #{title}</if>
            <if test="path != null  and path != ''">and path like concat('%', #{path}, '%')</if>
            <if test="md5 != null  and md5 != ''">and md5 = #{md5}</if>
            <if test="realPath != null  and realPath != ''">and real_path = #{realPath}</if>
        </where>
    </select>
 
 
    <select id="selectSysFiles" parameterType="SysFiles" resultMap="SysFilesResult">
        <include refid="selectSysFilesVo"/>
        <where>
            <if test="fileId != null and fileId != ''">and file_id = #{fileId},</if>
            <if test="title != null  and title != ''">and title = #{title}</if>
            <if test="path != null  and path != ''">and path = #{path}</if>
            <if test="md5 != null  and md5 != ''">and md5 = #{md5}</if>
            <if test="realPath != null  and realPath != ''">and real_path = #{realPath}</if>
        </where>
        limit 1
    </select>
 
    <select id="selectSysFilesByFileId" parameterType="SysFiles" resultMap="SysFilesResult">
        <include refid="selectSysFilesVo"/>
        where
        file_id = #{fileId}
        limit 1
    </select>
 
 
    <select id="selectSysFilesById" parameterType="Long" resultMap="SysFilesResult">
        <include refid="selectSysFilesVo"/>
        where id = #{id}
    </select>
 
 
    <select id="selectSysFilesListByFileIds" resultMap="SysFilesResult">
        select id, file_id , title, path, md5, create_by, create_time ,real_path from sys_files
        where file_id in
        <foreach collection="fileIds" item="id" separator="," open="(" close=")">
            #{id}
        </foreach>
 
    </select>
 
 
    <insert id="insertSysFiles" parameterType="SysFiles" useGeneratedKeys="true" keyProperty="id">
        insert into sys_files
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null and id != ''">id,</if>
            <if test="fileId != null and fileId != ''">file_id,</if>
            <if test="title != null and title != ''">title,</if>
            <if test="path != null and path != ''">path,</if>
            <if test="md5 != null and md5 != ''">md5,</if>
            <if test="createBy != null">create_by,</if>
            <if test="createTime != null">create_time,</if>
            <if test="realPath != null">real_path,</if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="id != null and id != ''">#{id},</if>
            <if test="fileId != null and fileId != ''">#{fileId},</if>
            <if test="title != null and title != ''">#{title},</if>
            <if test="path != null and path != ''">#{path},</if>
            <if test="md5 != null and md5 != ''">#{md5},</if>
            <if test="createBy != null">#{createBy},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="realPath != null">#{realPath},</if>
        </trim>
    </insert>
 
    <update id="updateSysFiles" parameterType="SysFiles">
        update sys_files
        <trim prefix="SET" suffixOverrides=",">
            <if test="fileId != null and fileId != ''">file_id = #{fileId},</if>
            <if test="title != null and title != ''">title = #{title},</if>
            <if test="path != null and path != ''">path = #{path},</if>
            <if test="md5 != null and md5 != ''">md5 = #{md5},</if>
            <if test="createBy != null">create_by = #{createBy},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="realPath != null">real_path = #{realPath},</if>
        </trim>
        where id = #{id}
    </update>
 
    <delete id="deleteSysFilesById" parameterType="Long">
        delete
        from sys_files
        where id = #{id}
    </delete>
 
    <delete id="deleteSysFilesByIds" parameterType="String">
        delete from sys_files where id in
        <foreach item="id" collection="array" open="(" separator="," close=")">
            #{id}
        </foreach>
    </delete>
 
 
    <delete id="deleteSysFilesByFileIds" parameterType="String">
        delete from sys_files where file_id in
        <foreach item="id" collection="list" open="(" separator="," close=")">
            #{id}
        </foreach>
    </delete>
 
</mapper>