<?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.RdDistrictProjectMpMapper">
    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="cn.com.countrygarden.bi.main.model.districtReport.RdDistrictProjectMp">
                                    <id column="id" property="id" />
                                                <result column="district_code" property="districtCode" />
                                                <result column="project_code" property="projectCode" />
                                                <result column="project_name" property="projectName" />
                                                <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" />
                                                <result column="update_name" property="updateName" />
                        </resultMap>
     <delete id="deletePoj">
            DELETE FROM rd_district_project_mp WHERE district_code= #{districtCode};
     </delete>

    <update id="deleupda">
          UPDATE rd_district_project_mp SET ENABLE = 0,update_time=NOW(),update_by=#{updateBy},update_name=#{updateName}
           WHERE district_code = #{districtCode};
    </update>

    <select id="listProject" resultType="cn.com.countrygarden.bi.main.model.districtReport.RdDistrictProjectMp">
             SELECT id as id,district_code as districtCode,project_code as projectCode,project_name	as projectName
	          FROM rd_district_project_mp
	          <where>
                  <if test="commIdString!=null and commIdString.size()!=0">
                  and project_code in
                  <foreach collection="commIdString" item="commIdString" index="index" open="(" close=")" separator=",">
                      #{commIdString}
                  </foreach>
              </if>
                    <if test="districtCode!=null and districtCode!=''">
                         and district_code=#{districtCode}
                    </if>
                and ENABLE=1
              </where>
    </select>

    <select id="checkMp" resultType="cn.com.countrygarden.bi.main.model.districtReport.RdDistrictProjectMp">
        SELECT DISTINCT project_code as projectCode,project_name as projectName
	          FROM rd_district_project_mp
        <where>
            and ENABLE=1
        </where>
    </select>



</mapper>