ProPackagingMapper.xml 3.89 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.config.proPackaging.mapper.ProPackagingMapper">
    
    <resultMap type="com.huaheng.pc.config.proPackaging.domain.ProPackaging" id="proPackagingResult">
        <result property="id"    column="id"    />
        <result property="name"    column="name"    />
        <result property="number"    column="number"    />
        <result property="description"    column="description"    />
        <result property="pieceBox"    column="pieceBox"    />
        <result property="price"    column="price"    />
        <result property="boxs"    column="boxs"    />
        <result property="pallet"    column="pallet"    />
        <result property="deleted"    column="deleted"    />
    </resultMap>
	<sql id="selectproPackagingVo">
        select id, name, number, description, pieceBox, price, boxs, pallet,`deleted` from pro_packaging
    </sql>
    <update id="truncateTable">
        truncate table pro_packaging
    </update>
    <insert id="insertBatch" parameterType="java.util.List">
        INSERT INTO pro_packaging
        (id, name, number, description, pieceBox, price, boxs, pallet)
        VALUES
        <foreach collection="list" item="item" separator=",">
            (
            #{item.id},#{item.name},#{item.number},#{item.description},#{item.pieceBox},#{item.price},#{item.boxs},#{item.pallet}
            )
        </foreach>
    </insert>

    <update id="modifyBatch" parameterType="java.util.List">
        update pro_packaging
        <trim prefix="set" suffixOverrides=",">
            <trim prefix="name =case" suffix="end,">
                <foreach collection="list" item="item" index="index">
                    <if test="item.name!=null">
                        when deleted=0 and id=#{item.id}
                        then #{item.name}
                    </if>
                </foreach>
            </trim>
            <trim prefix="description =case" suffix="end,">
                <foreach collection="list" item="item" index="index">
                    <if test="item.description!=null">
                        when deleted=0 and id=#{item.id}
                        then #{item.description}
                    </if>
                </foreach>
            </trim>
            <trim prefix="pieceBox =case" suffix="end,">
                <foreach collection="list" item="item" index="index">
                    <if test="item.pieceBox!=null">
                        when deleted=0 and id=#{item.id}
                        then #{item.pieceBox}
                    </if>
                </foreach>
            </trim>
            <trim prefix="boxs =case" suffix="end,">
                <foreach collection="list" item="item" index="index">
                    <if test="item.boxs!=null">
                        when deleted=0 and id=#{item.id}
                        then #{item.boxs}
                    </if>
                </foreach>
            </trim>
            <trim prefix="price =case" suffix="end,">
                <foreach collection="list" item="item" index="index">
                    <if test="item.price!=null">
                        when deleted=0 and id=#{item.id}
                        then #{item.price}
                    </if>
                </foreach>
            </trim>
            <trim prefix="pallet =case" suffix="end,">
                <foreach collection="list" item="item" index="index">
                    <if test="item.pallet!=null">
                        when deleted=0 and id=#{item.id}
                        then #{item.pallet}
                    </if>
                </foreach>
            </trim>
        </trim>
        where id in
        <foreach collection="list" item="item" index="index" separator="," open="(" close=")">
            #{item.id}
        </foreach>
    </update>
</mapper>