<?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.system.NumbMapper">

    <select id="selectSearchNumbList" resultType="com.oqpo.api.entity.system.NumbEntity">
        select  /* selectSearchNumbList */
                num_no, defi_info, num_nm,  use_yn, fn_code_nm('USE_YN',use_yn) as use_yn_nm
        from  np_num
        where 1=1
        <if test="sUseYn != null and sUseYn != ''">
        and   use_yn = #{sUseYn}
        </if>
        <if test="sNumNm != null and sNumNm != ''">
        and   (defi_info like concat('%',#{sNumNm},'%') or num_nm like concat('%',#{sNumNm},'%'))
        </if>
        order by defi_info asc
    </select>

    <select id="selectNumbInfo" resultType="com.oqpo.api.entity.system.NumbEntity">
        select /* selectNumbInfo */
            num_no, defi_info, num_nm, year_chk, month_chk, day_chk, num_st_no, num_ed_no, num_use_no, num_cu_no, use_yn, use_day
        from np_num
        where num_no = #{numNo}
    </select>

    <insert id="insertNumbInfo" >
        insert into np_num  /* insertNumbInfo */
        (defi_info, num_nm, year_chk, month_chk, day_chk, num_st_no, num_ed_no, use_yn, add_dt, add_id, chg_dt, chg_id)
        values
        (#{entity.defiInfo},#{entity.numNm},#{entity.yearChk},#{entity.monthChk},#{entity.dayChk},#{entity.numStNo},#{entity.numEdNo},#{entity.useYn}, now(), #{userId}, now(), #{userId})
    </insert>

    <update id="updateNumbInfo">
        update np_num  /** updateNumbInfo */
        set    defi_info    = #{entity.defiInfo}
            ,  num_nm       = #{entity.numNm}
            ,  year_chk     = #{entity.yearChk}
            ,  month_chk    = #{entity.monthChk}
            ,  day_chk      = #{entity.dayChk}
            ,  num_st_no    = #{entity.numStNo}
            ,  num_ed_no    = #{entity.numEdNo}
            ,  use_yn       = #{entity.useYn}
            ,  chg_dt       = now()
            ,  chg_id       = #{userId}
        where num_no       = #{entity.numNo}
    </update>

</mapper>
