<?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.github.zuihou.authority.dao.auth.UserMapper">

    <select id="findUserByRoleId" resultMap="BaseResultMap" parameterType="map">
        SELECT u.id as id, account, name, mobile, sex
        FROM c_auth_user u INNER JOIN c_auth_user_role ur on u.id = ur.user_id
        where ur.role_id = #{roleId, jdbcType=BIGINT}
        <if test="keyword != null and keyword != ''">
            and (u.account like #{keyword, typeHandler=fullLike} or u.`name` like #{keyword, typeHandler=fullLike})
        </if>
    </select>


    <update id="incrPasswordErrorNumById">
        update c_auth_user set password_error_num = password_error_num + 1, password_error_last_time = SYSDATE()
        where id = #{id, jdbcType=BIGINT}
    </update>
    <update id="resetPassErrorNum">
        update c_auth_user set password_error_num = 0, password_error_last_time = #{now, jdbcType=TIMESTAMP}, last_login_time = #{now, jdbcType=TIMESTAMP}
        where id = #{id, jdbcType=BIGINT}
    </update>
    <!--    <update id="updateLastLoginTime">-->
    <!--        update c_auth_user set last_login_time = #{now, jdbcType=TIMESTAMP}-->
    <!--        where id = #{id, jdbcType=BIGINT}-->
    <!--    </update>-->


    <select id="findPage" resultMap="BaseResultMap">
        SELECT
        <include refid="Base_Column_List"/>
        FROM c_auth_user s ${ew.customSqlSegment}
    </select>
</mapper>
