<?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.chinaweal.aiccs.aiccs.annual.mapper.AnnualDissentInfoMapper">

    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="com.chinaweal.aiccs.aiccs.annual.entity.AnnualDissentInfo">
        <id column="uid" property="uid"/>
        <result column="pripid" property="pripid"/>
        <result column="proposer_name" property="proposerName"/>
        <result column="proposer_idnum" property="proposerIdnum"/>
        <result column="proposer_phone" property="proposerPhone"/>
        <result column="proposer_mail" property="proposerMail"/>
        <result column="proposer_address" property="proposerAddress"/>
        <result column="dissent_desc" property="dissentDesc"/>
        <result column="dissent_date" property="dissentDate"/>
        <result column="handle_status" property="handleStatus"/>
        <result column="final_feedback" property="finalFeedback"/>
        <result column="create_time" property="createTime"/>
        <result column="update_time" property="updateTime"/>
        <result column="updater_id" property="updaterId"/>
    </resultMap>
    <resultMap id="DetailMap" type="com.chinaweal.aiccs.aiccs.annual.entity.dto.AnnualDissentDetailDto">
        <id column="uid" property="uid"/>
        <result column="pripid" property="pripid"/>
        <result column="proposer_name" property="proposerName"/>
        <result column="proposer_idnum" property="proposerIdnum"/>
        <result column="proposer_phone" property="proposerPhone"/>
        <result column="proposer_mail" property="proposerMail"/>
        <result column="proposer_address" property="proposerAddress"/>
        <result column="dissent_desc" property="dissentDesc"/>
        <result column="dissent_date" property="dissentDate"/>
        <result column="handle_status" property="handleStatus"/>
        <result column="final_feedback" property="finalFeedback"/>
        <result column="create_time" property="createTime"/>
        <result column="update_time" property="updateTime"/>
        <result column="updater_id" property="updaterId"/>
        <result column="entname" property="entname"/>
        <result column="uniscid" property="uniscid"/>
        <result column="reg_no" property="regNo"/>
        <result column="regorg" property="regorg"/>
    </resultMap>

    <!-- 通用查询结果列 -->
    <sql id="Base_Column_List">
        uid, pripid, proposer_name, proposer_idnum, proposer_phone, proposer_mail, proposer_address, dissent_desc, dissent_date, handle_status, final_feedback, create_time, update_time, updater_id
    </sql>
    <sql id="Detail_Select">
        select adi.* , eb.ENTNAME as entname, eb.UNISCID as uniscid, eb.REGNO as reg_no, eb.regorg
        from annual_dissent_info adi left join e_baseinfo eb on adi.pripid = eb.PRIPID
    </sql>
    <select id="selectAnnualDissentDetailPage" resultMap="DetailMap">
        <include refid="Detail_Select"/>
        where true
        <if test="params != null">
            <if test="params.searchName != null and params.searchName != ''">
                and eb.ENTNAME like concat('%', #{params.searchName} ,'%')
            </if>
            <if test="params.uniscid != null and params.uniscid != ''">
                and eb.UNISCID = #{params.uniscid}
            </if>
            <if test="params.regno != null and params.regno != ''">
                and eb.REGNO = #{params.regno}
            </if>
            <if test="params.searchStatus != null and params.searchStatus != ''">
                and adi.handle_status = #{params.searchStatus}
            </if>
            <if test="params.dissentDateBegin != null and params.dissentDateBegin != ''">
                and adi.dissent_date <![CDATA[>=]]> DATE_FORMAT(#{params.dissentDateBegin}, '%Y-%m-%d')
            </if>
            <if test="params.dissentDateEnd != null and params.dissentDateEnd != ''">
                and adi.dissent_date <![CDATA[<=]]> DATE_FORMAT(#{params.dissentDateEnd}, '%Y-%m-%d')
            </if>
            <if test="params.searchRegister != null and params.searchRegister != ''">
                and eb.regorg = #{params.searchRegister}
            </if>
        </if>
        order by adi.dissent_date desc
    </select>
    <!--查询详情-->
    <select id="selectAnnualDissentDetailById" resultMap="DetailMap">
    <include refid="Detail_Select"/>
    where adi.uid = #{id}
    </select>

</mapper>
