<?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.oqpo.api.mapper.MemberMapper">

    <select id="selectMemberById" resultType="com.oqpo.api.entity.oper.MemberEntity">
        SELECT /* selectMemberById */
            user_id, user_nm, user_pw as password
            ,system_admin_yn, super_admin_yn, auth_tp_cd
             ,case when auth_tp_cd in ('10','20') then '오더퀸'
                 when auth_tp_cd in ('30') then fn_affl_nm(affl_shop_id)
                 when auth_tp_cd in ('40') then fn_brand_nm(brand_id)
                 when auth_tp_cd in ('50') then fn_store_nm(brand_id, store_id)
                 when auth_tp_cd in ('60') then fn_spply_nm(spply_id)
                 end as auth_tp_nm
            , affl_shop_id, fn_affl_nm(affl_shop_id) as affl_shop_nm
            , brand_id, fn_brand_nm(brand_id) as brand_nm
            , store_id, fn_store_nm(brand_id, store_id) as store_nm
            , spply_id, fn_spply_nm(spply_id) as spply_nm
        FROM np_user_info
        WHERE user_id = #{userId}
    </select>

    <select id="selectMemberFindId" resultType="com.oqpo.api.entity.oper.MemberEntity">
        select /* selectMemberFindId */
                a.user_id
        from np_user_info a
        where a.user_nm = #{userNm}
        and a.email = #{email}
        and replace(a.tel_no,'-','') = replace(#{telNo},'-','')
    </select>

    <select id="selectMemberFindPwCnt" resultType="Integer">
        select /* selectMemberFindPw */
                count(*) as id_cnt
        from np_user_info
        where user_id = #{userId}
        and email = #{email}
        and replace(tel_no,'-','') = replace(#{telNo},'-','')
    </select>





</mapper>
