<?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.daqing.financial.hrauth.dao.UserLoginDao">
    <!-- 可根据自己的需求,是否要使用 -->
    <resultMap type="com.daqing.framework.domain.hrms.UserEntity" id="userMap">
        <result property="id" column="id"/>
        <result property="account" column="account"/>
        <result property="phoneAccount" column="phone_account"/>
        <result property="password" column="password"/>
        <result property="loginNum" column="login_num"/>
        <result property="createTime" column="create_time"/>
        <result property="motifyTime" column="motify_time"/>
    </resultMap>
    <update id="updatePasswordByPhoneAccount">
        update hrms_user set password = #{password} where phone_account = #{phoneAccount}
    </update>

    <select id="getUser" parameterType="string" resultType="com.daqing.framework.domain.hrms.UserEntity">
        SELECT account,password FROM hrms_user WHERE account = #{account}
    </select>
    <select id="selectCount" resultType="java.lang.Integer">
        select count(1) from hrms_user where phone_account = #{phoneAccount}
    </select>

    <select id="login" parameterType="com.daqing.framework.domain.hrms.request.LoginRequest" resultType="com.daqing.framework.domain.hrms.UserEntity">
        select id,account,phone_account,password,login_num from hrms_user
        where del_or_not = 0 and status = 0
        <if test="phone != null and phone != '' ">
            and phone_account = #{phone}
        </if>
        <if test="wechatId != null and wechatId != '' ">
            and wechat_id = #{wechatId}
        </if>

    </select>
    <select id="selectByPhoneAccount" resultType="com.daqing.framework.domain.hrms.UserEntity">
        SELECT id,account FROM hrms_user WHERE phone_account = #{phoneAccount}
    </select>

</mapper>