地质所 沉降监测网建设项目
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
<?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.ResourceMapper">
 
    <resultMap type="Resource" id="ResourceResult">
        <result property="id" column="id" />
        <result property="resourceRegion" column="resource_region" />
        <result property="title" column="title" />
        <result property="type" column="type" />
        <result property="description" column="description" />
        <result property="detail" column="detail" />
        <result property="size" column="size" />
        <result property="savePath" column="save_path" />
        <result property="coverImage" column="cover_image" />
        <result property="auditState" column="audit_state" />
        <result property="score" column="score" />
        <result property="downloadType" column="download_type" />
        <result property="favouriteCount" column="favourite_count" />
        <result property="downloadCount" column="download_count" />
        <result property="hit" column="hit" />
        <result property="upVote" column="up_vote" />
        <result property="free" column="free" />
        <result property="payType" column="pay_type" />
        <result property="cost" column="cost" />
        <result property="tagIds" column="tag_ids" />
        <result property="userId" column="user_id" />
        <result property="userName" column="user_name" />
        <result property="createTime" column="create_time" />
        <result property="updateTime" column="update_time" />
        <result property="status" column="status" />
        <result property="remark" column="remark" />
    </resultMap>
 
    <sql id="selectResourceVo">
        select id,resource_region, title, type, description, detail, size,
        save_path, cover_image, audit_state, score, download_type,
        favourite_count, download_count,hit, up_vote, free, pay_type, cost,
        tag_ids, user_id, user_name, create_time, update_time, status, remark
        from cms_resource
    </sql>
 
    <select id="selectResourceList" parameterType="Resource"
        resultMap="ResourceResult">
        <include refid="selectResourceVo" />
        <where>
            <if test="resourceRegion != null  and resourceRegion != ''"> and resource_region = #{resourceRegion}</if>
            <if test="title != null  and title != ''"> and title like concat('%', #{title}, '%')</if>
            <if test="type != null  and type != ''"> and type = #{type}</if>
            <if test="auditState != null  and auditState != ''"> and audit_state = #{auditState}</if>
            <if test="downloadType != null  and downloadType != ''"> and download_type = #{downloadType}</if>
            <if test="free != null "> and free = #{free}</if>
            <if test="status != null "> and status = #{status}</if>
        </where>
    </select>
 
    <select id="selectResourceById" parameterType="String"
        resultMap="ResourceResult">
        <include refid="selectResourceVo" />
        where id = #{id}
    </select>
 
    <insert id="insertResource" parameterType="Resource">
        insert into cms_resource
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null  and id != ''">id,</if>
            <if test="resourceRegion != null  and resourceRegion != ''">resource_region,</if>
            <if test="title != null  and title != ''">title,</if>
            <if test="type != null  and type != ''">type,</if>
            <if test="description != null  and description != ''">description,</if>
            <if test="detail != null  and detail != ''">detail,</if>
            <if test="size != null  and size != ''">size,</if>
            <if test="savePath != null  and savePath != ''">save_path,</if>
            <if test="coverImage != null  and coverImage != ''">cover_image,</if>
            <if test="auditState != null  and auditState != ''">audit_state,</if>
            <if test="score != null ">score,</if>
            <if test="downloadType != null  and downloadType != ''">download_type,</if>
            <if test="favouriteCount != null ">favourite_count,</if>
            <if test="downloadCount != null ">download_count,</if>
            <if test="hit != null ">hit,</if>
            <if test="upVote != null ">up_vote,</if>
            <if test="free != null ">free,</if>
            <if test="payType != null  and payType != ''">pay_type,</if>
            <if test="cost != null ">cost,</if>
            <if test="tagIds != null  and tagIds != ''">tag_ids,</if>
            <if test="userId != null  and userId != ''">user_id,</if>
            <if test="userName != null  and userName != ''">user_name,</if>
            <if test="createTime != null ">create_time,</if>
            <if test="updateTime != null ">update_time,</if>
            <if test="status != null ">status,</if>
            <if test="remark != null  and remark != ''">remark,</if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="id != null  and id != ''">#{id},</if>
            <if test="resourceRegion != null  and resourceRegion != ''">#{resourceRegion},</if>
            <if test="title != null  and title != ''">#{title},</if>
            <if test="type != null  and type != ''">#{type},</if>
            <if test="description != null  and description != ''">#{description},</if>
            <if test="detail != null  and detail != ''">#{detail},</if>
            <if test="size != null  and size != ''">#{size},</if>
            <if test="savePath != null  and savePath != ''">#{savePath},</if>
            <if test="coverImage != null  and coverImage != ''">#{coverImage},</if>
            <if test="auditState != null  and auditState != ''">#{auditState},</if>
            <if test="score != null ">#{score},</if>
            <if test="downloadType != null  and downloadType != ''">#{downloadType},</if>
            <if test="favouriteCount != null ">#{favouriteCount},</if>
            <if test="downloadCount != null ">#{downloadCount},</if>
            <if test="hit != null ">#{hit},</if>
            <if test="upVote != null ">#{upVote},</if>
            <if test="free != null ">#{free},</if>
            <if test="payType != null  and payType != ''">#{payType},</if>
            <if test="cost != null ">#{cost},</if>
            <if test="tagIds != null  and tagIds != ''">#{tagIds},</if>
            <if test="userId != null  and userId != ''">#{userId},</if>
            <if test="userName != null  and userName != ''">#{userName},</if>
            <if test="createTime != null ">#{createTime},</if>
            <if test="updateTime != null ">#{updateTime},</if>
            <if test="status != null ">#{status},</if>
            <if test="remark != null  and remark != ''">#{remark},</if>
        </trim>
    </insert>
 
    <update id="updateResource" parameterType="Resource">
        update cms_resource
        <trim prefix="SET" suffixOverrides=",">
            <if test="title != null  and title != ''">title = #{title},</if>
            <if test="resourceRegion != null  and resourceRegion != ''">resource_region = #{resourceRegion},</if>
            <if test="type != null  and type != ''">type = #{type},</if>
            <if test="description != null  and description != ''">description = #{description},</if>
            <if test="detail != null  and detail != ''">detail = #{detail},</if>
            <if test="size != null  and size != ''">size = #{size},</if>
            <if test="savePath != null  and savePath != ''">save_path = #{savePath},</if>
            <if test="coverImage != null  and coverImage != ''">cover_image = #{coverImage},</if>
            <if test="auditState != null  and auditState != ''">audit_state = #{auditState},</if>
            <if test="score != null ">score = #{score},</if>
            <if test="downloadType != null  and downloadType != ''">download_type = #{downloadType},</if>
            <if test="favouriteCount != null ">favourite_count = #{favouriteCount},</if>
            <if test="downloadCount != null ">download_count = #{downloadCount},</if>
            <if test="hit != null ">hit = #{hit},</if>
            <if test="upVote != null ">up_vote = #{upVote},</if>
            <if test="free != null ">free = #{free},</if>
            <if test="payType != null  and payType != ''">pay_type = #{payType},</if>
            <if test="cost != null ">cost = #{cost},</if>
            <if test="tagIds != null  and tagIds != ''">tag_ids = #{tagIds},</if>
            <if test="userId != null  and userId != ''">user_id = #{userId},</if>
            <if test="userName != null  and userName != ''">user_name = #{userName},</if>
            <if test="createTime != null ">create_time = #{createTime},</if>
            <if test="updateTime != null ">update_time = #{updateTime},</if>
            <if test="status != null ">status = #{status},</if>
            <if test="remark != null  and remark != ''">remark = #{remark},</if>
        </trim>
        where id = #{id}
    </update>
 
    <delete id="deleteResourceById" parameterType="String">
        delete from cms_resource where id = #{id}
    </delete>
 
    <delete id="deleteResourceByIds" parameterType="String">
        delete from cms_resource where id in
        <foreach item="id" collection="array" open="(" separator=","
            close=")">
            #{id}
        </foreach>
    </delete>
    <update id="upVote" parameterType="java.lang.String">
        update cms_resource set up_vote=up_vote+1 where id=#{id}
    </update>
    <update id="resourceLook" parameterType="java.lang.String">
        update cms_resource set hit=hit+1 where id=#{id}
    </update>
</mapper>