<?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="org.springblade.modules.yjxt.base.servicePerson.mapper.YjxtServicePersonMapper">

    <!-- 通用查询映射结果 -->
    <resultMap id="servicePersonResultMap" type="org.springblade.modules.yjxt.base.servicePerson.entity.YjxtServicePersonEntity">

        <result column="user_id" property="userId"/>
        <result column="ad_code" property="adCode"/>

    </resultMap>

    <resultMap id="servicePersonVOResultMap" type="org.springblade.modules.yjxt.base.servicePerson.vo.YjxtServicePersonVO">

        <result column="user_id" property="userId"/>
        <result column="ad_code" property="adCode"/>
        <result column="real_name" property="userName"/>
        <result column="account" property="userAccount"/>

    </resultMap>

    <select id="selectPage" resultMap="servicePersonVOResultMap">

        SELECT
        p.*,
        u.real_name,u.account
        FROM
        yjxt_base_service_person p
        LEFT JOIN blade_user u ON u.id = p.user_id and u.is_deleted = 0
        WHERE
        p.is_deleted = 0
        <if test="dto.userName!=null">
            and u.real_name like concat(concat('%', #{dto.userName}), '%')
        </if>
        ORDER BY
        u.real_name
    </select>

</mapper>
