<?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.yunzhi.marketing.eContract.mapper.TaCompanyMapper">

    <select id="getCompanyAndContractInfo" resultType="com.yunzhi.marketing.eContract.entity.TaCompany">
        select *,a.contract_id From ta_company t
        left join ta_contract a on t.company_id = a.company_id and a.target_type = 'auth' and a.status = 1
        where t.company_id = #{companyId}
    </select>

    <select id="selectListByOrgId" resultType="com.yunzhi.marketing.eContract.entity.TaCompany">
        select t.* From ta_company t
        left join ta_company_org a on t.company_id = a.company_id
        where a.org_id = #{orgId}
        <if test="companyCode != null and companyCode!=''">
            and t.company_code like CONCAT('%', #{companyCode}, '%')
        </if>
        <if test="companyName != null and companyName!=''">
            and t.company_name like CONCAT('%', #{companyName}, '%')
        </if>
        and t.status = 4
        order by t.create_date desc
    </select>

</mapper>
