<?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.BbsAuthRecordDao">
    <select id="selectPage" resultType="com.yonge.cooleshow.bbs.vo.BbsAuthRecordVo">
        SELECT
        a.id_ AS articleId,
        a.title_ AS title,
        a.user_id_ AS userId,
        u.username_ AS userName,
        u.real_name_ AS realName,
        u.phone_ AS phone,
        a.label_id_ AS labelId,
        l.label_name_ AS labelName,
        a.reply_flag_ AS replyFlag,
        a.created_time_ AS articleCreatedTime,
        r.audit_state_ AS auditState,
        r.reason_ AS reason,
        r.create_time_ AS createdTime,
        r.update_time_ AS updatedTime
        FROM bbs_article a
        LEFT JOIN sys_user u ON a.user_id_ = u.id_
        LEFT JOIN bbs_auth_record r ON a.id_=r.article_id_
        LEFT JOIN bbs_config_label l ON a.label_id_ = l.id_
        WHERE a.status_ IN ('DOING','PASS','REJECT')
        <if test="null != param.search and '' != param.search">
            AND (
            u.username_ LIKE CONCAT('%', #{param.search}, '%') OR
            u.phone_ LIKE CONCAT('%', #{param.search}, '%') OR
            a.title_ LIKE CONCAT('%', #{param.search}, '%')
            )
        </if>
        <if test="param.labelId !=null">
            AND a.label_id_ = #{param.labelId}
        </if>
        <if test="param.auditState !=null">
            AND r.audit_state_ = #{param.auditState}
        </if>
        <if test="param.delFlag !=null">
            AND a.del_flag_ = #{param.delFlag}
        </if>
        <if test="param.startTime !=null">
            <![CDATA[AND a.created_time_ >= #{param.startTime} ]]>
        </if>
        <if test="param.endTime !=null">
            <![CDATA[AND a.created_time_ <= #{param.endTime} ]]>
        </if>
    </select>
</mapper>