fangyuan
2022-11-18 c9d9a680d60722048fec46019b4a7ca36f821c58
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
<?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.NewsPoliceDao">
 
    <resultMap type="com.ycl.entity.NewsPolice" id="NewsPoliceMap">
        <result property="id" column="id" jdbcType="VARCHAR"/>
        <result property="rname" column="rname" jdbcType="VARCHAR"/>
        <result property="createTime" column="create_time" jdbcType="TIMESTAMP"/>
        <result property="updateTime" column="update_time" jdbcType="TIMESTAMP"/>
        <result property="newsDepartmentId" column="news_department_id" jdbcType="VARCHAR"/>
        <result property="phone" column="phone" jdbcType="VARCHAR"/>
    </resultMap>
 
    <!-- 批量插入 -->
    <insert id="insertBatch" keyProperty="id" useGeneratedKeys="true">
        insert into news_website.news_police(rname, create_time, update_time, news_department_id, phone)
        values
        <foreach collection="entities" item="entity" separator=",">
        (#{entity.rname}, #{entity.createTime}, #{entity.updateTime}, #{entity.newsDepartmentId}, #{entity.phone})
        </foreach>
    </insert>
    <!-- 批量插入或按主键更新 -->
    <insert id="insertOrUpdateBatch" keyProperty="id" useGeneratedKeys="true">
        insert into news_website.news_police(rname, create_time, update_time, news_department_id, phone)
        values
        <foreach collection="entities" item="entity" separator=",">
            (#{entity.rname}, #{entity.createTime}, #{entity.updateTime}, #{entity.newsDepartmentId}, #{entity.phone})
        </foreach>
        on duplicate key update
         rname = values(rname) , create_time = values(create_time) , update_time = values(update_time) , news_department_id = values(news_department_id) , phone = values(phone)     </insert>
 
    <insert id="savePolice" useGeneratedKeys="true" keyProperty="id" keyColumn="id">
        insert into news_website.news_police(rname, create_time, update_time, news_department_id, phone)
        values (#{entity.rname}, #{entity.createTime}, #{entity.updateTime}, #{entity.newsDepartmentId}, #{entity.phone})
    </insert>
</mapper>