<?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.zsElectric.boot.business.mapper.UserFirmMapper">

    <!-- 获取企业与用户关系分页列表 -->
    <select id="getUserFirmPage" resultType="com.zsElectric.boot.business.model.vo.UserFirmVO">
        SELECT
        a.id,
        a.user_id,
        a.phone,
        a.firm_id,
        b.name AS firmName,
        a.type,
        a.create_time,
        a.create_by,
        a.update_time,
        a.update_by,
        a.is_deleted
        FROM
        c_user_firm a
        LEFT JOIN c_firm_info b ON a.firm_id = b.id
        <where>
            a.is_deleted = 0 and b.is_deleted = 0
            <if test="queryParams.phone != null and queryParams.phone != ''">
                AND a.phone LIKE CONCAT('%', #{queryParams.phone}, '%')
            </if>
            <if test="queryParams.type != null">
                AND a.type = #{queryParams.type}
            </if>
        </where>
    </select>

</mapper>
