<?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.yonge.cooleshow.bbs.dao.BbsLikeDao">
	<resultMap id="BaseResultMap" type="com.yonge.cooleshow.bbs.entity.BbsLike">
            <result column="id_" property="id" />
	        <result column="article_id_" property="articleId" />
	        <result column="like_user_id_" property="likeUserId" />
	        <result column="created_time_" property="createdTime" />
		</resultMap>  
    
    <!-- 表字段 -->
    <sql id="baseColumns">
         t.id_ as id
        , t.article_id_ as articleId
        , t.like_user_id_ as likeUserId
        , t.created_time_ as createdTime
        </sql> 
    
    <select id="detail" resultType="com.yonge.cooleshow.bbs.vo.BbsLikeVo">
        SELECT
            <include refid="baseColumns"/>
        FROM bbs_like t
        where t.id_ = #{id}
    </select>
    
    <select id="selectPage" resultType="com.yonge.cooleshow.bbs.vo.BbsLikeVo">
		SELECT         
        	<include refid="baseColumns" />
		FROM bbs_like t
        left join bbs_article ba on t.article_id_ = ba.id_
        <where>
            <if test="param.userId != null">
                t.like_user_id_ = #{param.userId}
            </if>
        </where>
        order by t.created_time_ desc
	</select>
</mapper>