CompanyUserPostMapper.xml 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. <?xml version="1.0" encoding="UTF-8" ?>
  2. <!DOCTYPE mapper
  3. PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
  4. "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  5. <mapper namespace="com.fs.company.mapper.CompanyUserPostMapper">
  6. <resultMap type="CompanyUserPost" id="CompanyUserPostResult">
  7. <result property="userId" column="user_id" />
  8. <result property="postId" column="post_id" />
  9. </resultMap>
  10. <sql id="selectCompanyUserPostVo">
  11. select user_id, post_id from company_user_post
  12. </sql>
  13. <select id="selectCompanyUserPostList" parameterType="CompanyUserPost" resultMap="CompanyUserPostResult">
  14. <include refid="selectCompanyUserPostVo"/>
  15. <where>
  16. </where>
  17. </select>
  18. <select id="selectCompanyUserPostById" parameterType="Long" resultMap="CompanyUserPostResult">
  19. <include refid="selectCompanyUserPostVo"/>
  20. where user_id = #{userId}
  21. </select>
  22. <insert id="insertCompanyUserPost" parameterType="CompanyUserPost">
  23. insert into company_user_post
  24. <trim prefix="(" suffix=")" suffixOverrides=",">
  25. <if test="userId != null">user_id,</if>
  26. <if test="postId != null">post_id,</if>
  27. </trim>
  28. <trim prefix="values (" suffix=")" suffixOverrides=",">
  29. <if test="userId != null">#{userId},</if>
  30. <if test="postId != null">#{postId},</if>
  31. </trim>
  32. </insert>
  33. <update id="updateCompanyUserPost" parameterType="CompanyUserPost">
  34. update company_user_post
  35. <trim prefix="SET" suffixOverrides=",">
  36. <if test="postId != null">post_id = #{postId},</if>
  37. </trim>
  38. where user_id = #{userId}
  39. </update>
  40. <delete id="deleteCompanyUserPostById" parameterType="Long">
  41. delete from company_user_post where user_id = #{userId}
  42. </delete>
  43. <delete id="deleteCompanyUserPostByIds" parameterType="String">
  44. delete from company_user_post where user_id in
  45. <foreach item="userId" collection="array" open="(" separator="," close=")">
  46. #{userId}
  47. </foreach>
  48. </delete>
  49. <insert id="batchUserPost">
  50. insert into company_user_post(user_id, post_id) values
  51. <foreach item="item" index="index" collection="list" separator=",">
  52. (#{item.userId},#{item.postId})
  53. </foreach>
  54. </insert>
  55. <delete id="deleteUserPostByUserId" parameterType="Long">
  56. delete from company_user_post where user_id=#{userId}
  57. </delete>
  58. </mapper>