<?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.zhiqiyun.open.mapper.UserLoginAccountMapper">
    <resultMap id="BaseResultMap" type="com.zhiqiyun.open.models.UserLoginAccount">
        <id column="id" property="id" jdbcType="VARCHAR"/>
        <result column="uid" property="uid" jdbcType="BIGINT"/>
        <result column="login_account" property="loginAccount" jdbcType="VARCHAR"/>
        <result column="account_type" property="accountType" typeHandler="com.zhiqiyun.open.mybatis.typeHandler.IEnumTypeHandler"/>
    </resultMap>

    <sql id="Base_Column">
        `id`
        , `uid`, `login_account`, `account_type`
    </sql>
    <insert id="insertOrUpdate">
        replace
        into `user_login_account` (`id`, `uid`, `login_account`, `account_type`)
        values (
        #{id, jdbcType=BIGINT},
        #{uid, jdbcType=BIGINT},
        #{loginAccount, jdbcType=VARCHAR},
        #{accountType, typeHandler=com.zhiqiyun.open.mybatis.typeHandler.IEnumTypeHandler}
        )
    </insert>
    <delete id="deleteByUid">
        delete
        from `user_login_account`
        where uid = #{uid}
    </delete>
    <select id="findLoginAccount" resultMap="BaseResultMap">
        select
        <include refid="Base_Column"/>
        from `user_login_account`
        <where>
            `login_account`=#{loginAccount} and `account_type`=#{accountType,typeHandler=com.zhiqiyun.open.mybatis.typeHandler.IEnumTypeHandler}
        </where>
    </select>
    <select id="findLoginAccounts" resultMap="BaseResultMap">
        select
        <include refid="Base_Column"/>
        from `user_login_account`
        <where>
            `uid` = #{uid,jdbcType=BIGINT}
        </where>
    </select>
</mapper>