InBoxMapper.xml
2.85 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
<?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" />
</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
</sql>
<insert id="insertInbox">
INSERT INTO ${tableName} (uid,title,content,type,is_read,create_time,is_del, business_type)
values
(#{inBox.uid},#{inBox.title},#{inBox.content},#{inBox.type},#{inBox.isRead},
#{inBox.createTime},#{inBox.isDel},#{inBox.businessType})
</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}
</update>
<select id="selectTypeCount" resultMap="TypeCountInboxMap">
SELECT type, count(1) count FROM ${tableName} WHERE uid = #{uid}
and is_read = #{isRead} and is_del = #{isDel} GROUP BY type
</select>
<select id="selectInboxs" resultMap="BaseResultMap">
SELECT
<include refid="Base_Column_List"/>
FROM ${tableName} 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} 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>
</mapper>