<?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="cn.com.countrygarden.bi.main.dao.wcx.WcxFeedbackMapper">
    <resultMap id="BaseFeedbackDtoMap" type="cn.com.countrygarden.bi.main.dto.wcx.WcxFeedbackDto">
            <id column="feedback_id"      property="feedbackId"/>
        <result column="feedback_content" property="feedbackContent"/>
        <result column="user_id"          property="userId"/>
        <result column="status"          property="status"/>
        <result column="create_date"      property="createDate"/>
        <result column="employee_name"    property="createByName"/>
    </resultMap>

    <select id="selectPageData" resultMap="BaseFeedbackDtoMap">
      SELECT
          f.feedback_id,
          f.feedback_content,
          f.user_id,
          f.status,
          f.create_date,
          u.employee_name
      FROM wcx_feedback f
      LEFT JOIN wcx_user u on u.user_id = f.user_id
      WHERE
      <include refid="BaseSelectPageList"/>
      order by f.create_date desc, f.feedback_id
      limit #{pageOffset}, #{pageSize}
    </select>

    <select id="selectPageCount" resultType="long">
      SELECT count(f.feedback_id)
      FROM wcx_feedback f
      WHERE
        <include refid="BaseSelectPageList"/>
    </select>

    <sql id="BaseSelectPageList">
        f.create_date <![CDATA[>=]]> #{startDateStr} and f.create_date <![CDATA[<=]]> #{endDateStr}
    </sql>
</mapper>