<?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.UserPasswordMapper">
    <resultMap id="BaseResultMap" type="com.zhiqiyun.open.models.UserPassword">
        <id column="id" property="id" jdbcType="BIGINT"/>
        <result column="uid" property="uid" jdbcType="BIGINT"/>
        <result column="passwd" property="passwd" jdbcType="VARCHAR"/>
        <result column="salt" property="salt" jdbcType="VARCHAR"/>
        <result column="password_type" property="passwordType" typeHandler="com.zhiqiyun.open.mybatis.typeHandler.IEnumTypeHandler"/>
    </resultMap>

    <sql id="Base_Column">
        `id`
        , `uid`, `passwd`, `salt`, `password_type`
    </sql>

    <select id="findPassword" parameterType="java.lang.Object" resultMap="BaseResultMap">
        select
        <include refid="Base_Column"/>
        from `user_password`
        <where>
            and uid = #{uid, jdbcType=BIGINT}
            and `password_type`=#{passwordType, typeHandler=com.zhiqiyun.open.mybatis.typeHandler.IEnumTypeHandler}
        </where>
    </select>
    <insert id="insertOrUpdatePassword" parameterType="com.zhiqiyun.open.models.UserPassword">
        replace
        into `user_password` (`id`, `uid`, `passwd`, `salt`, `password_type`)
        values (
        #{id},
        #{uid},
        #{passwd},
        #{salt},
        #{passwordType.value}
        )
    </insert>
</mapper>