<?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.dbnt.faisp.userInfo.mapper.UserInfoMapper">
  <select id="selectUserInfoList" resultType="UserInfo" parameterType="UserInfo">
    select user_seq,
           user_id,
           user_nm,
           address,
           user_role,
           detail_addr,
           email,
           og_cd,
           ofc_cd,
           wrt_dt
    from user_info
    where
    <choose>
    	<when test="userStatus != null and userStatus != ''">
    	user_status = #{userStatus}
    	</when>
    	<otherwise>
    	user_status != 'D'
    	</otherwise>
    </choose> 
    <if test="userId != null and userId != ''">
      and user_id like '%'||#{userId}||'%'
    </if>
    <if test="userNm != null and userNm != ''">
      and user_nm like '%'||#{userNm}||'%'
    </if>
    <if test="ogCd != null and ogCd != ''">
      and og_cd = #{ogCd}
    </if>
    <if test="ofcCd != null and ofcCd != ''">
      and ofc_cd = #{ofcCd}
    </if>
    order by og_cd, ofc_cd desc
    limit #{rowCnt} offset #{firstIndex}
  </select>

  <select id="selectUserInfoListCnt" resultType="int" parameterType="UserInfo">
    select count(*)
    from user_info
    where
    <choose>
    	<when test="userStatus != null and userStatus != ''">
    	user_status = #{userStatus}
    	</when>
    	<otherwise>
    	user_status != 'D'
    	</otherwise>
    </choose> 
    <if test="userId != null and userId != ''">
      and user_id like '%'||#{userId}||'%'
    </if>
    <if test="userNm != null and userNm != ''">
      and user_nm like '%'||#{userNm}||'%'
    </if>
    <if test="ogCd != null and ogCd != ''">
      and og_cd = #{ogCd}
    </if>
    <if test="ofcCd != null and ofcCd != ''">
      and ofc_cd = #{ofcCd}
    </if>
  </select>
</mapper>