1
13693261870
2022-09-16 762f2fb45db004618ba099aa3c0bd89dba1eb843
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
<?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.landtool.lanbase.modules.sys.dao.SysAttachmentDao">
 
    <select id="queryObject" resultType="com.landtool.lanbase.modules.sys.entity.SysAttachment">
        select * from sys_attachment where id = #{id}
    </select>
 
    <select id="queryList" parameterType="map" resultType="com.landtool.lanbase.modules.sys.entity.SysAttachment">
 
        SELECT *
        FROM(
            SELECT ROW_NUMBER() OVER(ORDER BY B.id) AS rownumber,B.*
            FROM (
 
                SELECT * FROM SYS_ATTACHMENT
                <where>
                    <if test="title != null and title != ''">
                        AND title LIKE ('%' || #{title} || '%')
                    </if>
                    <if test="mime_type != null and mime_type != ''">
                        AND mime_type LIKE ('%' || #{mime_type}  || '%')
                    </if>
                </where>
 
          ) B
        ) A
        WHERE rownumber > #{lowerOffset} AND  <![CDATA[ rownumber <= ${upperOffset} ]]>
    </select>
 
    <select id="queryTotal" parameterType="map" resultType="int">
        SELECT COUNT(*) FROM SYS_ATTACHMENT
        <where>
            <if test="title != null and title != ''">
                AND title LIKE ('%' || #{title} || '%')
            </if>
            <if test="mime_type != null and mime_type != ''">
                AND mime_type LIKE ('%' || #{mime_type}  || '%')
            </if>
        </where>
    </select>
 
    <delete id="deleteBatch">
        delete from SYS_ATTACHMENT where id in
        <foreach item="id" collection="array" open="(" separator="," close=")">
            #{id}
        </foreach>
    </delete>
 
    <insert id="save" parameterType="com.landtool.lanbase.modules.sys.entity.SysAttachment">
        insert into SYS_ATTACHMENT
        (
            title,
            user_id,
            path,
            mime_type,
            suffix,
            create_time
        )
        values
        (
            #{title},
            #{userId},
            #{path},
            #{mimeType},
            #{suffix},
            #{createTime}
        )
    </insert>
    
    <delete id="deleteByPath">
         delete from SYS_ATTACHMENT where path = #{path}
    </delete>
</mapper>