<?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.base.mapper.BdCountryMapper">

    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="com.hzs.common.domain.system.base.BdCountry">
        <id column="PK_ID" property="pkId"/>
        <result column="CODE" property="code"/>
        <result column="SHORT_NAME" property="shortName"/>
        <result column="CODE_THREE" property="codeThree"/>
        <result column="NAME" property="name"/>
        <result column="NATIONAL_FLAG1" property="nationalFlag1"/>
        <result column="NATIONAL_FLAG2" property="nationalFlag2"/>
        <result column="TIME_ZONE" property="timeZone"/>
        <result column="ENABLE_STATE" property="enableState"/>
        <result column="NUMBER_PLACES" property="numberPlaces"/>
        <result column="PK_CREATOR" property="pkCreator"/>
        <result column="CREATION_TIME" property="creationTime"/>
        <result column="PK_MODIFIED" property="pkModified"/>
        <result column="MODIFIED_TIME" property="modifiedTime"/>
        <result column="DEL_FLAG" property="delFlag"/>
        <result column="LANGUAGES" property="languages"/>
        <result column="EFFECTIVE_DATE" property="effectiveDate"/>
        <result column="IMG" property="img"/>
        <result column="PK_TRANSACTION" property="pkTransaction"/>
    </resultMap>

    <!-- 根据管理员ID查询国家列表 -->
    <select id="queryListByUserId" resultMap="BaseResultMap">
        select bc.pk_id, bc.short_name
        from sys_user_country suc
                 left join bd_country bc
                           on bc.pk_id = suc.pk_country
                               and bc.del_flag = 0
        where suc.user_id = #{userId}
        order by bc.creation_time
    </select>

</mapper>
