<?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="WebLogin">
	
	<!-- 사용자 로그인 -->
	<select id="memberLogin" parameterType="hashmap" resultType="hashmap">
		SELECT MU.MU_MEMBER_ID                        AS "muMemberId"
			  ,MU.LOGIN_ID                            AS "loginId"
			  ,MU.PASSWORD                            AS "password"
			  ,MU.NAME                                AS "name"
			  ,MU.PHONE_NUMBER                        AS "phoneNumber"
			  ,MU.MU_AUTH_ID                          AS "type"
			  ,MU.STATUS                              AS "status"
		  FROM MU_MEMBER AS MU
		 WHERE MU.USE_YN = 'Y'
		   AND MU.LOGIN_ID = #{loginId}
		   AND MU.PASSWORD = #{password}
	</select>
	
	<!-- 로그인 아이디 중복체크 -->
	<select id="checkloginId" parameterType="hashmap" resultType="hashmap">
		SELECT MU.MU_MEMBER_ID                        AS "muMemberId"
		  FROM MU_MEMBER AS MU
		 WHERE MU.USE_YN = 'Y'
		   AND MU.LOGIN_ID	= #{loginId}
		<if test="muMemberId != null and muMemberId != ''">
		   AND MU.MU_MEMBER_ID != #{muMemberId}
		</if>
	</select>
	
	<update id="updateLastLoginDate" parameterType="hashmap">
		UPDATE MU_MEMBER
		   SET MOD_DATE              = NOW()
			  ,MOD_ID                = #{modId}
			  ,LAST_LOGIN_DATE       = NOW()
			  ,IP                    = #{visitIp,jdbcType=VARCHAR}
		 WHERE USE_YN          = 'Y'
		   AND MU_MEMBER_ID    = #{muMemberId}
	</update>

</mapper>