PositionPermitMapper.xml 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  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.PositionPermitMapper">
  5. <resultMap id="PermitDtoResultMap" type="com.zhyc.xps.sys.dto.PositionPermitDto" >
  6. <result column="oc_id" property="ocId" jdbcType="BIGINT"/>
  7. <result column="position_id" property="positionId" jdbcType="BIGINT"/>
  8. <result column="permit_id" property="permitId" jdbcType="BIGINT"/>
  9. <result column="permit_code" property="permitCode" jdbcType="VARCHAR"/>
  10. </resultMap>
  11. <sql id="Ext_Column_List">
  12. A.oc_id,
  13. A.position_id,
  14. A.permit_id,
  15. B.permit_code
  16. </sql>
  17. <!--基于ID查询-->
  18. <select id="getById" resultMap="PermitDtoResultMap" >
  19. SELECT
  20. <include refid="Ext_Column_List"/>
  21. FROM s_position_permit AS A
  22. LEFT JOIN s_role_permit AS B ON (A.permit_id = B.permit_id)
  23. WHERE 1 = 1
  24. <if test="ocId != null">
  25. AND A.oc_id = #{ocId,jdbcType=BIGINT}
  26. </if>
  27. <if test="positionId != null">
  28. AND A.position_id = #{positionId,jdbcType=BIGINT}
  29. </if>
  30. <if test="permitId != null">
  31. AND A.permit_id = #{permitId ,jdbcType=BIGINT}
  32. </if>
  33. </select>
  34. <!--列表查询-->
  35. <select id="getByList" parameterType="java.util.Map" resultMap="PermitDtoResultMap">
  36. SELECT
  37. <include refid="Ext_Column_List"/>
  38. FROM s_position_permit AS A
  39. LEFT JOIN s_role_permit AS B ON (A.permit_id = B.permit_id)
  40. WHERE 1 = 1
  41. <if test="ocId != null">
  42. AND A.oc_id = #{ocId,jdbcType=BIGINT}
  43. </if>
  44. <if test="positionId != null">
  45. AND A.position_id = #{positionId,jdbcType=BIGINT}
  46. </if>
  47. <if test="permitId != null">
  48. AND A.permit_id = #{permitId ,jdbcType=BIGINT}
  49. </if>
  50. <if test="clientId != null">
  51. AND B.client_id = #{clientId ,jdbcType=BIGINT}
  52. </if>
  53. </select>
  54. <!--新增-->
  55. <insert id="create" parameterType="com.zhyc.xps.sys.entity.PositionPermit">
  56. INSERT INTO s_position_permit
  57. <trim prefix="(" suffix=")" suffixOverrides=",">
  58. <if test="ocId != null">
  59. oc_id,
  60. </if>
  61. <if test="positionId != null">
  62. position_id,
  63. </if>
  64. <if test="permitId != null">
  65. permit_id,
  66. </if>
  67. </trim>
  68. <trim prefix="values (" suffix=")" suffixOverrides=",">
  69. <if test="ocId != null">
  70. #{ocId ,jdbcType=BIGINT},
  71. </if>
  72. <if test="positionId != null">
  73. #{positionId ,jdbcType=BIGINT},
  74. </if>
  75. <if test="permitId != null">
  76. #{permitId ,jdbcType=BIGINT},
  77. </if>
  78. </trim>
  79. </insert>
  80. <!--删除-->
  81. <delete id="delete" parameterType="java.util.Map">
  82. DELETE
  83. FROM s_position_permit
  84. WHERE 1 = 1
  85. <if test="ocId != null">
  86. AND oc_id = #{ocId, jdbcType=BIGINT}
  87. </if>
  88. <if test="permitId != null">
  89. AND permit_id = #{permitId, jdbcType=BIGINT}
  90. </if>
  91. <if test="positionId != null">
  92. AND position_id = #{positionId, jdbcType=BIGINT}
  93. </if>
  94. </delete>
  95. <resultMap id="PermitVoResultMap" type="com.zhyc.xps.sys.vo.PermitVo" >
  96. <result column="permit_id" property="permitId" jdbcType="BIGINT" />
  97. <result column="permit_title" property="permitTitle" jdbcType="VARCHAR"/>
  98. <result column="permit_code" property="permitCode" jdbcType="VARCHAR"/>
  99. <result column="permit_desc" property="permitDesc" jdbcType="VARCHAR"/>
  100. <result column="permit_type" property="permitType" jdbcType="BIGINT" />
  101. <result column="parent_id" property="parentId" jdbcType="BIGINT" />
  102. <result column="root_id" property="rootId" jdbcType="BIGINT" />
  103. <result column="position_permitted" property="positionPermitted" jdbcType="BIGINT" />
  104. <result column="account_permitted" property="accountPermitted" jdbcType="BIGINT" />
  105. </resultMap>
  106. <!--列表查询-->
  107. <select id="getViewByList" resultMap="PermitVoResultMap" >
  108. SELECT
  109. A.permit_id,
  110. A.permit_title,
  111. A.permit_code,
  112. A.permit_desc,
  113. A.permit_type,
  114. A.parent_id,
  115. A.root_id,
  116. IFNULL(CASE WHEN B.permit_id > 0 THEN 1 ELSE 0 END, 0) AS position_permitted
  117. FROM s_role_permit AS A
  118. LEFT JOIN s_position_permit AS B ON (A.permit_id = B.permit_id AND B.oc_id=#{ocId} AND B.position_id=#{positionId})
  119. WHERE 1 = 1
  120. <if test="clientId != null">
  121. AND A.client_id = #{clientId,jdbcType=BIGINT}
  122. </if>
  123. <if test="roleId != null">
  124. AND A.role_id = #{roleId,jdbcType=BIGINT}
  125. </if>
  126. ORDER BY A.parent_id ASC ,A.sort_no ASC
  127. </select>
  128. </mapper>