<?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.hotent.project.dao.CostProjectTaskDao">

    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="com.hotent.project.model.CostProjectTask">
        <id column="id" property="id" />
    	<result column="year" property="year" />
    	<result column="project_id" property="projectId" />
        <result column="pid" property="pid" />
		<result column="project_name" property="projectName" />
		<result column="audited_unit_id" property="auditedUnitId" />
        <result column="audited_unit_name" property="auditedUnitName" />
        <result column="audit_period" property="auditPeriod"/>
        <result column="source_type" property="sourceType"/>
    	<result column="audit_type" property="auditType" />
        <result column="current_node" property="currentNode" />
		<result column="status" property="status" />
		<result column="order_num" property="orderNum" />
		<result column="is_deleted" property="isDeleted" />
		<result column="is_gd" property="isGd" />
		<result column="create_time" property="createTime" />
		<result column="create_by" property="createBy" />
		<result column="update_time" property="updateTime" />
		<result column="update_by" property="updateBy" />
    </resultMap>


    <select id="getCostProjectTaskList"
            resultMap="BaseResultMap">
        SELECT
        c.*
        FROM
        cost_project_task c,
        uc_user u
        WHERE
        c.create_by=u.ID_
        <if test=" year != null and  year != ''">
            and c.year=#{year}
        </if>

        <if test=" projectName != null and  projectName != ''">
            and c.project_name LIKE CONCAT('%', #{projectName}, '%')
        </if>

        <if test=" dataScope != null and  dataScope != ''">
            <if test=" dataScope ==1">
                and  u.CITY_CODE=#{ cityCode}
            </if>
            <if test=" dataScope ==2">
                and  u.COUNTY_CODE=#{ countyCode}
            </if>
        </if>
        ORDER BY c.create_time DESC
    </select>

</mapper>
