懒羊羊
2024-01-31 e57a8990ae56f657a59c435a0613c5f7a8728003
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
<?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.jcdm.system.mapper.SysUserPostMapper">
 
    <resultMap type="SysUserPost" id="SysUserPostResult">
        <result property="userId"     column="user_id"      />
        <result property="postId"     column="post_id"      />
    </resultMap>
 
    <delete id="deleteUserPostByUserId" parameterType="Long">
        delete from sys_user_post where user_id=#{userId}
    </delete>
    
    <select id="countUserPostById" resultType="Integer">
        select count(1) from sys_user_post where post_id=#{postId}  
    </select>
    
    <delete id="deleteUserPost" parameterType="Long">
         delete from sys_user_post where user_id in
         <foreach collection="array" item="userId" open="(" separator="," close=")">
             #{userId}
        </foreach> 
     </delete>
    
    <insert id="batchUserPost">
        insert into sys_user_post(user_id, post_id) values
        <foreach item="item" index="index" collection="list" separator=",">
            (#{item.userId},#{item.postId})
        </foreach>
    </insert>
    
</mapper>