地质所 沉降监测网建设项目
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
<?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.TemplateMapper">
    
    <resultMap type="Template" id="TemplateResult">
        <result property="templateId"    column="template_id"    />
        <result property="templateCode"    column="template_code"    />
        <result property="templateType"    column="template_type"    />
        <result property="templateName"    column="template_name"    />
        <result property="templateContent"    column="template_content"    />
    </resultMap>
 
    <sql id="selectTemplateVo">
        select template_id, template_code, template_type, template_name, template_content from cms_template
    </sql>
 
    <select id="selectTemplateList" parameterType="Template" resultMap="TemplateResult">
        <include refid="selectTemplateVo"/>
        <where>  
            <if test="templateCode != null  and templateCode != ''"> and template_code = #{templateCode}</if>
            <if test="templateType != null  and templateType != ''"> and template_type = #{templateType}</if>
            <if test="templateName != null  and templateName != ''"> and template_name like concat('%', #{templateName}, '%')</if>
            <if test="templateContent != null  and templateContent != ''"> and template_content = #{templateContent}</if>
        </where>
    </select>
    
    <select id="selectTemplateById" parameterType="Long" resultMap="TemplateResult">
        <include refid="selectTemplateVo"/>
        where template_id = #{templateId}
    </select>
        
    <insert id="insertTemplate" parameterType="Template" useGeneratedKeys="true" keyProperty="templateId">
        insert into cms_template
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="templateCode != null  and templateCode != ''">template_code,</if>
            <if test="templateType != null  and templateType != ''">template_type,</if>
            <if test="templateName != null  and templateName != ''">template_name,</if>
            <if test="templateContent != null  and templateContent != ''">template_content,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="templateCode != null  and templateCode != ''">#{templateCode},</if>
            <if test="templateType != null  and templateType != ''">#{templateType},</if>
            <if test="templateName != null  and templateName != ''">#{templateName},</if>
            <if test="templateContent != null  and templateContent != ''">#{templateContent},</if>
         </trim>
    </insert>
 
    <update id="updateTemplate" parameterType="Template">
        update cms_template
        <trim prefix="SET" suffixOverrides=",">
            <if test="templateCode != null  and templateCode != ''">template_code = #{templateCode},</if>
            <if test="templateType != null  and templateType != ''">template_type = #{templateType},</if>
            <if test="templateName != null  and templateName != ''">template_name = #{templateName},</if>
            <if test="templateContent != null  and templateContent != ''">template_content = #{templateContent},</if>
        </trim>
        where template_id = #{templateId}
    </update>
 
    <delete id="deleteTemplateById" parameterType="Long">
        delete from cms_template where template_id = #{templateId}
    </delete>
 
    <delete id="deleteTemplateByIds" parameterType="String">
        delete from cms_template where template_id in 
        <foreach item="templateId" collection="array" open="(" separator="," close=")">
            #{templateId}
        </foreach>
    </delete>
    
</mapper>