DataRuleMapper.xml 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  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.jeeplus.modules.sys.mapper.DataRuleMapper">
  4. <sql id="dataRuleColumns">
  5. a.id AS "id",
  6. a.menu_id AS "menuId",
  7. a.name AS "name",
  8. a.className AS "className",
  9. a.t_field AS "field",
  10. a.t_express AS "express",
  11. a.t_value AS "value",
  12. a.sql_segment AS "sqlSegment",
  13. a.remarks AS "remarks",
  14. a.del_flag AS "delFlag"
  15. </sql>
  16. <sql id="dataRuleJoins">
  17. </sql>
  18. <select id="get" resultType="DataRule" >
  19. SELECT
  20. <include refid="dataRuleColumns"/>
  21. FROM sys_datarule a
  22. <include refid="dataRuleJoins"/>
  23. WHERE a.id = #{id}
  24. </select>
  25. <select id="findList" resultType="DataRule" >
  26. SELECT
  27. <include refid="dataRuleColumns"/>
  28. FROM sys_datarule a
  29. <include refid="dataRuleJoins"/>
  30. <where>
  31. a.del_flag = #{DEL_FLAG_NORMAL}
  32. <if test="name != null and name != ''">
  33. AND a.name LIKE
  34. <if test="dbName == 'oracle'">'%'||#{name}||'%'</if>
  35. <if test="dbName == 'mssql'">'%'+#{name}+'%'</if>
  36. <if test="dbName == 'mysql'">concat('%',#{name},'%')</if>
  37. </if>
  38. <if test="menuId != null and menuId != ''">
  39. AND a.menu_id =#{menuId}
  40. </if>
  41. </where>
  42. <choose>
  43. <when test="page !=null and page.orderBy != null and page.orderBy != ''">
  44. ORDER BY ${page.orderBy}
  45. </when>
  46. <otherwise>
  47. </otherwise>
  48. </choose>
  49. </select>
  50. <select id="findByUserId" resultType="DataRule">
  51. SELECT DISTINCT
  52. <include refid="dataRuleColumns"/>
  53. FROM sys_datarule a
  54. JOIN sys_role_datarule rd ON rd.datarule_id = a.id
  55. JOIN sys_role r ON r.id = rd.role_id AND r.useable='1'
  56. JOIN sys_user_role ur ON ur.role_id = r.id
  57. JOIN sys_user u ON u.id = ur.user_id AND u.id = #{id}
  58. WHERE a.del_flag = #{DEL_FLAG_NORMAL} AND r.del_flag = #{DEL_FLAG_NORMAL} AND u.del_flag = #{DEL_FLAG_NORMAL}
  59. </select>
  60. <select id="findAllList" resultType="DataRule" >
  61. SELECT
  62. <include refid="dataRuleColumns"/>
  63. FROM sys_datarule a
  64. <include refid="dataRuleJoins"/>
  65. <where>
  66. a.del_flag = #{DEL_FLAG_NORMAL}
  67. </where>
  68. <choose>
  69. <when test="page !=null and page.orderBy != null and page.orderBy != ''">
  70. ORDER BY ${page.orderBy}
  71. </when>
  72. <otherwise>
  73. </otherwise>
  74. </choose>
  75. </select>
  76. <insert id="insert">
  77. INSERT INTO sys_datarule(
  78. id,
  79. menu_id,
  80. name,
  81. className,
  82. t_field,
  83. t_express,
  84. t_value,
  85. sql_segment,
  86. remarks,
  87. del_flag
  88. ) VALUES (
  89. #{id},
  90. #{menuId},
  91. #{name},
  92. #{className},
  93. #{field},
  94. #{express},
  95. #{value},
  96. #{sqlSegment},
  97. #{remarks},
  98. #{delFlag}
  99. )
  100. </insert>
  101. <update id="update">
  102. UPDATE sys_datarule SET
  103. menu_id = #{menuId},
  104. name = #{name},
  105. className = #{className},
  106. t_field = #{field},
  107. t_express = #{express},
  108. t_value = #{value},
  109. sql_segment = #{sqlSegment},
  110. remarks = #{remarks}
  111. WHERE id = #{id}
  112. </update>
  113. <!--物理删除-->
  114. <update id="delete">
  115. DELETE FROM sys_datarule
  116. WHERE id = #{id}
  117. </update>
  118. <update id="deleteRoleDataRule">
  119. DELETE FROM sys_role_datarule
  120. WHERE datarule_id = #{id}
  121. </update>
  122. <!--逻辑删除-->
  123. <update id="deleteByLogic">
  124. UPDATE sys_datarule SET
  125. del_flag = #{DEL_FLAG_DELETE}
  126. WHERE id = #{id}
  127. </update>
  128. <!-- 根据实体名称和字段名称和字段值获取唯一记录 -->
  129. <select id="findUniqueByProperty" resultType="DataRule" statementType="STATEMENT">
  130. select * FROM sys_datarule where ${propertyName} = '${value}'
  131. </select>
  132. </mapper>