<?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.fuzamei.mapperInterface.LoginMapper">
	
	<select id="queryUser" resultType="User">
		select 
			u.user_id,
			u.username,
			u.person_name,
			u.random,
			u.role_id,
			r.role_name,
			t.token
		from 
			users u
		left join
			role r
		on 
			u.role_id=r.role_id
		left join 
			token t
		on 
			t.user_id=u.user_id
		where
			u.username=#{username}
		and 
			u.password=#{password}
		
	</select>
	
	<update id="updateToken">
		update 
			token
		set
			token=#{token}
		where 
			user_id=#{userId}
	</update>
	
	<insert id="insertToken">
		insert into token(user_id,token) values(#{userId},#{token})
	</insert>
	
	
	
	
	
	
</mapper>