<?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.m2pool.pool.mapper.GoogleAuthMapper">
    <update id="bingGoogleAuthenticator">
        update sys_user
        set
            google_auth = #{info.secret},
            google_status = #{info.status},
            update_time = sysdate()
        where user_name = #{info.email}
    </update>

    <select id="checkIfBindByEmail" resultType="java.lang.Boolean">
        select COUNT(google_auth) from sys_user where email = #{email} and google_status=1
    </select>

    <select id="getGoogleInfoByEmail" resultType="com.m2pool.pool.entity.GoogleInfo">
        select
            email,
            google_auth secret,
            google_status status
        from
            sys_user
        where
            email = #{email}
        limit 1
    </select>

    <select id="checkSecretIfExist" resultType="java.lang.Boolean">
        select COUNT(1) from sys_user where google_auth = #{secret}
    </select>

    <select id="getUserInfoByEmail" resultType="com.m2pool.pool.entity.UserGoogleAuthInfo">
        select
            email,
            password pwd,
            google_auth secret,
            google_status status
        from
            sys_user
        where
            email = #{email}
        limit 1
    </select>

    <update id="closeGoogleAuthenticator">
        update sys_user
        set
            google_auth = '',
            google_status = 0,
            update_time = sysdate()
        where user_name = #{info.email}
    </update>

</mapper>


