HospitalUserPostMapper.xml 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  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.hospital.mapper.HospitalUserPostMapper">
  6. <resultMap type="HospitalUserPost" id="HospitalUserPostResult">
  7. <result property="userId" column="user_id" />
  8. <result property="postId" column="post_id" />
  9. <result property="hospitalId" column="hospital_id" />
  10. </resultMap>
  11. <sql id="selectHospitalUserPostVo">
  12. select user_id, post_id, hospital_id from hospital_user_post
  13. </sql>
  14. <select id="selectHospitalUserPostList" parameterType="HospitalUserPost" resultMap="HospitalUserPostResult">
  15. <include refid="selectHospitalUserPostVo"/>
  16. <where>
  17. <if test="hospitalId != null "> and hospital_id = #{hospitalId}</if>
  18. </where>
  19. </select>
  20. <select id="selectHospitalUserPostByUserId" parameterType="Long" resultMap="HospitalUserPostResult">
  21. <include refid="selectHospitalUserPostVo"/>
  22. where user_id = #{userId}
  23. </select>
  24. <insert id="insertHospitalUserPost" parameterType="HospitalUserPost">
  25. insert into hospital_user_post
  26. <trim prefix="(" suffix=")" suffixOverrides=",">
  27. <if test="userId != null">user_id,</if>
  28. <if test="postId != null">post_id,</if>
  29. <if test="hospitalId != null">hospital_id,</if>
  30. </trim>
  31. <trim prefix="values (" suffix=")" suffixOverrides=",">
  32. <if test="userId != null">#{userId},</if>
  33. <if test="postId != null">#{postId},</if>
  34. <if test="hospitalId != null">#{hospitalId},</if>
  35. </trim>
  36. </insert>
  37. <update id="updateHospitalUserPost" parameterType="HospitalUserPost">
  38. update hospital_user_post
  39. <trim prefix="SET" suffixOverrides=",">
  40. <if test="postId != null">post_id = #{postId},</if>
  41. <if test="hospitalId != null">hospital_id = #{hospitalId},</if>
  42. </trim>
  43. where user_id = #{userId}
  44. </update>
  45. <delete id="deleteHospitalUserPostByUserId" parameterType="Long">
  46. delete from hospital_user_post where user_id = #{userId}
  47. </delete>
  48. <delete id="deleteHospitalUserPostByUserIds" parameterType="String">
  49. delete from hospital_user_post where user_id in
  50. <foreach item="userId" collection="array" open="(" separator="," close=")">
  51. #{userId}
  52. </foreach>
  53. </delete>
  54. <insert id="batchUserPost">
  55. insert into hospital_user_post(user_id, post_id) values
  56. <foreach item="item" index="index" collection="list" separator=",">
  57. (#{item.userId},#{item.postId})
  58. </foreach>
  59. </insert>
  60. <delete id="deleteUserPostByUserId" parameterType="Long">
  61. delete from hospital_user_post where user_id=#{userId}
  62. </delete>
  63. </mapper>