<?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.hzs.system.sys.mapper.SysCorpMapper">

    <!-- 通用查询映射结果 -->
    <resultMap id="SysCorp" type="com.hzs.common.domain.system.sys.ext.SysCorpExt">
        <id column="PK_ID" property="pkId" />
        <result column="CREATION_TIME" property="creationTime" />
        <result column="MODIFIED_TIME" property="modifiedTime" />
        <result column="DEL_FLAG" property="delFlag" />
        <result column="PK_COUNTRY" property="pkCountry" />
        <result column="PK_CREATOR" property="pkCreator" />
        <result column="PK_MODIFIED" property="pkModified" />
        <result column="PK_FATHER_ORG" property="pkFatherOrg" />
        <result column="CORP_NAME" property="corpName" />
        <result column="SHORT_NAME" property="shortName" />
        <result column="PRINCIPAL" property="principal" />
        <result column="PHONE" property="phone" />
        <result column="ENABLE_STATE" property="enableState" />
        <result column="father_corp_name" property="fatherCorpName" />
    </resultMap>
    <select id="querySysCorpByCondition" resultType="com.hzs.common.domain.system.sys.ext.SysCorpExt">
        select bc.*,bf.corp_name father_corp_name from sys_corp bc
        left join sys_corp bf
        on bc.pk_father_org=bf.pk_id and bf.del_flag=0
        where bc.del_flag=0 and bc.pk_country=#{pkCountry}
        and bc.enable_state = 0
        <if test="corpName != null and corpName != ''">
            and bc.corp_name = #{corpName}
        </if>
        <if test="shortName != null and shortName != ''">
            and bc.short_name = #{shortName}
        </if>
        <if test="principal != null and principal != ''">
            and bc.principal = #{principal}
        </if>
        <if test="phone != null and phone != ''">
            and bc.phone = #{phone}
        </if>
    </select>

</mapper>
