<?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.districtReport.RdDistrictPrincipalMapper">
    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="cn.com.countrygarden.bi.main.model.districtReport.RdDistrictPrincipal">
                                    <id column="id" property="id" />
                                                <result column="region_code" property="regionCode" />
                                                <result column="region_name" property="regionName" />
                                                <result column="district_code" property="districtCode" />
                                                <result column="principal_code" property="principalCode" />
                                                <result column="principal_login" property="principalLogin" />
                                                <result column="principal_name" property="principalName" />
                                                <result column="authorization_time" property="authorizationTime" />
                                                <result column="authorization_name" property="authorizationName" />
                                                <result column="ENABLE" property="enable" />
                                                <result column="create_time" property="createTime" />
                                                <result column="create_by" property="createBy" />
                                                <result column="create_name" property="createName" />
                                                <result column="update_time" property="updateTime" />
                                                <result column="update_by" property="updateBy" />
       </resultMap>

    <select id="rdDistrictPList" resultMap="BaseResultMap">
           SELECT DISTINCT `id`,`region_code`,`region_name`,`district_code`,
       `principal_code`,`principal_name`,`authorization_time`,`authorization_name`,
        `create_time`,`create_by`,`create_name`
       FROM rd_district_principal
       WHERE `ENABLE`=1 and principal_code=#{principalCode}
    </select>

    <update id="delUpdate">
        UPDATE rd_district_principal SET
           `ENABLE` = 0,
           update_time = #{rdDistrictPrincipal.updateTime},
            update_by = #{rdDistrictPrincipal.updateBy}
           WHERE id =#{rdDistrictPrincipal.id};
    </update>

    <update id="delUpdatePr">
        UPDATE rd_district_principal SET
           `ENABLE` = 0,
           update_time = #{rdDistrictPrincipal.updateTime},
            update_by = #{rdDistrictPrincipal.updateBy}
           WHERE district_code =#{rdDistrictPrincipal.districtCode};
    </update>

</mapper>