fangyuan
2022-11-17 04656ebd6d0000dd4653eaf000bf73cb2bd4f521
ycl-platform/src/main/resources/mapper/NewsChannelDao.xml
@@ -1,31 +1,31 @@
<?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.ycl.mapper.NewsChannelDao">
    <resultMap type="com.ycl.entity.NewsChannel" id="NewsChannelMap">
        <result property="id" column="id" jdbcType="INTEGER"/>
        <result property="name" column="name" jdbcType="VARCHAR"/>
        <result property="code" column="code" jdbcType="VARCHAR"/>
        <result property="createTime" column="create_time" jdbcType="TIMESTAMP"/>
    </resultMap>
    <!-- 批量插入 -->
    <insert id="insertBatch" keyProperty="id" useGeneratedKeys="true">
        insert into news_website.news_channel(name, code, create_time)
        values
        <foreach collection="entities" item="entity" separator=",">
        (#{entity.name}, #{entity.code}, #{entity.createTime})
        </foreach>
    </insert>
    <!-- 批量插入或按主键更新 -->
    <insert id="insertOrUpdateBatch" keyProperty="id" useGeneratedKeys="true">
        insert into news_website.news_channel(name, code, create_time)
        values
        <foreach collection="entities" item="entity" separator=",">
            (#{entity.name}, #{entity.code}, #{entity.createTime})
        </foreach>
        on duplicate key update
         name = values(name) , code = values(code) , create_time = values(create_time)     </insert>
</mapper>
<?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.ycl.dao.NewsChannelDao">
    <resultMap type="com.ycl.entity.NewsChannel" id="NewsChannelMap">
        <result property="id" column="id" jdbcType="INTEGER"/>
        <result property="name" column="name" jdbcType="VARCHAR"/>
        <result property="code" column="code" jdbcType="VARCHAR"/>
        <result property="createTime" column="create_time" jdbcType="TIMESTAMP"/>
    </resultMap>
    <!-- 批量插入 -->
    <insert id="insertBatch" keyProperty="id" useGeneratedKeys="true">
        insert into news_website.news_channel(name, code, create_time)
        values
        <foreach collection="entities" item="entity" separator=",">
        (#{entity.name}, #{entity.code}, #{entity.createTime})
        </foreach>
    </insert>
    <!-- 批量插入或按主键更新 -->
    <insert id="insertOrUpdateBatch" keyProperty="id" useGeneratedKeys="true">
        insert into news_website.news_channel(name, code, create_time)
        values
        <foreach collection="entities" item="entity" separator=",">
            (#{entity.name}, #{entity.code}, #{entity.createTime})
        </foreach>
        on duplicate key update
         name = values(name) , code = values(code) , create_time = values(create_time)     </insert>
</mapper>