MaterialMapper.xml 2.01 KB
<?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.huaheng.pc.general.material.mapper.MaterialMapper">


    <select id="selectNameBycode" resultType="com.huaheng.pc.general.material.domain.Material">
        select name,barcode,masterUnit from material where code = #{code}
    </select>

    <select id="selectNameByListCode" resultType="com.huaheng.pc.general.material.domain.Material">
        select * from material where code in
        <foreach collection="array" item="id" open="(" separator="," close=")">
            #{id}
        </foreach>
    </select>
    <select id="selectNameByListUserdef1" resultType="com.huaheng.pc.general.material.domain.Material">
        select * from material where userDef1 in
        <foreach collection="array" item="id" open="(" separator="," close=")">
            #{id}
        </foreach>
    </select>

    <insert id="insertList" parameterType="com.huaheng.pc.general.material.domain.Material" keyProperty="id" useGeneratedKeys="true" >
        INSERT INTO material(
        code,
        barcode,
        name,
        warehouseId,
        warehouseCode,
        companyId,
        companyCode,
        specification,
        masterUnit,
        assistUnit,
        convertRate,
        type,
        userDef1,
        createdBy,
        lastUpdatedBy
        )values
        <foreach collection="materials" item="item" index="index" separator=",">
            (
            #{item.code},
            #{item.barcode},
            #{item.name},
            #{item.warehouseId},
            #{item.warehouseCode},
            #{item.companyId},
            #{item.companyCode},
            #{item.specification},
            #{item.masterUnit},
            #{item.assistUnit},
            #{item.convertRate},
            #{item.type},
            #{item.userDef1},
            #{item.createdBy},
            #{item.lastUpdatedBy}
            )
        </foreach>

    </insert>

</mapper>