InBoxMapper.xml
4.03 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
90
91
92
93
94
95
<?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.yohoufo.dal.user.IInBoxDao">
<resultMap id="BaseResultMap" type="com.yohoufo.dal.user.model.InBox">
<id column="id" property="id" jdbcType="INTEGER"/>
<result column="uid" property="uid" jdbcType="INTEGER"/>
<result column="title" property="title" jdbcType="VARCHAR"/>
<result column="type" property="type" jdbcType="INTEGER"/>
<result column="is_read" property="isRead" jdbcType="CHAR"/>
<result column="create_time" property="createTime" jdbcType="INTEGER"/>
<result column="read_time" property="readTime" jdbcType="INTEGER"/>
<result column="is_del" property="isDel" jdbcType="CHAR"/>
<result column="content" property="content" jdbcType="LONGVARCHAR"/>
<result column="business_type" property="businessType" jdbcType="INTEGER" />
<result column="action" property="action" jdbcType="VARCHAR" />
</resultMap>
<resultMap id="TypeCountInboxMap" type="com.yohoufo.dal.user.model.TypeCountInbox">
<result column="type" property="type" jdbcType="INTEGER"/>
<result column="count" property="count" jdbcType="INTEGER"/>
</resultMap>
<sql id="Base_Column_List">
id, uid, title, type, is_read, create_time, read_time, is_del,content,business_type,action
</sql>
<insert id="insertInbox" useGeneratedKeys="true" keyProperty="inBox.id">
INSERT INTO ${tableName} (uid,title,content,type,is_read,create_time,is_del, business_type,action)
values
(#{inBox.uid},#{inBox.title},#{inBox.content},#{inBox.type},#{inBox.isRead},
#{inBox.createTime},#{inBox.isDel},#{inBox.businessType},#{inBox.action})
</insert>
<update id="updateReadedByUidAndType">
update ${tableName} set is_read='Y', read_time=#{readTime} where uid = ${uid} and is_read='N'
and is_del = 'N' and type = #{type}
<if test="time != 0">
and create_time >= #{time}
</if>
</update>
<select id="selectTypeCount" resultType="java.lang.Integer">
SELECT count(1) count FROM ${tableName} force index (`uid`) WHERE uid = #{uid}
and is_read = #{isRead} and is_del = #{isDel}
<if test="type != null">
AND type = #{type}
</if>
<if test="time != 0 and isRead ='N'">
and create_time >= #{time}
</if>
</select>
<select id="selectInboxs" resultMap="BaseResultMap">
SELECT
<include refid="Base_Column_List"/>
FROM ${tableName} force index(`read`) where uid = #{uid} and is_del='N'
<if test="type != null">
and type=#{type}
</if>
order by id desc
limit #{rowNo},#{limit}
</select>
<select id="selectTotalInboxs" resultType="java.lang.Integer">
select count(1) from ${tableName}
<if test="type != null">
force index(`read`)
</if>
where uid = #{uid} and is_del='N'
<if test="type != null">
and type=#{type}
</if>
</select>
<select id="selectNewUserGuideInBox" resultMap="BaseResultMap">
SELECT
<include refid="Base_Column_List"/>
FROM ${tableName} where uid = #{uid} and business_type = #{businessType}
limit 1
</select>
<insert id="insertBatch">
insert into ${tableName}
(uid,title,content,type,is_read,create_time,is_del, business_type,action)
values
<foreach collection="list" separator="," item="inBox">
(#{inBox.uid},#{inBox.title},#{inBox.content},#{inBox.type},#{inBox.isRead},
#{inBox.createTime},#{inBox.isDel},#{inBox.businessType},#{inBox.action})
</foreach>
</insert>
<select id="selectInboxsEx" resultMap="BaseResultMap">
SELECT
<include refid="Base_Column_List"/>
FROM ${tableName} where uid = #{uid} and is_del='N'
order by id desc
limit 1
</select>
</mapper>