SaasProductPageMapper.xml 4.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  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.persagy.account.mapper.SaasProductPageMapper">
  4. <resultMap id="BaseResultMap" type="com.persagy.account.pojo.dto.SaasProductPage">
  5. <result column="ID" property="id" jdbcType="VARCHAR" />
  6. <result column="PRODUCT_ID" property="productId" jdbcType="VARCHAR" />
  7. <result column="PARENT_ID" property="parentId" jdbcType="VARCHAR" />
  8. <result column="PAGE_NAME" property="pageName" jdbcType="VARCHAR" />
  9. <result column="PAGE_ICON" property="pageIcon" jdbcType="VARCHAR" />
  10. <result column="PAGE_URL" property="pageUrl" jdbcType="VARCHAR" />
  11. <result column="PAGE_ANGLE" property="pageAngle" jdbcType="VARCHAR" />
  12. <result column="PAGE_FLOOR" property="pageFloor" jdbcType="VARCHAR" />
  13. <result column="PAGE_LEVEL" property="pageLevel" jdbcType="INTEGER" />
  14. <result column="CREATE_TIME" property="createTime" jdbcType="DATE" />
  15. <result column="UPDATE_TIME" property="updateTime" jdbcType="DATE" />
  16. <result column="UPDATE_USER" property="updateUser" jdbcType="VARCHAR" />
  17. <result column="REMARK" property="remark" jdbcType="VARCHAR" />
  18. </resultMap>
  19. <sql id="Base_Sql_Column">
  20. ID, PRODUCT_ID, PARENT_ID, PAGE_NAME, PAGE_ICON, PAGE_URL, PAGE_ANGLE, PAGE_FLOOR, PAGE_LEVEL, CREATE_TIME, UPDATE_TIME, UPDATE_USER, REMARK
  21. </sql>
  22. <select id="queryGroupProductPages" resultMap="BaseResultMap">
  23. SELECT M.* FROM (SELECT ID FROM saas_group_product
  24. <where>
  25. <if test="groupCode != null and groupCode.trim().length() != 0">AND GROUP_CODE = #{groupCode}</if>
  26. <if test="productId != null and productId.trim().length() != 0">AND PRODUCT_ID = #{productId}</if>
  27. </where>) M JOIN saas_group_product_detail N ON M.ID = N.CONTRACT_ID
  28. JOIN (SELECT <include refid="Base_Sql_Column"></include> FROM saas_product_page
  29. <where>
  30. <if test="productId != null and productId.trim().length() != 0">AND PRODUCT_ID = #{productId}</if>
  31. <choose>
  32. <when test="angle != null and angle == '1'">AND PAGE_ANGLE IN ('0', '1')</when>
  33. <when test="angle != null and angle == '2'">AND PAGE_ANGLE IN ('0', '2')</when>
  34. </choose>
  35. </where>) P ON P.ID = N.PAGE_ID
  36. </select>
  37. <select id="queryProjectProductPages" resultMap="BaseResultMap">
  38. SELECT M.* FROM (SELECT ID FROM saas_project_product
  39. <where>
  40. <if test="groupCode != null and groupCode.trim().length() != 0">AND GROUP_CODE = #{groupCode}</if>
  41. <if test="projectId != null and projectId.trim().length() != 0">AND PROJECT_ID = #{projectId}</if>
  42. <if test="productId != null and productId.trim().length() != 0">AND PRODUCT_ID = #{productId}</if>
  43. </where>) M JOIN saas_group_product_detail N ON M.CONTRACT_ID = N.CONTRACT_ID
  44. JOIN (SELECT <include refid="Base_Sql_Column"></include> FROM saas_product_page
  45. <where>
  46. <if test="productId != null and productId.trim().length() != 0">AND PRODUCT_ID = #{productId}</if>
  47. <choose>
  48. <when test="angle != null and angle == '1'">AND PAGE_ANGLE IN ('0', '1')</when>
  49. <when test="angle != null and angle == '2'">AND PAGE_ANGLE IN ('0', '2')</when>
  50. </choose>
  51. </where>) P ON P.ID = N.PAGE_ID
  52. </select>
  53. <select id="queryAccountProductPages" resultMap="BaseResultMap">
  54. SELECT * FROM (SELECT <include refid="Base_Sql_Column"></include> FROM saas_product_page
  55. <where>
  56. <if test="productId != null and productId.trim().length() != 0">AND PRODUCT_ID = #{productId}</if>
  57. <if test="parentId != null and parentId.trim().length() != 0">AND PARENT_ID = #{parentId}</if>
  58. <choose>
  59. <when test="angle != null and angle == '1'">AND PAGE_ANGLE IN ('0', '1')</when>
  60. <when test="angle != null and angle == '2'">AND PAGE_ANGLE IN ('0', '2')</when>
  61. </choose>
  62. </where>) M
  63. <!-- JOIN 内容为权限过滤数据 -->
  64. JOIN (SELECT DISTINCT Q.PAGE_ID FROM (SELECT ROLE_ID FROM saas_account_role
  65. <where>
  66. <if test="accountId != null and accountId.trim().length() != 0">AND ACCOUNT_ID = #{accountId}</if>
  67. </where>) P
  68. JOIN (SELECT ROLE_ID, PAGE_ID FROM saas_role_menu
  69. <where>
  70. <if test="menuId != null and menuId.trim().length() != 0">AND MENU_ID = #{menuId}</if>
  71. </where>) Q ON P.ROLE_ID = Q.ROLE_ID) N ON M.ID = N.PAGE_ID
  72. </select>
  73. </mapper>