地质所 沉降监测网建设项目
zmk
2024-05-15 9e3afc6d0fa514f986d3fea40fa23124e6fb5070
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
<?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.javaweb.cms.mapper.AlbumMapper">
 
    <resultMap type="Album" id="AlbumResult">
        <result property="albumId" column="album_id" />
        <result property="albumName" column="album_name" />
        <result property="userId" column="user_id" />
        <result property="deptId" column="dept_id" />
        <result property="albumType" column="album_type" />
        <result property="description" column="description" />
        <result property="createBy" column="create_by" />
        <result property="createTime" column="create_time" />
        <result property="auditState" column="audit_state" />
        <result property="code" column="code" />
        <result property="width" column="width" />
        <result property="height" column="height" />
    </resultMap>
 
    <sql id="selectAlbumVo">
        select a.album_id, a.album_name, a.user_id, a.dept_id, a.album_type,
        a.description, a.create_by, a.create_time,
        a.audit_state,a.code,a.width,a.height from cms_album a
    </sql>
 
    <select id="selectAlbumList" parameterType="Album" resultMap="AlbumResult">
        <include refid="selectAlbumVo" />
        <where>
            <if test="albumName != null  and albumName != ''"> and a.album_name like concat('%', #{albumName}, '%')
            </if>
            <if test="albumType != null  and albumType != ''"> and a.album_type = #{albumType}</if>
            <if test="code != null  and code != ''"> and a.code = #{code}</if>
            <if test="auditState != null "> and a.audit_state = #{auditState}</if>
            ${params.dataScope}
        </where>
 
    </select>
 
    <select id="selectAlbumById" parameterType="String" resultMap="AlbumResult">
        <include refid="selectAlbumVo" />
        where a.album_id = #{albumId}
    </select>
 
    <select id="selectAlbumByCode" parameterType="String" resultMap="AlbumResult">
        <include refid="selectAlbumVo" />
        where a.code = #{code}
    </select>
 
    <insert id="insertAlbum" parameterType="Album">
        insert into cms_album
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="albumId != null  and albumId != ''">album_id,</if>
            <if test="albumName != null  and albumName != ''">album_name,</if>
            <if test="userId != null  and userId != ''">user_id,</if>
            <if test="deptId != null  and deptId != ''">dept_id,</if>
            <if test="albumType != null  and albumType != ''">album_type,</if>
 
            <if test="description != null  and description != ''">description,</if>
            <if test="createBy != null  and createBy != ''">create_by,</if>
            <if test="createTime != null ">create_time,</if>
            <if test="auditState != null ">audit_state,</if>
            <if test="code != null  and code != ''">code,</if>
            <if test="width != null">width,</if>
            <if test="height != null">height,</if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="albumId != null  and albumId != ''">#{albumId},</if>
            <if test="albumName != null  and albumName != ''">#{albumName},</if>
            <if test="userId != null  and userId != ''">#{userId},</if>
            <if test="deptId != null  and deptId != ''">#{deptId},</if>
            <if test="albumType != null  and albumType != ''">#{albumType},</if>
 
            <if test="description != null  and description != ''">#{description},</if>
            <if test="createBy != null  and createBy != ''">#{createBy},</if>
            <if test="createTime != null ">#{createTime},</if>
            <if test="auditState != null ">#{auditState},</if>
            <if test="code != null  and code != ''">#{code},</if>
            <if test="width != null">#{width},</if>
            <if test="height != null">#{height},</if>
        </trim>
    </insert>
 
    <insert id="insertAlbumMaterial" useGeneratedKeys="true"
        keyProperty="id" parameterType="AlbumMaterial">
        insert into cms_album_material (id,album_id,material_id,link,sort)
        values
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            null,
            <if test="albumId != null  and albumId != ''">#{albumId},</if>
            <if test="materialId != null  and materialId != ''">#{materialId},</if>
            <if test="link != null  and link != ''">#{link},</if>
            <if test="sort != null  and sort != ''">#{sort},</if>
        </trim>
    </insert>
 
    <insert id="insertAlbumMaterialBatch" parameterType="AlbumMaterial">
        insert into cms_album_material (id,album_id,material_id,link,sort)
        values
        <foreach collection="list" item="item" separator=",">
            (null,#{item.albumId},#{item.materialId},#{item.link},#{item.sort})
        </foreach>
    </insert>
 
    <resultMap type="AlbumMaterial" id="AlbumMaterialResult">
        <result property="id" column="id" />
        <result property="link" column="link" />
        <result property="sort" column="sort" />
        <result property="materialId" column="material_id" />
        <result property="albumId" column="album_id" />
    </resultMap>
 
 
    <select id="selectAlbumMaterialByIds" parameterType="String"
        resultMap="AlbumMaterialResult">
        select * from cms_album_material where id in
        <foreach item="id" collection="array" open="(" separator=","
            close=")">
            #{id}
        </foreach>
 
    </select>
    <delete id="deleteAlbumMaterialByIds" parameterType="String">
        delete from cms_album_material where id in
        <foreach item="id" collection="array" open="(" separator=","
            close=")">
            #{id}
        </foreach>
    </delete>
    <update id="updateAlbum" parameterType="Album">
        update cms_album
        <trim prefix="SET" suffixOverrides=",">
            <if test="albumName != null  and albumName != ''">album_name = #{albumName},</if>
            <if test="userId != null  and userId != ''">user_id = #{userId},</if>
            <if test="deptId != null  and deptId != ''">dept_id = #{deptId},</if>
            <if test="albumType != null  and albumType != ''">album_type = #{albumType},</if>
 
            <if test="description != null  and description != ''">description = #{description},</if>
            <if test="createBy != null  and createBy != ''">create_by = #{createBy},</if>
            <if test="createTime != null ">create_time = #{createTime},</if>
            <if test="auditState != null ">audit_state = #{auditState},</if>
            <if test="code != null ">code = #{code},</if>
            <if test="width != null ">width = #{width},</if>
            <if test="height != null ">height = #{height},</if>
        </trim>
        where album_id = #{albumId}
    </update>
 
    <delete id="deleteAlbumById" parameterType="String">
        delete from cms_album where album_id = #{albumId}
    </delete>
 
    <delete id="deleteAlbumByIds" parameterType="String">
        delete from cms_album where album_id in
        <foreach item="albumId" collection="array" open="(" separator=","
            close=")">
            #{albumId}
        </foreach>
    </delete>
 
</mapper>