InformMapper.xml
2.61 KB
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
<?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.project.demo.mapper.InformMapper">
<resultMap id="informMap" type="com.project.demo.domain.Inform">
<result column="id" property="id" />
<result column="information" property="information" />
<result column="user_id" property="userId" />
<result column="create_time" property="createTime" />
<result column="state" property="state" />
<result column="file_name" property="fileName" />
<result column="file_id" property="fileId" />
</resultMap>
<sql id="inform_column_list">
id,information,user_id,create_time,state,file_name,file_id
</sql>
<select id="search" resultMap="informMap" resultType="Map">
SELECT
<include refid="inform_column_list" />
FROM inform
where state is TRUE
</select>
<insert id="saveInform" parameterType="com.project.demo.domain.Inform">
insert into inform
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="information != null">
information,
</if>
<if test="userId != null">
user_id,
</if>
<if test="createTime != null">
create_time,
</if>
<if test="state != null">
state,
</if>
<if test="fileName != null">
file_name,
</if>
<if test="fileId != null">
file_id,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="information != null">
#{information},
</if>
<if test="userId != null">
#{userId},
</if>
<if test="createTime != null">
#{createTime},
</if>
<if test="state != null">
#{state},
</if>
<if test="fileName != null">
#{fileName},
</if>
<if test="fileId != null">
#{fileId},
</if>
</trim>
</insert>
<update id="updateInform" parameterType="com.project.demo.domain.Inform">
UPDATE inform
<set>
state = FALSE
</set>
WHERE
id = #{id}
</update>
<select id="findById" resultMap="informMap">
SELECT
<include refid="inform_column_list" />
FROM inform
where id = #{id}
</select>
</mapper>