<?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.njzscloud.supervisory.user.mapper.SysUserAccountMapper">

    <select id="paging" resultType="com.njzscloud.supervisory.user.pojo.SysUserAccountEntity">
        SELECT id,
        user_id,
        username,
        email,
        phone,
        secret,
        wechat_openid,
        wechat_unionid,
        regdate,
        client_code,
        disabled,
        creator_id,
        modifier_id,
        create_time,
        modify_time,
        deleted
        FROM sys_user_account
        <if test="ew != null and ew.customSqlSegment != null and ew.customSqlSegment !=''">
            ${ew.customSqlSegment}
        </if>
    </select>

    <select id="selectUserByAccount" resultType="com.njzscloud.common.security.support.UserDetail">
        SELECT a.id account_id,
        a.user_id,
        a.secret,
        b.nickname,
        b.tenant_id,
        c.tenant_name,
        a.disabled
        FROM sys_user_account a
        INNER JOIN sys_user b ON a.user_id = b.id AND b.deleted = 0
        INNER JOIN sys_tenant c ON c.id = b.tenant_id AND c.deleted = 0
        WHERE a.deleted = 0
        AND (a.username = #{account}
        OR a.email = #{account}
        OR a.phone = #{account})
    </select>

</mapper>
