<?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.UserInfoMapper">

    <!-- 获取个人用户信息分页列表 -->
    <select id="getUserInfoPage" resultType="com.zsElectric.boot.business.model.vo.UserInfoVO">
        SELECT
        ui.id,
        ui.ec_id,
        ui.nick_name,
        fi.name AS firmName,
        ui.phone,
        ui.openid,
        ui.integral_num,
        ui.group_id,
        ui.create_time,
        ui.create_by,
        ui.update_time,
        ui.update_by,
        ui.is_deleted
        FROM
        c_user_info ui
        LEFT JOIN c_user_firm uf ON uf.user_id = ui.id
        LEFT JOIN c_firm_info fi ON fi.id = uf.firm_id
        <where>
            ui.is_deleted = 0
        </where>
    </select>
    <select id="getAppletUserInfo" resultType="com.zsElectric.boot.business.model.vo.applet.AppletUserInfoVO">
        SELECT
                ui.id,
                ui.ec_id,
                ui.nick_name,
                ui.phone,
                ui.openid,
                ui.integral_num,
                ui.group_id,
                ua.balance,
                uf.firm_id,
                uf.type AS firmUserType,
                fi.name AS firmName
        FROM
            c_user_info ui
        LEFT JOIN c_user_account ua ON ui.id = ua.user_id
        LEFT JOIN c_user_firm uf ON ui.id = uf.user_id
        LEFT JOIN c_firm_info fi ON uf.firm_id = fi.id
        WHERE
            ui.is_deleted = 0
            AND ui.id = #{userId}
    </select>

</mapper>
