<?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="org.springblade.manager.mapper.ContractInfoMapper">


    <!-- 通用查询映射结果 -->
    <resultMap id="contractInfoResultMap" type="org.springblade.manager.entity.ContractInfo">
        <result column="id" property="id"/>
        <result column="create_time" property="createTime"/>
        <result column="create_user" property="createUser"/>
        <result column="create_dept" property="createDept"/>
        <result column="update_user" property="updateUser"/>
        <result column="update_time" property="updateTime"/>
        <result column="status" property="status"/>
        <result column="is_deleted" property="isDeleted"/>
        <result column="contract_name" property="contractName"/>
        <result column="project_name" property="projectName" />
        <result column="contract_number" property="contractNumber"/>
        <result column="contractor_unit_name" property="contractorUnitName"/>
        <result column="supervision_unit_name" property="supervisionUnitName"/>
        <result column="contractor_join_time" property="contractorJoinTime"/>
        <result column="plan_start_time" property="planStartTime"/>
        <result column="plan_end_time" property="planEndTime"/>
        <result column="actual_start_time" property="actualStartTime"/>
        <result column="actual_end_time" property="actualEndTime"/>
        <result column="start_file_url" property="startFileUrl"/>
        <result column="contract_amount" property="contractAmount"/>
        <result column="contract_amount" property="contractAmount"/>
        <result column="project_place" property="projectPlace"/>
        <result column="start_station" property="startStation"/>
        <result column="end_station" property="endStation"/>
    </resultMap>
    <!-- 通用查询映射结果 -->
    <resultMap id="contractInfoResultMap1" type="org.springblade.manager.vo.ContractlnfoCountVO">
        <result column="contract_name" property="contractName"/>
        <result column="contract_counts" property="contractCounts"/>
    </resultMap>


    <select id="selectContractInfoPage" resultMap="contractInfoResultMap">
        select c.* ,p.project_name as project_name from t_pf_contract_info c INNER JOIN t_pf_project_info p on c.p_id=p.id where c.is_deleted = 0
    </select>

    <select id="selectContractInfoCount" resultMap="contractInfoResultMap1">
        select c.contract_name,count(*) as contract_counts from t_pf_contract_info c where c.is_deleted = 0  GROUP BY c.p_id
    </select>

    <select id="selectContractInfoPageByPid" resultMap="contractInfoResultMap" >
        select c.*,p.project_name as project_name  from t_pf_contract_info c INNER JOIN t_pf_project_info p on c.p_id=p.id where p.id = #{pid} and c.is_deleted = 0
    </select>

</mapper>
