<?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.NascMaterialListMapper">

    <resultMap id="materialListResult" type="NascMaterialList">
        <id     property="id"          column="id"         />
        <result property="materialId"    column="material_id"  />
        <result property="listName"  column="list_name" />
        <result property="memo"    column="memo"  />
        <result property="verification"    column="verification"  />
        <result property="imgs"    column="imgs"  />
    </resultMap>

    <insert id="insertMaterialList" parameterType="NascMaterialList" useGeneratedKeys="true" keyProperty="id">
        INSERT INTO nasc_material_list (material_id, list_name, memo, verification, imgs)
        VALUES (#{materialId}, #{listName}, #{memo}, #{verification}, #{imgs})
    </insert>

    <delete id="deleteMaterialListByMaterialId" parameterType="Long">
        DELETE FROM nasc_material_list
        WHERE material_id =#{materialId}
    </delete>

    <select id="getMaterialListByMaterialId" parameterType="Long" resultMap="materialListResult">
        SELECT nml.id, nml.material_id, nml.list_name, nml.memo, nml.verification, nml.imgs
        FROM nasc_material_list nml
        WHERE nml.material_id = #{materialId}
    </select>

</mapper> 