<?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="cn.wisenergy.chnmuseum.party.mapper.BankBranchInfoMapper">

    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="BankBranchInfo">
        <id column="id" property="id" />
        <result column="name" property="name" />
        <result column="address" property="address" />
        <result column="is_deleted" property="isDeleted" />
        <result column="image_url" property="imageUrl" />
        <result column="phone_num" property="phoneNum" />
        <result column="width" property="width" />
        <result column="height" property="height" />
        <result column="sortorder" property="sortorder" />
        <result column="create_time" property="createTime" />
        <result column="update_time" property="updateTime" />
        <result column="status" property="status" />
        <result column="bank_qr_code" property="bankQrCode" />
        <result column="head_image" property="headImage" />
        <result column="reject_reason" property="rejectReason" />
        <result column="creator" property="creator" />
        <result column="modifier" property="modifier" />
        <result column="is_show" property="isShow" />
        <result column="reviewer" property="reviewer"/>
        <result column="lon" property="lon"/>
        <result column="lat" property="lat"/>
    </resultMap>

    <select id="selectListByName" resultMap="BaseResultMap">
        SELECT bbi.*,
            c.name AS creatorName,
            m.name AS modifierName
        FROM bank_branch_info bbi
        LEFT JOIN employee c ON bbi.creator = c.id
        LEFT JOIN employee m ON bbi.modifier = m.id
        <where>
            bbi.is_deleted = 0
            <if test=" name != null and name != '' ">
                AND bbi.name LIKE CONCAT('%','${name}','%')
            </if>
            <if test="currentBankId != null and currentBankId != '' and roleId == 3 ">
                AND bbi.id = #{currentBankId}
            </if>
            <if test=" query != null and query == 'map' ">
                AND bbi.id != '0'
            </if>
        </where>
        ORDER BY CONVERT (bbi.name USING gbk) COLLATE gbk_chinese_ci ASC
    </select>

</mapper>