<?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.bofeng.dao.UserMapper">

    <update id="updateLoginCount">
      update tb_user set
        login_count=login_count+1,
        last_login_time=CURRENT_TIMESTAMP
      where
        user_id=#{user_id}
    </update>

    <select id="selectByLoginName" resultType="com.bofeng.entity.User">
        select * from tb_user where login_name=#{login_name}
    </select>

    <select id="selectVersionById" resultType="java.lang.String">
        select version from tb_user where user_id=#{user_id}
    </select>

    <select id="selectAll" resultType="com.bofeng.entity.User">
        select a.*, b.place_name as placeName from tb_user a left join tb_place b on (a.place_id = b.place_id)
    </select>

    <update id="updateInfo">
        update tb_user set
        phone=#{phone},
        staff_name=#{staffName}
        where
        user_id=#{userId}
    </update>

    <update id="updatePassword">
        update tb_user set
        login_pwd=#{newPassword}
        where
        user_id=#{userId} and login_pwd = #{password}
    </update>

    <select id="checkLoginName" resultType="integer">
select count(*) from tb_user u where u.user_id!=#{userId} and u.login_name=#{loginName}
    </select>
</mapper>