PostMapper.xml 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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.PostMapper">
  4. <!-- 通用查询映射结果 -->
  5. <resultMap id="BaseResultMap" type="com.dayou.entity.Post">
  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="name" property="name" />
  11. <result column="department_id" property="departmentId" />
  12. <result column="duty" property="duty" />
  13. <result column="parent_id" property="parentId" />
  14. </resultMap>
  15. <!-- 通用查询结果列 -->
  16. <sql id="Base_Column_List">
  17. id,
  18. deleted,
  19. created,
  20. modified,
  21. name, department_id, duty,parent_id
  22. </sql>
  23. <insert id="upsert" parameterType="com.dayou.entity.Post">
  24. insert IGNORE into post (id,name) values(#{post.id},#{post.name})
  25. </insert>
  26. <select id="getPage" parameterType="com.dayou.vo.PostVO" resultType="com.dayou.vo.PostVO">
  27. SELECT
  28. p.id,
  29. p.NAME,
  30. p.duty,
  31. p.deleted,
  32. p.modified,
  33. d.NAME AS departmentName,
  34. d.id as departmentId,
  35. p.created,
  36. p.parent_id,
  37. p1.name as leaderPost,
  38. d1.name as leaderDepartmentName,
  39. d1.id as leaderDepartmentId,
  40. p1.id as leaderPostId
  41. FROM
  42. post p
  43. LEFT JOIN department d ON p.department_id = d.id
  44. left join post p1 on p.parent_id = p1.id
  45. left join department d1 on p1.department_id = d1.id
  46. <where>
  47. p.deleted =0 and d.deleted = 0
  48. <if test="postVO!=null and postVO.departmentName != null and postVO.departmentName != '' ">
  49. and d.name like concat ('%', #{postVO.departmentName},'%')
  50. </if>
  51. <if test="postVO!=null and postVO.name != null and postVO.name!='' ">
  52. and p.name like concat ('%',#{postVO.name},'%')
  53. </if>
  54. </where>
  55. order by p.id DESC
  56. </select>
  57. <select id="xSimpleAll" resultType="com.dayou.common.PullDownModel">
  58. select p.id ,CONCAT(p.name,'-',d.name) as name from post p left join department d on p.department_id = d.id where p.deleted =0 and d.deleted=0
  59. </select>
  60. <select id="getDepartmentList" parameterType="java.util.Set" resultType="com.dayou.bo.SimpleParentModel">
  61. select distinct d.name ,d.id ,d.parent_id from post p left join department d on d.id = p.department_id
  62. where d.deleted = 0 and p.deleted = 0
  63. <if test="postIds!=null and postIds.size!=0">
  64. and p.id in
  65. <foreach collection="postIds" item="pId" open="(" close=")" separator=",">
  66. #{pId}
  67. </foreach>
  68. </if>
  69. </select>
  70. </mapper>