UmsAdminRoleRelationDao.xml 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  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.macro.mall.dao.UmsAdminRoleRelationDao">
  4. <!--批量新增回写主键支持-->
  5. <insert id="insertList">
  6. INSERT INTO ums_admin_role_relation (admin_id, role_id) VALUES
  7. <foreach collection="list" separator="," item="item" index="index">
  8. (#{item.adminId,jdbcType=BIGINT},
  9. #{item.roleId,jdbcType=BIGINT})
  10. </foreach>
  11. </insert>
  12. <select id="getRoleList" resultMap="com.macro.mall.mapper.UmsRoleMapper.BaseResultMap">
  13. select r.*
  14. from ums_admin_role_relation ar left join ums_role r on ar.role_id = r.id
  15. where ar.admin_id = #{adminId}
  16. </select>
  17. <select id="getRolePermissionList" resultMap="com.macro.mall.mapper.UmsPermissionMapper.BaseResultMap">
  18. select p.*
  19. from ums_admin_role_relation ar left join ums_role r on ar.role_id = r.id
  20. left join ums_role_permission_relation rp on r.id = rp.role_id
  21. left join ums_permission p on rp.permission_id=p.id
  22. where ar.admin_id = #{adminId} and p.id is not null
  23. </select>
  24. <select id="getPermissionList" resultMap="com.macro.mall.mapper.UmsPermissionMapper.BaseResultMap">
  25. SELECT
  26. p.*
  27. FROM
  28. ums_admin_role_relation ar
  29. LEFT JOIN ums_role r ON ar.role_id = r.id
  30. LEFT JOIN ums_role_permission_relation rp ON r.id = rp.role_id
  31. LEFT JOIN ums_permission p ON rp.permission_id = p.id
  32. WHERE
  33. ar.admin_id = #{adminId}
  34. AND p.id IS NOT NULL
  35. AND p.id NOT IN (
  36. SELECT
  37. p.id
  38. FROM
  39. ums_admin_permission_relation pr
  40. LEFT JOIN ums_permission p ON pr.permission_id = p.id
  41. WHERE
  42. pr.type = - 1
  43. AND pr.admin_id = #{adminId}
  44. )
  45. UNION
  46. SELECT
  47. p.*
  48. FROM
  49. ums_admin_permission_relation pr
  50. LEFT JOIN ums_permission p ON pr.permission_id = p.id
  51. WHERE
  52. pr.type = 1
  53. AND pr.admin_id = #{adminId}
  54. </select>
  55. </mapper>