地质所 沉降监测网建设项目
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
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
<?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.AdMapper">
 
    <resultMap type="Ad" id="AdResult">
        <result property="adId" column="ad_id" />
        <result property="adCode" column="ad_code" />
        <result property="adName" column="ad_name" />
        <result property="width" column="width" />
        <result property="height" column="height" />
        <result property="status" column="status" />
        <result property="userId" column="user_id" />
        <result property="deptId" column="dept_id" />
        <result property="description" column="description" />
        <result property="createBy" column="create_by" />
        <result property="createTime" column="create_time" />
    </resultMap>
 
    <sql id="selectAdVo">
        select ad_id, ad_code, ad_name, width, height, status, user_id, dept_id,
        description, create_by, create_time from cms_ad
    </sql>
 
    <select id="selectAdList" parameterType="Ad" resultMap="AdResult">
        <include refid="selectAdVo" />
        <where>
            <if test="adCode != null  and adCode != ''"> and ad_code like concat('%', #{adCode}, '%')</if>
            <if test="adName != null  and adName != ''"> and ad_name like concat('%', #{adName}, '%')</if>
            <if test="status != null "> and status = #{status}</if>
        </where>
    </select>
 
    <select id="selectAdById" parameterType="Long" resultMap="AdResult">
        <include refid="selectAdVo" />
        where ad_id = #{adId}
    </select>
 
    <insert id="insertAd" parameterType="Ad" useGeneratedKeys="true"
        keyProperty="adId">
        insert into cms_ad
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="adCode != null  and adCode != ''">ad_code,</if>
            <if test="adName != null  and adName != ''">ad_name,</if>
            <if test="width != null ">width,</if>
            <if test="height != null ">height,</if>
            <if test="status != null ">status,</if>
            <if test="userId != null  and userId != ''">user_id,</if>
            <if test="deptId != null  and deptId != ''">dept_id,</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>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="adCode != null  and adCode != ''">#{adCode},</if>
            <if test="adName != null  and adName != ''">#{adName},</if>
            <if test="width != null ">#{width},</if>
            <if test="height != null ">#{height},</if>
            <if test="status != null ">#{status},</if>
            <if test="userId != null  and userId != ''">#{userId},</if>
            <if test="deptId != null  and deptId != ''">#{deptId},</if>
            <if test="description != null  and description != ''">#{description},</if>
            <if test="createBy != null  and createBy != ''">#{createBy},</if>
            <if test="createTime != null ">#{createTime},</if>
        </trim>
    </insert>
 
    <update id="updateAd" parameterType="Ad">
        update cms_ad
        <trim prefix="SET" suffixOverrides=",">
            <if test="adCode != null  and adCode != ''">ad_code = #{adCode},</if>
            <if test="adName != null  and adName != ''">ad_name = #{adName},</if>
            <if test="width != null ">width = #{width},</if>
            <if test="height != null ">height = #{height},</if>
            <if test="status != null ">status = #{status},</if>
            <if test="userId != null  and userId != ''">user_id = #{userId},</if>
            <if test="deptId != null  and deptId != ''">dept_id = #{deptId},</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>
        </trim>
        where ad_id = #{adId}
    </update>
 
    <delete id="deleteAdById" parameterType="Long">
        delete from cms_ad where ad_id = #{adId}
    </delete>
 
    <delete id="deleteAdByIds" parameterType="String">
        delete from cms_ad where ad_id in
        <foreach item="adId" collection="array" open="(" separator=","
            close=")">
            #{adId}
        </foreach>
    </delete>
    <!--/*****************************************分割线****************************************************/ -->
    <resultMap type="AdMaterial" id="AdMaterialResult">
        <result property="id" column="id" />
        <result property="adId" column="ad_id" />
        <result property="link" column="link" />
        <result property="sort" column="sort" />
        <result property="hit" column="hit" />
        <result property="startTime" column="start_time" />
        <result property="endTime" column="end_time" />
        <result property="status" column="status" />
        <result property="useHisId" column="use_his_id" />
 
        <result property="materialId" column="material_id" />
        <result property="groupId" column="group_id" />
        <result property="groupName" column="group_name" />
        <result property="materialName" column="material_name" />
        <result property="materialType" column="material_type" />
        <result property="description" column="description" />
        <result property="materialSize" column="material_size" />
        <result property="savePath" column="save_path" />
        <result property="thumbnail" column="thumbnail" />
        <result property="auditState" column="audit_state" />
        <result property="auditReason" column="audit_reason" />
        <result property="useState" column="use_state" />
        <result property="width" column="width" />
        <result property="height" column="height" />
        <result property="uploaderId" column="uploader_id" />
        <result property="uploadTime" column="upload_time" />
        <result property="remark" column="remark" />
    </resultMap>
    <sql id="selectAdMaterialVo">
        select
        id,ad_id,material_id,link,sort,hit,start_time,end_time,status,use_his_id
        from cms_ad_material
    </sql>
 
    <select id="selectAdMaterialById" parameterType="Long"
        resultMap="AdMaterialResult">
        select
        a.id,a.ad_id,a.material_id,b.material_name,a.link,a.sort,a.hit,a.start_time,a.end_time,a.status,a.use_his_id
        from cms_ad_material a,cms_material b
        where a.id = #{id} and a.material_id=b.material_id
    </select>
 
    <select id="selectAdMaterialList" parameterType="AdMaterial"
        resultMap="AdMaterialResult">
        select
        b.id,b.ad_id,b.link,b.sort,b.hit,b.start_time,b.end_time,b.status,b.use_his_id,a.material_id,
        a.group_id, a.material_name, a.material_type, a.description,
        a.material_size, a.save_path, a.thumbnail, a.audit_state,
        a.audit_reason, a.use_state, a.width, a.height, a.uploader_id,
        a.upload_time, a.remark
        from cms_material a , cms_ad_material b
        where a.material_id=b.material_id
        and b.ad_id=#{adId} and
        a.material_id in
        (select material_id from cms_ad_material where ad_id=#{adId})
        <if test="materialName != null and materialName != ''">
            AND a.material_name like concat('%', #{materialName}, '%')
        </if>
        and a.audit_state=1
        order by b.sort asc
    </select>
 
 
    <insert id="insertAdMaterial" parameterType="AdMaterial"
        useGeneratedKeys="true" keyProperty="adId">
        insert into cms_ad_material
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="adId != null  and adId != ''">ad_id,</if>
            <if test="materialId != null  and materialId != ''">material_id,</if>
            <if test="link != null  and link != ''">link,</if>
            <if test="sort != null  and sort != ''">sort,</if>
            <if test="hit != null  and hit != ''">hit,</if>
            <if test="startTime != null ">start_time,</if>
            <if test="endTime != null ">end_time,</if>
            <if test="status != null ">status,</if>
            <if test="useHisId != null ">use_his_id,</if>
 
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="adId != null  and adId != ''">#{adId},</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>
            <if test="hit != null  and hit != ''">#{hit},</if>
            <if test="startTime != null ">#{startTime},</if>
            <if test="endTime != null ">#{endTime},</if>
            <if test="status != null ">#{status},</if>
            <if test="useHisId != null ">#{useHisId},</if>
        </trim>
    </insert>
 
    <update id="updateAdMaterial" parameterType="Ad">
        update cms_ad_material
        <trim prefix="SET" suffixOverrides=",">
            <if test="adId != null  and adId != ''">ad_id = #{adId},</if>
            <if test="materialId != null  and materialId != ''">material_id = #{materialId},</if>
            <if test="link != null  and link != ''">link = #{link},</if>
            <if test="sort != null  and sort != ''">sort = #{sort},</if>
            <if test="hit != null  and hit != ''">hit = #{hit},</if>
            <if test="startTime != null">start_time = #{startTime},</if>
            <if test="endTime != null ">end_time = #{endTime},</if>
            <if test="status != null ">status = #{status},</if>
            <if test="useHisId != null ">use_his_id = #{useHisId},</if>
        </trim>
        where id = #{id}
    </update>
 
    <delete id="deleteAdMaterialByIds" parameterType="String">
        delete from cms_ad_material where id in
        <foreach item="id" collection="array" open="(" separator=","
            close=")">
            #{id}
        </foreach>
    </delete>
 
 
    <sql id="selectMaterialVo">
        select a.material_id, a.group_id, a.material_name, a.material_type,
        a.description, a.material_size, a.save_path, a.thumbnail,
        a.audit_state, a.audit_reason, a.use_state, a.width, a.height,
        a.uploader_id, a.upload_time, a.remark
        from cms_material a
        inner join cms_material_group b on a.group_id=b.group_id
    </sql>
 
 
    <select id="selectAdUnMaterialList" parameterType="AdMaterial"
        resultMap="AdMaterialResult">
        <include refid="selectMaterialVo" />
        where a.material_id not in
        (select material_id from cms_ad_material where ad_id=#{adId})
        <if test="materialName != null and materialName != ''">
            AND a.material_name like concat('%', #{materialName}, '%')
        </if>
        and a.audit_state=1
    </select>
 
 
    <select id="selectAdMaterialByIds" parameterType="String"
        resultMap="AdMaterialResult">
        select * from cms_ad_material where id in
        <foreach item="id" collection="array" open="(" separator=","
            close=")">
            #{id}
        </foreach>
    </select>
</mapper>