<?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.article.dao.ArticleCategoryI18nDao">

    <!-- 批量插入 -->
    <insert id="insertBatch" parameterType="java.util.List">
        INSERT INTO cms_article_category_i18n (
            article_category_id, language, category_name, category_description
        )
        VALUES
        <foreach collection="translations" item="item" separator=",">
        (
            #{item.article_category_id}, #{item.language}, #{item.category_name}, #{item.category_description}
        )
        </foreach>
    </insert>

    <!-- 批量更新 -->
    <update id="updateBatch" parameterType="com.backendsys.modules.cms.article.entity.ArticleCategoryI18n">
        <foreach collection="translations" item="item" separator=";">
            UPDATE cms_article_category_i18n
            <set>
                <trim suffixOverrides="," suffix=" ">
                    category_name = #{item.category_name},
                    <if test="item.category_description != null and item.category_description != ''">
                        category_description = #{item.category_description},
                    </if>
                </trim>
            </set>
            WHERE article_category_id = #{item.article_category_id} AND language = #{item.language}
        </foreach>
    </update>

</mapper>
