<?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.tsi.sig.server.mapper.LoginMapper">

	<select id="login" parameterType="HashMap" resultType="com.tsi.sig.server.objects.UserVO">
		select
			user_id userId
			 , user_pswd userPswd
			 , user_name userName
			 , user_grade userGrade
			 , useyn
		from
			tb_tsc_user
		where
			user_id=#{username}
		  and
			user_pswd=#{password}
	</select>

	<update id="initFailCnt" parameterType="String">
		update
			tb_tsc_user
		set
			fail_cnt=0
		where
			user_id=#{username}
	</update>

	<update id="loginFail" parameterType="String">
		update
			tb_tsc_user
		set
			fail_cnt=fail_cnt+1
		where
			user_id=#{username}
	</update>

	<update id="fullFail" parameterType="String">
		update
			tb_tsc_user
		set
			fail_cnt = 0,
			useyn = "N"
		where
			user_id=#{username}
	</update>

	<select id="findUserId" parameterType="String" resultType="com.tsi.sig.server.objects.UserVO">
		select
			user_id userId
			 , user_pswd userPswd
			 , user_name userName
			 , user_grade userGrade
			 , useyn
			 , fail_cnt failCnt
		from
			tb_tsc_user
		where
			user_id=#{username}
	</select>

</mapper>