GroupMemberPositionGrantMapper.xml 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  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.GroupMemberPositionGrantMapper">
  5. <resultMap id="BaseResultMap" type="com.zhyc.xps.sys.entity.GroupMemberPositionGrant">
  6. <result column="gmpg_id" property="gmpgId" 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. <result column="grant_group_id" property="grantGroupId" jdbcType="BIGINT" /> <!--授权群组ID-->
  12. </resultMap>
  13. <resultMap id="GroupMemberPositionGrantDtoResultMap" type="com.zhyc.xps.sys.dto.GroupMemberPositionGrantDto" extends="BaseResultMap">
  14. <result column="grant_group_name" property="grantGroupName" jdbcType="VARCHAR" />
  15. </resultMap>
  16. <sql id="GroupMemberPositionGrantDto_Cols">
  17. A.gmpg_id,
  18. A.oc_id,
  19. A.group_id,
  20. A.account_id,
  21. A.position_id,
  22. A.grant_group_id,
  23. B.group_name AS grant_group_name
  24. </sql>
  25. <!--基于ID查询-->
  26. <select id="getById" parameterType="java.lang.Long" resultMap="GroupMemberPositionGrantDtoResultMap">
  27. SELECT
  28. <include refid="GroupMemberPositionGrantDto_Cols" />
  29. FROM s_group_member_position_grant A
  30. LEFT JOIN s_group B ON(A.oc_id = B.oc_id AND A.grant_group_id = B.group_id)
  31. WHERE
  32. A.gmpg_id = #{gmpgId, jdbcType=BIGINT}
  33. </select>
  34. <!--根据ID获取第1个授权群组-->
  35. <select id="getFirstGrantGroupByPosition" resultMap="GroupMemberPositionGrantDtoResultMap">
  36. SELECT
  37. <include refid="GroupMemberPositionGrantDto_Cols" />
  38. FROM s_group_member_position_grant A
  39. LEFT JOIN s_group B ON(A.oc_id = B.oc_id AND A.grant_group_id = B.group_id)
  40. WHERE A.deleted_flag = 0
  41. <if test="ocId != null">
  42. AND A.oc_id = #{ocId,jdbcType=BIGINT}
  43. </if>
  44. <if test="groupId != null">
  45. AND A.group_id = #{groupId, jdbcType=BIGINT}
  46. </if>
  47. <if test="accountId != null">
  48. AND A.account_id = #{accountId, jdbcType=BIGINT}
  49. </if>
  50. <if test="positionId != null">
  51. AND A.position_id = #{positionId, jdbcType=BIGINT}
  52. </if>
  53. LIMIT 1
  54. </select>
  55. <!--Insert新增-->
  56. <insert id="create" parameterType="com.zhyc.xps.sys.entity.GroupMemberPositionGrant">
  57. insert into s_group_member_position_grant
  58. <trim prefix="(" suffix=")" suffixOverrides=",">
  59. <if test="gmpgId != null">
  60. gmpg_id,
  61. </if>
  62. <if test="ocId != null">
  63. oc_id,
  64. </if>
  65. <if test="groupId != null">
  66. group_id,
  67. </if>
  68. <if test="accountId != null">
  69. account_id,
  70. </if>
  71. <if test="positionId != null">
  72. position_id,
  73. </if>
  74. <if test="grantGroupId != null">
  75. grant_group_id,
  76. </if>
  77. <if test="createdBy != null">
  78. created_by,
  79. </if>
  80. <if test="createdAt != null">
  81. created_at,
  82. </if>
  83. </trim>
  84. <trim prefix="values (" suffix=")" suffixOverrides=",">
  85. <if test="gmpgId != null">
  86. #{gmpgId,jdbcType=BIGINT},
  87. </if>
  88. <if test="ocId != null">
  89. #{ocId,jdbcType=BIGINT},
  90. </if>
  91. <if test="groupId != null">
  92. #{groupId,jdbcType=BIGINT},
  93. </if>
  94. <if test="accountId != null">
  95. #{accountId,jdbcType=BIGINT},
  96. </if>
  97. <if test="positionId != null">
  98. #{positionId,jdbcType=BIGINT},
  99. </if>
  100. <if test="grantGroupId != null">
  101. #{grantGroupId,jdbcType=BIGINT},
  102. </if>
  103. <if test="createdBy != null">
  104. #{createdBy,jdbcType=BIGINT},
  105. </if>
  106. <if test="createdAt != null">
  107. #{createdAt,jdbcType=TIMESTAMP},
  108. </if>
  109. </trim>
  110. </insert>
  111. <!--Update更新-->
  112. <update id="update" parameterType="com.zhyc.xps.sys.entity.GroupMemberPositionGrant">
  113. UPDATE s_group_member_position_grant
  114. <trim suffixOverrides=",">
  115. <set>
  116. <if test="groupId!= null">
  117. group_id = #{groupId,jdbcType=BIGINT},
  118. </if>
  119. <if test="accountId != null">
  120. account_id = #{accountId,jdbcType=BIGINT},
  121. </if>
  122. <if test="positionId != null">
  123. position_id = #{positionId,jdbcType=BIGINT},
  124. </if>
  125. <if test="grantGroupId != null">
  126. grant_group_id = #{grantGroupId,jdbcType=BIGINT},
  127. </if>
  128. <if test="updatedBy != null">
  129. updated_by = #{updatedBy,jdbcType=BIGINT},
  130. </if>
  131. <if test="updatedAt != null">
  132. updated_at = #{updatedAt,jdbcType=TIMESTAMP},
  133. </if>
  134. </set>
  135. </trim>
  136. WHERE gmpg_id = #{gmpgId,jdbcType=BIGINT}
  137. </update>
  138. <!--删除-->
  139. <delete id="delete">
  140. DELETE
  141. FROM s_group_member_position_grant
  142. WHERE 1 = 1
  143. <if test="gmpgId!= null">
  144. AND gmpg_id = #{gmpgId,jdbcType=BIGINT}
  145. </if>
  146. <if test="ocId != null">
  147. and oc_id = #{ocId}
  148. </if>
  149. <if test="groupId!= null">
  150. AND group_id = #{groupId,jdbcType=BIGINT}
  151. </if>
  152. <if test="accountId != null">
  153. AND account_id = #{accountId,jdbcType=BIGINT}
  154. </if>
  155. <if test="positionId != null">
  156. AND position_id = #{pId,jdbcType=BIGINT}
  157. </if>
  158. </delete>
  159. </mapper>