<?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.backendsys.modules.cms.page.dao.PageI18nDao">

    <!-- 批量插入 -->
    <insert id="insertBatch" parameterType="java.util.List">
        INSERT INTO cms_page_i18n (
            page_sign, language,
            title, description, content, meta_keyword, meta_description
        )
        VALUES
        <foreach collection="translations" item="item" separator=",">
        (
            #{item.page_sign}, #{item.language},
            #{item.title}, #{item.description}, #{item.content},
            #{item.meta_keyword}, #{item.meta_description}
        )
        </foreach>
    </insert>

    <!-- 批量更新 -->
    <update id="updateBatch" parameterType="com.backendsys.modules.cms.page.entity.PageI18n">
        <foreach collection="translations" item="item" separator=";">
            UPDATE cms_page_i18n
            <set>
                <trim suffixOverrides="," suffix=" ">
                    title = #{item.title},
                    content = #{item.content},
                    <if test="item.description != null and item.description != ''">
                        description = #{item.description},
                    </if>
                    <if test="item.meta_keyword != null and item.meta_keyword != ''">
                        meta_keyword = #{item.meta_keyword},
                    </if>
                    <if test="item.meta_description != null and item.meta_description != ''">
                        meta_description = #{item.meta_description},
                    </if>
                </trim>
            </set>
            WHERE page_sign = #{item.page_sign} AND language = #{item.language}
        </foreach>
    </update>

</mapper>
