UserPostMapper.xml 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  3. <mapper namespace="com.dayou.mapper.UserPostMapper">
  4. <!-- 通用查询映射结果 -->
  5. <resultMap id="BaseResultMap" type="com.dayou.entity.UserPost">
  6. <result column="id" property="id" />
  7. <result column="deleted" property="deleted" />
  8. <result column="created" property="created" />
  9. <result column="modified" property="modified" />
  10. <result column="user_id" property="userId" />
  11. <result column="post_id" property="postId" />
  12. </resultMap>
  13. <!-- 通用查询结果列 -->
  14. <sql id="Base_Column_List">
  15. id,
  16. deleted,
  17. created,
  18. modified,
  19. user_id, post_id
  20. </sql>
  21. <select id="getPostList" parameterType="java.lang.Long" resultType="com.dayou.dto.SimplePostModel">
  22. select p.id as id,p.name as name,p.department_id as departmentId,p.parent_id as parentId
  23. from user_post t
  24. join
  25. post p
  26. on t.post_id = p.id
  27. where t.user_id = #{userId}
  28. and t.deleted = false
  29. and p.deleted = false
  30. </select>
  31. <insert id="saveOrUpdateById" parameterType="com.dayou.entity.UserPost">
  32. insert into user_post(`id`,`user_id`, `post_id`)
  33. values
  34. (#{userPost.id},#{userPost.userId},#{userPost.postId})
  35. on duplicate key update
  36. id=id
  37. </insert>
  38. <select id="getPostUserId" parameterType="java.util.Set" resultType="java.lang.Long">
  39. select id from user u right join (select distinct user_id from user_post where post_id in (
  40. <foreach collection="juniorPost" item="item" index="index" separator=",">
  41. #{item}
  42. </foreach>
  43. ) and deleted = 0 ) up on up.user_id = u.id where u.deleted = 0 and enable = 1
  44. </select>
  45. <select id="getMarketPostList" parameterType="java.lang.Long" resultType="com.dayou.dto.SimplePostModel">
  46. select p.id as id,p.name as name,p.department_id as departmentId,p.parent_id as parentId
  47. from user_post t
  48. join
  49. post p
  50. on t.post_id = p.id
  51. left join department d on d.id = p.department_id
  52. where t.user_id = #{userId} and d.name = '市场部'
  53. and t.deleted = false
  54. and p.deleted = false
  55. </select>
  56. </mapper>