<?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="cn.iocoder.mall.user.dao.OAuth2RefreshTokenMapper">

    <insert id="insert" parameterType="OAuth2RefreshTokenDO">
        INSERT INTO oauth2_refresh_token (
          id, user_id, valid, expires_time, create_time
        ) VALUES (
          #{id}, #{userId}, #{valid}, #{expiresTime}, #{createTime}
        )
    </insert>

    <update id="updateToInvalidByUserId" parameterType="Integer">
        UPDATE oauth2_refresh_token
        SET valid = 0
        WHERE user_id = #{userId}
        AND valid = 1
    </update>

</mapper>