SysTableConfigMapper.xml 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174
  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.aidex.system.mapper.SysTableConfigMapper">
  4. <sql id="sysTableConfigColumns">
  5. table_key as "tableKey",
  6. user_id as "userId",
  7. space as "space",
  8. columns as "columns",
  9. remark as "remark",
  10. status as "status",
  11. id as "id",
  12. create_by as "createBy",
  13. create_dept as "createDept",
  14. create_time as "createTime",
  15. update_by as "updateBy",
  16. update_time as "updateTime",
  17. update_ip as "updateIp",
  18. version as "version",
  19. del_flag as "delFlag"
  20. </sql>
  21. <sql id="sysTableConfigJoins">
  22. </sql>
  23. <select id="get" resultType="SysTableConfig">
  24. SELECT
  25. <include refid="sysTableConfigColumns"/>
  26. FROM sys_table_config a
  27. <include refid="sysTableConfigJoins"/>
  28. WHERE a.id = #{id}
  29. </select>
  30. <select id="findList" resultType="SysTableConfig">
  31. SELECT
  32. <include refid="sysTableConfigColumns"/>
  33. FROM sys_table_config a
  34. <include refid="sysTableConfigJoins"/>
  35. <where>
  36. a.del_flag = #{DEL_FLAG_NORMAL}
  37. <if test="tableKey != null and tableKey != ''">
  38. and table_key = #{tableKey}
  39. </if>
  40. <if test="userId != null and userId != ''">
  41. and user_id = #{userId}
  42. </if>
  43. <if test="space != null and space != ''">
  44. and space like concat('%', #{space}, '%')
  45. </if>
  46. <if test="columns != null and columns != ''">
  47. and columns like concat('%', #{columns}, '%')
  48. </if>
  49. </where>
  50. <choose>
  51. <when test="page !=null and page.orderBy != null and page.orderBy != ''">
  52. ORDER BY ${page.orderBy}
  53. </when>
  54. <otherwise>
  55. ORDER BY a.create_time
  56. </otherwise>
  57. </choose>
  58. </select>
  59. <select id="findListWithUnique" resultType="SysTableConfig">
  60. SELECT
  61. a.id
  62. FROM sys_table_config a
  63. <include refid="sysTableConfigJoins"/>
  64. <where>
  65. a.del_flag = #{DEL_FLAG_NORMAL}
  66. <if test="notEqualId != null and notEqualId != ''">
  67. AND id != #{notEqualId}
  68. </if>
  69. </where>
  70. </select>
  71. <insert id="insert">
  72. INSERT INTO sys_table_config(
  73. table_key,
  74. user_id,
  75. space,
  76. columns,
  77. remark,
  78. status,
  79. id,
  80. create_by,
  81. create_dept,
  82. create_time,
  83. update_by,
  84. update_time,
  85. update_ip,
  86. version,
  87. del_flag
  88. ) VALUES (
  89. #{tableKey},
  90. #{userId},
  91. #{space},
  92. #{columns},
  93. #{remark},
  94. #{status},
  95. #{id},
  96. #{createBy},
  97. #{createDept},
  98. #{createTime},
  99. #{updateBy},
  100. #{updateTime},
  101. #{updateIp},
  102. #{version},
  103. #{delFlag}
  104. )
  105. </insert>
  106. <update id="update">
  107. UPDATE sys_table_config SET
  108. table_key = #{tableKey},
  109. user_id = #{userId},
  110. <if test="space != null and space != ''">space = #{space}, </if>
  111. columns = #{columns},
  112. <if test="remark != null and remark != ''">remark = #{remark}, </if>
  113. status = #{status},
  114. update_by = #{updateBy},
  115. update_time = #{updateTime},
  116. update_ip = #{updateIp},
  117. version = version + 1
  118. WHERE id = #{id} and version = #{version}
  119. </update>
  120. <update id="delete">
  121. UPDATE sys_table_config SET
  122. del_flag = #{DEL_FLAG_DELETE}
  123. WHERE id = #{id}
  124. </update>
  125. <delete id="deleteSysTableConfigByIds">
  126. UPDATE sys_table_config SET
  127. del_flag = #{DEL_FLAG_DELETE}
  128. WHERE id in
  129. <foreach item="tableKey" collection="array" open="(" separator="," close=")">
  130. #{tableKey}
  131. </foreach>
  132. </delete>
  133. <select id="getInfoByTableKey" resultType="SysTableConfig">
  134. SELECT
  135. <include refid="sysTableConfigColumns"/>,
  136. 'U' as configType
  137. FROM sys_table_config a
  138. <where>
  139. a.del_flag = #{DEL_FLAG_NORMAL}
  140. <if test="tableKey != null and tableKey != ''">
  141. and table_key = #{tableKey}
  142. </if>
  143. <if test="userId != null and userId != ''">
  144. and user_id = #{userId}
  145. </if>
  146. </where>
  147. <!--查询个人列配置时union all系统管理对应的配置,如果个人没有则使用管理员对应配置,用户管理员初始化全局配置-->
  148. union all
  149. SELECT
  150. <include refid="sysTableConfigColumns"/>,
  151. 'S' as configType
  152. FROM sys_table_config a
  153. <where>
  154. a.del_flag = #{DEL_FLAG_NORMAL}
  155. <if test="tableKey != null and tableKey != ''">
  156. and table_key = #{tableKey}
  157. </if>
  158. and user_id = '1'
  159. </where>
  160. </select>
  161. </mapper>