<?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.th.demo.mapping.maint.ProdPriceMapper" >
    <resultMap id="BaseResultMap" type="com.th.demo.model.maint.ProdPrice" >
        <id column="id" property="id" jdbcType="VARCHAR" />
        <result column="prod_nm" property="prodNm" jdbcType="VARCHAR" />
        <result column="invoice_price" property="invoicePrice" jdbcType="DOUBLE" />
        <result column="crt_time" property="crtTime" jdbcType="TIMESTAMP" />
        <result column="cancel_flag" property="cancelFlag" jdbcType="VARCHAR" />
        <result column="cancel_time" property="cancelTime" jdbcType="TIMESTAMP" />
        <result column="cancel_id" property="cancelId" jdbcType="VARCHAR" />
        <result column="crt_id" property="crtId" jdbcType="VARCHAR" />
    </resultMap>

    <insert id="savePriceNew" parameterType="com.th.demo.model.maint.ProdPrice" >
        <selectKey keyProperty="id" order="BEFORE" resultType="java.lang.String">
            SELECT  REPLACE(UUID(),'-','') as id from dual
        </selectKey>
        insert into t_maint_prod_price(id,prod_nm,invoice_price,crt_time,crt_id)
        values (#{id,jdbcType=VARCHAR},#{prodNm,jdbcType=VARCHAR}, #{invoicePrice,jdbcType=DOUBLE}, #{crtTime,jdbcType=TIMESTAMP},#{crtId,jdbcType=VARCHAR})
    </insert>


    <select id="selectByProdNm" resultMap="BaseResultMap" >
        select * from t_maint_prod_price t where t.prod_nm = #{param1,jdbcType=VARCHAR} and ifnull(t.cancel_flag,'0') = '0'
    </select>

    <select id="queryPriceNew" resultMap="BaseResultMap" >
        select * from t_maint_prod_price t where ifnull(t.cancel_flag,'0') = '0'
    </select>

    <delete id="deletePriceNew" parameterType="java.lang.String" >
       update t_maint_prod_price t set t.cancel_flag = '1',t.cancel_time = now(),t.cancel_id=#{param1,jdbcType=VARCHAR}  where t.id = #{param1,jdbcType=VARCHAR}
  </delete>


</mapper>