<?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.nasc.custom.mapper.NascPrintMapper">

    <resultMap id="printResult" type="NascPrint">
        <id     property="id"         column="id"        />
        <result property="matterId"   column="matter_id" />
        <result property="content"    column="content"   />
        <result property="missContent"    column="miss_content"   />
        <result property="denyContent"    column="deny_content"   />
        <result property="disposableContent"    column="disposable_content"   />
        <result property="printBy"    column="print_by"  />
        <result property="printTime"  column="print_ime" />
    </resultMap>

    <insert id="insertPrint" parameterType="NascPrint" useGeneratedKeys="true" keyProperty="id">
        INSERT INTO nasc_print (matter_id, content, miss_content, deny_content, disposable_content, print_by, print_time)
        VALUES (#{matterId}, #{content}, #{missContent}, #{denyContent}, #{disposableContent}, #{printBy}, sysdate())
    </insert>

    <update id="updatePrint" parameterType="NascPrint">
        UPDATE nasc_print
        SET content = #{content}, miss_content = #{missContent}, deny_content = #{denyContent}, print_by = #{printBy}, print_time = sysdate()
        WHERE id = #{id}
    </update>

    <select id="getPrintByMatterId" parameterType="Long" resultMap="printResult">
        SELECT np.id, np.matter_id, np.content, np.miss_content, np.deny_content, np.disposable_content, np.print_by, np.print_time
        FROM nasc_print np
        WHERE np.matter_id = #{matterId}
    </select>

</mapper> 