<?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.artfess.gyl.supplierApply.dao.BizStrategicAgreementDao">

    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="com.artfess.gyl.supplierApply.model.BizStrategicAgreement">
        <id column="ID_" property="id" />
        <result column="ENTERPRISE_ID_" property="enterpriseId" />
        <result column="ENTERPRISE_CODE_" property="enterpriseCode" />
        <result column="ENTERPRISE_SIGNER_NAME_" property="enterpriseSignerName" />
        <result column="ENTERPRISE_SIGNER_PHONE_" property="enterpriseSignerPhone" />
        <result column="SUPPLIER_ID_" property="supplierId" />
        <result column="SUPPLIER_CODE_" property="supplierCode" />
        <result column="SUPPLIER_SIGNER_NAME_" property="supplierSignerName" />
        <result column="SUPPLIER_SIGNER_PHONE_" property="supplierSignerPhone" />
        <result column="CONTRACT_SIGN_STATUS_" property="contractSignStatus" />
        <result column="CONTRACT_SIGN_ID_" property="contractSignId" />
        <result column="CONTRACT_SIGN_DATE_" property="contractSignDate" />
        <result column="CONTRACT_SIGN_DETAILS_" property="contractSignDetails" />
        <result column="CONTRACT_BEGINNING_TIME_" property="contractBeginningTime" />
        <result column="CONTRACT_ENDING_TIME_" property="contractEndingTime" />
        <result column="IS_DELE_" property="isDele" />
        <result column="CREATE_BY_" property="createBy" />
        <result column="CREATE_NAME_" property="createName" />
        <result column="CREATE_ORG_ID_" property="createOrgId" />
        <result column="CREATE_ORG_NAME_" property="createOrgName" />
        <result column="CREATE_DEPT_ID_" property="createDeptId" />
        <result column="CREATE_DEPT_NAME_" property="createDeptName" />
        <result column="CREATE_TIME_" property="createTime" />
        <result column="UPDATE_BY_" property="updateBy" />
        <result column="UPDATE_NAME_" property="updateName" />
        <result column="UPDATE_ORG_ID_" property="updateOrgId" />
        <result column="UPDATE_ORG_NAME_" property="updateOrgName" />
        <result column="UPDATE_DEPT_ID_" property="updateDeptId" />
        <result column="UPDATE_DEPT_NAME_" property="updateDeptName" />
        <result column="UPDATE_TIME_" property="updateTime" />
        <result column="LAST_TIME_" property="lastTime" />
        <result column="VERSION_" property="version" />
        <result column="TENANT_ID_" property="tenantId" />
    </resultMap>

    <resultMap id="JoinResultMap" type="com.artfess.gyl.supplierApply.model.BizStrategicAgreement" extends="BaseResultMap">
        <result column="enterpriseName" property="enterpriseName" />
        <result column="supplierName" property="supplierName" />
    </resultMap>

    <!-- 通用查询结果列 -->
    <sql id="Base_Column_List">
        ID_, ENTERPRISE_ID_, ENTERPRISE_CODE_, ENTERPRISE_SIGNER_NAME_, ENTERPRISE_SIGNER_PHONE_, SUPPLIER_ID_, SUPPLIER_CODE_, SUPPLIER_SIGNER_NAME_, SUPPLIER_SIGNER_PHONE_, CONTRACT_SIGN_STATUS_, CONTRACT_SIGN_ID_, CONTRACT_SIGN_DATE_, CONTRACT_SIGN_DETAILS_, CONTRACT_BEGINNING_TIME_, CONTRACT_ENDING_TIME_, IS_DELE_, CREATE_BY_, CREATE_NAME_, CREATE_ORG_ID_, CREATE_ORG_NAME_, CREATE_DEPT_ID_, CREATE_DEPT_NAME_, CREATE_TIME_, UPDATE_BY_, UPDATE_NAME_, UPDATE_ORG_ID_, UPDATE_ORG_NAME_, UPDATE_DEPT_ID_, UPDATE_DEPT_NAME_, UPDATE_TIME_, LAST_TIME_, VERSION_, TENANT_ID_
    </sql>

    <select id="queryJoinPage" resultMap="JoinResultMap">
        SELECT a.*,
               b.ENTERPRISE_NAME_ AS enterpriseName,
               b.SUPPLIER_NAME_ AS supplierName
        FROM biz_strategic_agreement a
        LEFT JOIN biz_supplier_enterprise b
          ON a.ENTERPRISE_ID_ = b.ENTERPRISE_ID_
         AND a.SUPPLIER_ID_ = b.SUPPLIER_ID_
        <if test="ew.customSqlSegment!=null">
            ${ew.customSqlSegment}
        </if>
    </select>

    <select id="getDetailById" resultMap="JoinResultMap">
        SELECT a.*,
               b.ENTERPRISE_NAME_ AS enterpriseName,
               b.SUPPLIER_NAME_ AS supplierName
        FROM biz_strategic_agreement a
        LEFT JOIN biz_supplier_enterprise b
          ON a.ENTERPRISE_ID_ = b.ENTERPRISE_ID_
         AND a.SUPPLIER_ID_ = b.SUPPLIER_ID_
        WHERE a.ID_ = #{id}
    </select>

</mapper>
