地质所 沉降监测网建设项目
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
<?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.TagsMapper">
    
    <resultMap type="Tags" id="TagsResult">
        <result property="tagId"    column="tag_id"    />
        <result property="tagType"    column="tag_type"    />
        <result property="userId"    column="user_id"    />
        <result property="tagName"    column="tag_name"    />
        <result property="sort"    column="sort"    />
        <result property="status"    column="status"    />
        <result property="url"    column="url"    />
    </resultMap>
 
    <sql id="selectTagsVo">
        select tag_id, tag_type, user_id, tag_name, sort, status, url from cms_tags
    </sql>
 
 
    <select id="getTagByName" parameterType="Tags" resultMap="TagsResult">
        <include refid="selectTagsVo"/>
        where tag_type=#{type} and tag_name=#{name} limit 1
    </select>
 
    <select id="selectTagsList" parameterType="Tags" resultMap="TagsResult">
        <include refid="selectTagsVo"/>
        <where>  
            <if test="tagType != null  and tagType != ''"> and tag_type = #{tagType}</if>
            <if test="userId != null  and userId != ''"> and user_id = #{userId}</if>
            <if test="tagName != null  and tagName != ''"> and tag_name like concat('%', #{tagName}, '%')</if>
            <if test="sort != null "> and sort = #{sort}</if>
            <if test="status != null "> and status = #{status}</if>
            <if test="url != null  and url != ''"> and url = #{url}</if>
        </where>
        order by sort asc
    </select>
    <select id="selectTagsAll"  resultMap="TagsResult">
        <include refid="selectTagsVo"/>
         where  status=0
         and tag_type != 'p'
         order by sort asc
    </select>
 
    <select id="selectBlogTabs"  resultMap="TagsResult">
        <include refid="selectTagsVo"/>
         where tag_type='blogTab' and status=0
        order by sort asc
    </select>
 
    <select id="selectTagsById" parameterType="Long" resultMap="TagsResult">
        <include refid="selectTagsVo"/>
        where tag_id = #{tagId}
    </select>
        
    <insert id="insertTags" parameterType="Tags" useGeneratedKeys="true" keyProperty="tagId">
        insert into cms_tags
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="tagType != null  and tagType != ''">tag_type,</if>
            <if test="userId != null  and userId != ''">user_id,</if>
            <if test="tagName != null  and tagName != ''">tag_name,</if>
            <if test="sort != null ">sort,</if>
            <if test="status != null ">status,</if>
            <if test="url != null  and url != ''">url,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="tagType != null  and tagType != ''">#{tagType},</if>
            <if test="userId != null  and userId != ''">#{userId},</if>
            <if test="tagName != null  and tagName != ''">#{tagName},</if>
            <if test="sort != null ">#{sort},</if>
            <if test="status != null ">#{status},</if>
            <if test="url != null  and url != ''">#{url},</if>
         </trim>
    </insert>
 
    <update id="updateTags" parameterType="Tags">
        update cms_tags
        <trim prefix="SET" suffixOverrides=",">
            <if test="tagType != null  and tagType != ''">tag_type = #{tagType},</if>
            <if test="userId != null  and userId != ''">user_id = #{userId},</if>
            <if test="tagName != null  and tagName != ''">tag_name = #{tagName},</if>
            <if test="sort != null ">sort = #{sort},</if>
            <if test="status != null ">status = #{status},</if>
            <if test="url != null  and url != ''">url = #{url},</if>
        </trim>
        where tag_id = #{tagId}
    </update>
 
    <delete id="deleteTagsById" parameterType="Long">
        delete from cms_tags where tag_id = #{tagId}
    </delete>
 
    <delete id="deleteTagsByIds" parameterType="String">
        delete from cms_tags where tag_id in 
        <foreach item="tagId" collection="array" open="(" separator="," close=")">
            #{tagId}
        </foreach>
    </delete>
    
</mapper>