TaskMapper.xml 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  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.hssx.pcbms.mapper.TaskMapper">
  4. <!-- 通用查询映射结果 -->
  5. <resultMap id="BaseResultMap" type="com.hssx.pcbms.entity.Task">
  6. <id column="id" property="id" />
  7. <result column="name" property="name" />
  8. <result column="code" property="code" />
  9. <result column="plan_time" property="planTime" />
  10. <result column="work_load" property="workLoad" />
  11. <result column="recipient_id" property="recipientId" />
  12. <result column="payer" property="payer" />
  13. <result column="payee" property="payee" />
  14. <result column="fee" property="fee" />
  15. <result column="tag_id" property="tagId" />
  16. <result column="delay_time" property="delayTime" />
  17. <result column="state" property="state" />
  18. <result column="publish_id" property="publishId" />
  19. <result column="content" property="content" />
  20. </resultMap>
  21. <resultMap id="BaseResultMapVO" type="com.hssx.pcbms.entity.vo.TaskDTO">
  22. <id column="id" property="id" />
  23. <result column="name" property="name" />
  24. <result column="code" property="code" />
  25. <result column="plan_time" property="planTime" />
  26. <result column="work_load" property="workLoad" />
  27. <result column="recipient_id" property="recipientId" />
  28. <result column="payer" property="payer" />
  29. <result column="payee" property="payee" />
  30. <result column="fee" property="fee" />
  31. <result column="tag_id" property="tagId" />
  32. <result column="delay_time" property="delayTime" />
  33. <result column="state" property="state" />
  34. <result column="publish_id" property="publishId" />
  35. <result column="publishName" property="publishName" />
  36. <result column="tag_name" property="tagName" />
  37. <result column="recipient" property="recipient" />
  38. <result column="content" property="content" />
  39. <collection property="participantsVOS" select="selectPaticaterByTaskId" column="{taskId=id,}"
  40. ofType="com.hssx.pcbms.entity.vo.TaskParticipantsVO"/>
  41. </resultMap>
  42. <!-- 通用查询结果列 -->
  43. <sql id="Base_Column_List">
  44. id, name, code, plan_time, work_load, recipient_id, payer, payee, fee, tag_id, delay_time, state, publish_id
  45. </sql>
  46. <select id="selectListByCondition" resultMap="BaseResultMapVO">
  47. select
  48. t.id, t.name, t.code, t.plan_time, t.work_load, t.recipient_id,
  49. t.payer, t.payee, t.fee, t.tag_id, t.delay_time, t.state, t.publish_id
  50. u.name publishName,tt.name tag_name,ru.name recipient,t.content
  51. from
  52. task t
  53. left join user u
  54. on t.publish_id = u.id
  55. left join task_tags tt
  56. on tt.id = t.tag_id
  57. left join user ru
  58. on t.recipient_id = ru.id
  59. <where>
  60. <if test="taskVO.keyName != null and taskVO.keyName != ''">
  61. and name like concat('%',#{taskVO.keyName},'%')
  62. </if>
  63. <if test="taskVO.startTime != null and taskVO.startTime != ''and taskVO.endTime != null and taskVO.endTime != ''">
  64. and plan_time between #{taskVO.startTime} and #{taskVO.endTime}
  65. </if>
  66. <if test="taskVO.uid != null">
  67. and publish_id =#{taskVO.uid}
  68. </if>
  69. <if test="taskVO.tagId != null and taskVO.tagId != ''">
  70. and t.tag_id = #{taskVO.tagId}
  71. </if>
  72. </where>
  73. order by t.id desc
  74. </select>
  75. <select id="selectListByTaskIds" resultMap="BaseResultMapVO">
  76. select
  77. t.id, t.name, t.code, t.plan_time, t.work_load, t.recipient_id,
  78. t.payer, t.payee, t.fee, t.tag_id, t.delay_time, t.state, t.publish_id
  79. u.name publishName,tt.name tag_name,ru.name recipient
  80. from
  81. task t
  82. left join user u
  83. on t.publish_id = u.id
  84. left join task_tags tt
  85. on tt.id = t.tag_id
  86. left join user ru
  87. on t.recipient_id = ru.id
  88. <where>
  89. <foreach collection="list" separator="," close=")" item="item" open="t.id in (" index="index">
  90. #{item}
  91. </foreach>
  92. <if test="taskVO.keyName != null and taskVO.keyName != ''">
  93. and name like concat('%',#{taskVO.keyName},'%')
  94. </if>
  95. <if test="taskVO.startTime != null and taskVO.startTime != ''and taskVO.endTime != null and taskVO.endTime != ''">
  96. and plan_time between #{taskVO.startTime} and #{taskVO.endTime}
  97. </if>
  98. <if test="taskVO.uid != null">
  99. and publish_id =#{taskVO.uid}
  100. </if>
  101. <if test="taskVO.tagId != null and taskVO.tagId != ''">
  102. and t.tag_id = #{taskVO.tagId}
  103. </if>
  104. </where>
  105. order by t.id desc
  106. </select>
  107. <resultMap id="PaticaterMapVO" type="com.hssx.pcbms.entity.vo.TaskParticipantsVO">
  108. <id column="id" property="id" />
  109. <result column="user_id" property="userId" />
  110. <result column="task_id" property="taskId" />
  111. <result column="head_pic" property="headPic"/>
  112. <result column="name" property="userName"/>
  113. </resultMap>
  114. <select id="selectPaticaterByTaskId" resultMap="PaticaterMapVO">
  115. select tp.id, tp.user_id, tp.task_id,u.name
  116. from task_participants tp
  117. left join user u
  118. on tp.user_id = u.id
  119. where tp.task_id = #{id}
  120. </select>
  121. <select id="getDetailById" resultMap="BaseResultMapVO">
  122. select
  123. t.id, t.name, t.code, t.plan_time, t.work_load, t.recipient_id,
  124. t.payer, t.payee, t.fee, t.tag_id, t.delay_time, t.state, t.publish_id
  125. u.name publishName,tt.name tag_name,ru.name recipient,t.content
  126. from
  127. task t
  128. left join user u
  129. on t.publish_id = u.id
  130. left join task_tags tt
  131. on tt.id = t.tag_id
  132. left join user ru
  133. on t.recipient_id = ru.id
  134. <where>
  135. t.id = #{taskVO.id}
  136. </where>
  137. </select>
  138. </mapper>