<?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="loginDAO">


	<!-- 로그인 처리를 위한 resultMap -->
	<resultMap id="login" type="egovframework.com.cmm.LoginVO">
		<result property="id" column="id"/>
		<result property="name" column="name"/>
		<result property="ihidNum" column="ihidNum"/>
		<result property="email" column="email"/>
		<result property="password" column="password"/>
		<result property="userSe" column="userSe"/>
		<result property="orgnztId" column="orgnztId"/>
		<result property="uniqId" column="uniqId"/>		
	</resultMap>
	
	<!-- 아이디 찾기를 위한 resultMap 
	<resultMap id="id" class="egovframework.com.cmm.LoginVO">
		<result property="id" column="id" columnIndex="1"/>
	</resultMap>
	-->
	<!-- 비밀번호 처리를 위한 resultMap 
	<resultMap id="password" class="egovframework.com.cmm.LoginVO">
		<result property="password" column="password" columnIndex="1"/>
	</resultMap>
	-->
	<!-- 일반 로그인 -->
	<select id="actionLogin" resultMap="login">
		<if test='userSe == "USR"'>
			
            SELECT EMPLYR_ID AS id
                 , USER_NM AS name
                 , PASSWORD AS password
                 , IHIDNUM AS ihidNum
                 , EMAIL_ADRES AS email
                 , 'USR' AS userSe
                 , ORGNZT_ID AS orgnztId
                 , ESNTL_ID AS uniqId
              FROM LETTNEMPLYRINFO
             WHERE EMPLYR_ID = #{id}
               AND PASSWORD = #{password}
               AND EMPLYR_STTUS_CODE = 'P'
			
		</if>
	</select>
	
	<!-- 인증서 로그인
	<select id="actionCrtfctLogin" resultMap="login">
		<![CDATA[
		SELECT emplyr_id AS id
		     , USER_NM AS name
		     , password AS password
		     , ihidnum AS ihidNum
		     , email_adres AS email
		     , 'USR' AS userSe
		     , orgnzt_id AS orgnztId
		     , ESNTL_ID AS uniqId
		  FROM LETTNEMPLYRINFO
		 WHERE sub_dn = #{dn}
		]]>
	</select>
	 -->
	<!-- 아이디 찾기
	<select id="searchId" resultMap="id">
		<isEqual property="userSe" compareValue="GNR">
			<![CDATA[
			SELECT mber_id AS id
			  FROM LETTNGNRLMBER
			 WHERE mber_nm = #{name}
			   AND mber_email_adres = #{email}
			   AND mber_sttus = 'P'
			]]>
		</isEqual>
		<isEqual property="userSe" compareValue="ENT">
			<![CDATA[
			SELECT entrprsmber_id AS id
			  FROM LETTNENTRPRSMBER
			 WHERE cmpny_nm = #{name}
			   AND applcnt_email_adres = #{email}
			   AND entrprs_mber_sttus = 'P'
			]]>
		</isEqual>
		<isEqual property="userSe" compareValue="USR">
			<![CDATA[
			SELECT emplyr_id AS id
			  FROM LETTNEMPLYRINFO
			 WHERE USER_NM = #{name}
			   AND email_adres = #{email}
			   AND emplyr_sttus_code = 'P'
			]]>
		</isEqual>
	</select>
	 -->
	<!-- 비밀번호 찾기 
	<select id="searchPassword" resultMap="password">
		<isEqual property="userSe" compareValue="GNR">
			<![CDATA[
			SELECT password AS password
			  FROM LETTNGNRLMBER
			 WHERE mber_id = #{id}
			   AND mber_nm = #{name}
			   AND mber_email_adres = #{email}
			   AND password_hint = #{passwordHint}
			   AND password_cnsr = #{passwordCnsr}
			   AND mber_sttus = 'P'
			]]>
		</isEqual>
		<isEqual property="userSe" compareValue="ENT">
			<![CDATA[
			SELECT entrprs_mber_password AS password
			  FROM LETTNENTRPRSMBER
			 WHERE entrprsmber_id = #{id}
			   AND cmpny_nm = #{name}
			   AND applcnt_email_adres = #{email}
			   AND entrprs_mber_password_hint = #{passwordHint}
			   AND entrprs_mber_password_cnsr = #{passwordCnsr}
			   AND entrprs_mber_sttus = 'P'
			]]>
		</isEqual>
		<isEqual property="userSe" compareValue="USR">
			<![CDATA[
			SELECT password AS password
			  FROM LETTNEMPLYRINFO
			 WHERE emplyr_id = #{id}
			   AND USER_NM = #{name}
			   AND email_adres = #{email}
			   AND password_hint = #{passwordHint}
			   AND password_cnsr = #{passwordCnsr}
			   AND emplyr_sttus_code = 'P'
			]]>
		</isEqual>
	</select>
	-->
	<!-- 변경된 비밀번호를 저장 
	<update id="updatePassword">
		<isEqual property="userSe" compareValue="GNR">
			<![CDATA[
			UPDATE LETTNGNRLMBER
			   SET password = #{password}
			 WHERE mber_id = #{id}
			]]>
		</isEqual>
		<isEqual property="userSe" compareValue="ENT">
			<![CDATA[
			UPDATE LETTNENTRPRSMBER
			   SET entrprs_mber_password = #{password}
			 WHERE entrprsmber_id = #{id}
			]]>
		</isEqual>
		<isEqual property="userSe" compareValue="USR">
			<![CDATA[
			UPDATE LETTNEMPLYRINFO
			   SET password = #{password}
			 WHERE emplyr_id = #{id}
			]]>
		</isEqual>
	</update>
	-->
</mapper>