<?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.chinacreator.video.mapper.UserMsgDao" >
    <resultMap id="BaseResultMap" type="com.chinacreator.video.bean.UserMsgBean" >
        <result column="cpid" property="cpid" jdbcType="VARCHAR" />
        <result column="spid" property="spid" jdbcType="VARCHAR" />
        <result column="userid" property="userid" jdbcType="VARCHAR" />
        <result column="msg2" property="msg2" jdbcType="VARCHAR" />
        <result column="msg3" property="msg3" jdbcType="VARCHAR" />
        <result column="msg1" property="msg1" jdbcType="VARCHAR" />
        <result column="activeid" property="activeid" jdbcType="VARCHAR" />
        <result column="inserttime" property="inserttime" jdbcType="VARCHAR" />
    </resultMap>
    
    <sql id="Base_Column_List" >
        	 cpid,spid,userid,msg1,msg2,msg3,activeid,inserttime
    </sql>

    <select id="getMsg" parameterType="string"  resultMap="BaseResultMap" >
       SELECT 
       <include refid="Base_Column_List" />
           from (select cpid,spid,userid,msg1,msg2,msg3,activeid,to_char(inserttime, 'yyyy-mm-dd hh24:mi:ss') inserttime from TD_USERMSG_INFO a where a.userid=#{userid} and cpid=#{cpid} and spid=#{spid} and activeid=#{activeid} order by inserttime desc) where rownum =1
    </select>
    

</mapper>