InBoxMapper.xml 3.5 KB
<?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}
    </update>

    <select id="selectTypeCount" resultType="java.lang.Integer">
        SELECT count(1)  count FROM ${tableName} force index (`read`) WHERE uid = #{uid}
        and is_read = #{isRead} and is_del = #{isDel} AND type = #{type}
    </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} force index(`read`) 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>
</mapper>