<?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.WcxReviewOtherMapper">
    <resultMap id="BaseReviewOtherDtoMap" type="cn.com.countrygarden.bi.main.dto.wcx.WcxReviewOtherDto">
        <id property="reviewOtherId"            column="review_other_id"/>
        <result property="reviewId"             column="review_id"/>
        <result property="reviewContent"        column="review_content"/>
        <result property="reviewUserId"         column="review_user_id"/>
        <result property="reviewUserName"       column="review_user_name"/>
        <result property="reviewInnovationId"   column="review_innovation_id"/>
        <result property="reviewCreateDate"     column="review_create_date"/>
        <result property="reviewStatus"         column="review_status"/>
        <result property="reportContent"        column="report_content"/>
        <result property="reportNumber"         column="report_number"/>
        <result property="reportBy"             column="report_by"/>
        <result property="reportByName"         column="report_by_name"/>
        <result property="createDate"           column="create_date"/>
        <result property="createBy"             column="create_by"/>
        <result property="createByName"         column="create_by_name"/>
        <result property="lastUpdateDate"       column="last_update_date"/>
        <result property="lastUpdateBy"         column="last_update_by"/>
        <result property="lastUpdateByName"     column="last_update_by_name"/>
        <result property="isDelete"             column="is_delete"/>
        <result property="status"               column="status"/>
        <result property="version"              column="version"/>
    </resultMap>

    <resultMap id="BaseReviewOtherMap" type="cn.com.countrygarden.bi.main.model.wcx.WcxReviewOther">
        <id property="reviewOtherId"            column="review_other_id"/>
        <result property="reviewId"             column="review_id"/>
        <result property="reviewContent"        column="review_content"/>
        <result property="reviewUserId"         column="review_user_id"/>
        <result property="reviewUserName"       column="review_user_name"/>
        <result property="reviewInnovationId"   column="review_innovation_id"/>
        <result property="reviewCreateDate"     column="review_create_date"/>
        <result property="reviewStatus"         column="review_status"/>
        <result property="reportContent"        column="report_content"/>
        <result property="reportNumber"         column="report_number"/>
        <result property="reportBy"             column="report_by"/>
        <result property="reportByName"         column="report_by_name"/>
        <result property="createDate"           column="create_date"/>
        <result property="createBy"             column="create_by"/>
        <result property="createByName"         column="create_by_name"/>
        <result property="lastUpdateDate"       column="last_update_date"/>
        <result property="lastUpdateBy"         column="last_update_by"/>
        <result property="lastUpdateByName"     column="last_update_by_name"/>
        <result property="isDelete"             column="is_delete"/>
        <result property="status"               column="status"/>
        <result property="version"              column="version"/>
    </resultMap>

    <select id="selectPageData" resultMap="BaseReviewOtherDtoMap">
      SELECT
        r.review_other_id,
        r.review_id,
        r.review_content,
        r.review_user_id,
        r.review_user_name,
        r.review_innovation_id,
        r.review_create_date,
        r.review_status,
        r.report_content,
        r.report_number,
        r.report_by,
        r.report_by_name,
        r.create_date,
        r.create_by,
        r.create_by_name,
        r.last_update_date,
        r.last_update_by,
        r.last_update_by_name,
        r.is_delete,
        r.status,
        r.version
      FROM wcx_review_other r
      WHERE
      <include refid="BaseSelectPageList"/>
      ORDER BY r.status desc, r.create_date desc, r.review_other_id
      limit #{pageOffset}, #{pageSize}
    </select>

    <select id="selectPageCount" resultType="long">
      SELECT count(r.review_other_id)
      FROM wcx_review_other r
      WHERE
        <include refid="BaseSelectPageList"/>
    </select>

    <sql id="BaseSelectPageList">
        r.status = #{status}
    </sql>

    <select id="findFirstByPrimaryKey" resultMap="BaseReviewOtherDtoMap">
      SELECT
        r.review_other_id,
        r.review_id,
        r.review_content,
        r.review_user_id,
        r.review_user_name,
        r.review_innovation_id,
        r.review_create_date,
        r.review_status,
        r.report_content,
        r.report_number,
        r.report_by,
        r.report_by_name,
        r.create_date,
        r.create_by,
        r.create_by_name,
        r.last_update_date,
        r.last_update_by,
        r.last_update_by_name,
        r.is_delete,
        r.status,
        r.version
      FROM wcx_review_other r
      WHERE r.review_other_id = #{reviewOtherId}
    </select>

    <update id="updateStatus">
        UPDATE wcx_review_other SET is_delete = #{isDelete}, status = #{status}  WHERE review_other_id = #{reviewOtherId}
    </update>

    <update id="updateAudit">
        UPDATE wcx_review_other SET last_update_by = #{lastUpdateBy}, last_update_by_name = #{lastUpdateByName}  WHERE review_other_id = #{reviewOtherId}
    </update>
</mapper>