GroupMemberPositionMapper.xml 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
  3. "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
  4. <mapper namespace="com.zhyc.xps.sys.mapper.GroupMemberPositionMapper">
  5. <resultMap id="BaseResultMap" type="com.zhyc.xps.sys.entity.GroupMemberPosition">
  6. <result column="gmp_id" property="gmpId" jdbcType="BIGINT" /> <!--群组成员岗位记录ID-->
  7. <result column="oc_id" property="ocId" jdbcType="BIGINT" /> <!--公司或机构ID-->
  8. <result column="group_id" property="groupId" jdbcType="BIGINT" /> <!--群组ID-->
  9. <result column="account_id" property="accountId" jdbcType="BIGINT" /> <!--帐号ID-->
  10. <result column="position_id" property="positionId" jdbcType="BIGINT" /> <!--岗位ID-->
  11. </resultMap>
  12. <resultMap id="GroupMemberPositionDtoResultMap" type="com.zhyc.xps.sys.dto.GroupMemberPositionDto" extends="BaseResultMap">
  13. <result column="group_name" property="groupName" jdbcType="VARCHAR" />
  14. <result column="account_name" property="accountName" jdbcType="VARCHAR" />
  15. <result column="account_real_name" property="accountRealName" jdbcType="VARCHAR" />
  16. <result column="position_name" property="positionName" jdbcType="VARCHAR" />
  17. </resultMap>
  18. <sql id="GroupMemberPositionDto_Column_List">
  19. A.gmp_id,
  20. A.oc_id,
  21. A.group_id,
  22. B.group_name,
  23. A.account_id,
  24. D.account_name,
  25. D.account_real_name,
  26. A.position_id,
  27. C.position_name
  28. </sql>
  29. <!--基于ID查询-->
  30. <select id="getById" resultMap="GroupMemberPositionDtoResultMap">
  31. SELECT
  32. <include refid="GroupMemberPositionDto_Column_List" />
  33. FROM
  34. s_group_member_position A
  35. LEFT JOIN s_group B ON (A.oc_id = B.oc_id AND A.group_id = B.group_id)
  36. LEFT JOIN s_position C ON (A.oc_id = C.oc_id AND A.position_id = C.position_id)
  37. LEFT JOIN account D ON (A.oc_id = D.oc_id AND A.account_id = D.account_id)
  38. WHERE A.deleted_flag = 0
  39. <if test="ocId != null">
  40. AND A.oc_id = #{ocId,jdbcType=BIGINT}
  41. </if>
  42. <if test="gmpId != null">
  43. AND A.gmp_id = #{gmpId, jdbcType=BIGINT}
  44. </if>
  45. </select>
  46. <!--根据ID获取第1个岗位-->
  47. <select id="getFirstPositionByGroupIdAndAccountId" resultMap="GroupMemberPositionDtoResultMap">
  48. SELECT
  49. <include refid="GroupMemberPositionDto_Column_List" />
  50. FROM s_group_member_position A
  51. LEFT JOIN s_group B ON (A.oc_id = B.oc_id AND A.group_id = B.group_id)
  52. LEFT JOIN s_position C ON (A.oc_id = C.oc_id AND A.position_id = C.position_id)
  53. LEFT JOIN account D ON (A.oc_id = D.oc_id AND A.account_id = D.account_id)
  54. WHERE A.deleted_flag = 0
  55. <if test="ocId != null">
  56. AND A.oc_id = #{ocId,jdbcType=BIGINT}
  57. </if>
  58. <if test="groupId != null">
  59. AND A.group_id = #{groupId, jdbcType=BIGINT}
  60. </if>
  61. <if test="accountId != null">
  62. AND A.account_id = #{accountId, jdbcType=BIGINT}
  63. </if>
  64. LIMIT 1
  65. </select>
  66. <!--根据条件获取List getGroupMemberPositionList-->
  67. <select id="getByList" parameterType="java.util.Map" resultMap="GroupMemberPositionDtoResultMap">
  68. SELECT
  69. <include refid="GroupMemberPositionDto_Column_List" />
  70. FROM s_group_member_position A
  71. LEFT JOIN s_group B ON (A.oc_id = B.oc_id AND A.group_id = B.group_id)
  72. LEFT JOIN s_position C ON (A.oc_id = C.oc_id AND A.position_id = C.position_id)
  73. LEFT JOIN account D ON (A.oc_id = D.oc_id AND A.account_id = D.account_id)
  74. WHERE A.deleted_flag = 0
  75. <if test="ocId != null">
  76. AND A.oc_id = #{ocId,jdbcType=BIGINT}
  77. </if>
  78. <if test="groupId != null">
  79. AND A.group_id = #{groupId,jdbcType=BIGINT}
  80. </if>
  81. <if test="accountId != null">
  82. AND A.account_id = #{accountId ,jdbcType=BIGINT}
  83. </if>
  84. <if test="positionId != null">
  85. and A.position_id = #{positionId ,jdbcType=BIGINT}
  86. </if>
  87. <if test="nodeLeft != null and nodeRight != null">
  88. <![CDATA[
  89. AND
  90. B.node_left >= #{nodeLeft, jdbcType=BIGINT}
  91. AND
  92. B.node_right <= #{nodeRight, jdbcType=BIGINT}
  93. ]]>
  94. </if>
  95. <if test="position != null and position !=''">
  96. <foreach collection="position" item="item" open="and A.position_id in (" separator="," close=")">
  97. #{item}
  98. </foreach>
  99. </if>
  100. ORDER BY A.position_id ASC
  101. </select>
  102. <!--Insert新增-->
  103. <insert id="create" parameterType="com.zhyc.xps.sys.entity.GroupMemberPosition">
  104. insert into s_group_member_position
  105. <trim prefix="(" suffix=")" suffixOverrides=",">
  106. <if test="ocId != null">
  107. oc_id,
  108. </if>
  109. <if test="gmpId != null">
  110. gmp_id,
  111. </if>
  112. <if test="groupId != null">
  113. group_id,
  114. </if>
  115. <if test="accountId != null">
  116. account_id,
  117. </if>
  118. <if test="positionId != null">
  119. position_id,
  120. </if>
  121. <if test="createdBy != null">
  122. created_by,
  123. </if>
  124. <if test="createdAt != null">
  125. created_at,
  126. </if>
  127. </trim>
  128. <trim prefix="values (" suffix=")" suffixOverrides=",">
  129. <if test="ocId != null">
  130. #{ocId,jdbcType=BIGINT},
  131. </if>
  132. <if test="gmpId != null">
  133. #{gmpId,jdbcType=BIGINT},
  134. </if>
  135. <if test="groupId != null">
  136. #{groupId,jdbcType=BIGINT},
  137. </if>
  138. <if test="accountId != null">
  139. #{accountId,jdbcType=BIGINT},
  140. </if>
  141. <if test="positionId != null">
  142. #{positionId,jdbcType=BIGINT},
  143. </if>
  144. <if test="createdBy != null">
  145. #{createdBy,jdbcType=BIGINT},
  146. </if>
  147. <if test="createdAt != null">
  148. #{createdAt,jdbcType=TIMESTAMP},
  149. </if>
  150. </trim>
  151. </insert>
  152. <!--Update更新-->
  153. <update id="update" parameterType="com.zhyc.xps.sys.entity.GroupMemberPosition">
  154. UPDATE s_group_member_position
  155. <trim suffixOverrides=",">
  156. <set>
  157. <if test="groupId!= null">
  158. group_id = #{groupId,jdbcType=BIGINT},
  159. </if>
  160. <if test="accountId != null">
  161. account_id = #{accountId,jdbcType=BIGINT},
  162. </if>
  163. <if test="positionId != null">
  164. position_id = #{positionId,jdbcType=BIGINT},
  165. </if>
  166. <if test="updatedBy != null">
  167. updated_by = #{updatedBy,jdbcType=BIGINT},
  168. </if>
  169. <if test="updatedAt != null">
  170. updated_at = #{updatedAt,jdbcType=TIMESTAMP},
  171. </if>
  172. </set>
  173. </trim>
  174. WHERE gmp_id = #{gmpId ,jdbcType=BIGINT}
  175. AND oc_id = #{ocId ,jdbcType=BIGINT}
  176. </update>
  177. <!--删除-->
  178. <delete id="delete" parameterType="java.util.Map">
  179. DELETE FROM s_group_member_position
  180. WHERE 1 = 1
  181. <if test="ocId != null">
  182. and oc_id = #{ocId}
  183. </if>
  184. <if test="groupId!= null">
  185. AND group_id = #{groupId ,jdbcType=BIGINT}
  186. </if>
  187. <if test="accountId != null">
  188. AND account_id = #{accountId ,jdbcType=BIGINT}
  189. </if>
  190. <if test="positionId != null">
  191. AND position_id = #{positionId ,jdbcType=BIGINT}
  192. </if>
  193. <if test="gmpId!= null">
  194. AND gmp_id = #{gmpId ,jdbcType=BIGINT}
  195. </if>
  196. </delete>
  197. </mapper>