1
0

QueryConfigMapper.xml 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325
  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.izouma.awesomeadmin.dao.QueryConfigMapper">
  4. <resultMap id="BaseResultMap" type="com.izouma.awesomeadmin.model.QueryConfig">
  5. <id column="id" property="id" jdbcType="INTEGER"/>
  6. <result column="del_flag" property="delFlag" jdbcType="CHAR"/>
  7. <result column="code" property="code" jdbcType="VARCHAR"/>
  8. <result column="table_name" property="tableName" jdbcType="VARCHAR"/>
  9. <result column="tableColumns" property="tablecolumns" jdbcType="VARCHAR"/>
  10. <result column="dataBaseType" property="databasetype" jdbcType="VARCHAR"/>
  11. <result column="modules" property="modules" jdbcType="VARCHAR"/>
  12. <result column="data_source_code" property="dataSourceCode" jdbcType="VARCHAR"/>
  13. </resultMap>
  14. <sql id="Base_Column_List">
  15. <trim suffixOverrides=",">
  16. id,
  17. del_flag,
  18. code,
  19. table_name,
  20. tableColumns,
  21. dataBaseType,
  22. modules,
  23. data_source_code,
  24. </trim>
  25. </sql>
  26. <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Integer">
  27. select
  28. <include refid="Base_Column_List"/>
  29. from query_config
  30. where id = #{id,jdbcType=INTEGER}
  31. </select>
  32. <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
  33. delete from query_config
  34. where id = #{id,jdbcType=INTEGER}
  35. </delete>
  36. <insert id="insertSelective" parameterType="com.izouma.awesomeadmin.model.QueryConfig" useGeneratedKeys="true"
  37. keyProperty="id">
  38. insert into query_config
  39. <trim prefix="(" suffix=")" suffixOverrides=",">
  40. <if test="id!= null">
  41. id,
  42. </if>
  43. <if test="delFlag!= null">
  44. del_flag,
  45. </if>
  46. <if test="code!= null">
  47. code,
  48. </if>
  49. <if test="tableName!= null">
  50. table_name,
  51. </if>
  52. <if test="tablecolumns!= null">
  53. tableColumns,
  54. </if>
  55. <if test="databasetype!= null">
  56. dataBaseType,
  57. </if>
  58. <if test="modules!= null">
  59. modules,
  60. </if>
  61. <if test="dataSourceCode!= null">
  62. data_source_code,
  63. </if>
  64. </trim>
  65. <trim prefix="values (" suffix=")" suffixOverrides=",">
  66. <if test="id != null">
  67. #{id,jdbcType=INTEGER},
  68. </if>
  69. <if test="delFlag != null">
  70. #{delFlag,jdbcType=CHAR},
  71. </if>
  72. <if test="code != null">
  73. #{code,jdbcType=VARCHAR},
  74. </if>
  75. <if test="tableName != null">
  76. #{tableName,jdbcType=VARCHAR},
  77. </if>
  78. <if test="tablecolumns != null">
  79. #{tablecolumns,jdbcType=VARCHAR},
  80. </if>
  81. <if test="databasetype != null">
  82. #{databasetype,jdbcType=VARCHAR},
  83. </if>
  84. <if test="modules != null">
  85. #{modules,jdbcType=VARCHAR},
  86. </if>
  87. <if test="dataSourceCode != null">
  88. #{dataSourceCode,jdbcType=VARCHAR},
  89. </if>
  90. </trim>
  91. </insert>
  92. <update id="updateByPrimaryKeySelective" parameterType="com.izouma.awesomeadmin.model.QueryConfig">
  93. update query_config
  94. <set>
  95. <if test="id != null">
  96. id= #{id,jdbcType=INTEGER},
  97. </if>
  98. <if test="delFlag != null">
  99. del_flag= #{delFlag,jdbcType=CHAR},
  100. </if>
  101. <if test="code != null">
  102. code= #{code,jdbcType=VARCHAR},
  103. </if>
  104. <if test="tableName != null">
  105. table_name= #{tableName,jdbcType=VARCHAR},
  106. </if>
  107. <if test="tablecolumns != null">
  108. tableColumns= #{tablecolumns,jdbcType=VARCHAR},
  109. </if>
  110. <if test="databasetype != null">
  111. dataBaseType= #{databasetype,jdbcType=VARCHAR},
  112. </if>
  113. <if test="modules != null">
  114. modules= #{modules,jdbcType=VARCHAR},
  115. </if>
  116. <if test="dataSourceCode != null">
  117. data_source_code= #{dataSourceCode,jdbcType=VARCHAR},
  118. </if>
  119. </set>
  120. where id = #{id,jdbcType=INTEGER}
  121. </update>
  122. <select id="queryQueryConfigByPage" parameterType="java.util.Map"
  123. resultType="com.izouma.awesomeadmin.model.QueryConfig">
  124. select
  125. <include refid="Base_Column_List"/>
  126. from query_config
  127. <where>
  128. and del_flag = 'N'
  129. <if test="record.id != null and !&quot;&quot;.equals(record.id)">
  130. and id = #{record.id}
  131. </if>
  132. <if test="record.delFlag != null and !&quot;&quot;.equals(record.delFlag)">
  133. and del_flag = #{record.delFlag}
  134. </if>
  135. <if test="record.code != null and !&quot;&quot;.equals(record.code)">
  136. and code = #{record.code}
  137. </if>
  138. <if test="record.tableName != null and !&quot;&quot;.equals(record.tableName)">
  139. and table_name = #{record.tableName}
  140. </if>
  141. <if test="record.tablecolumns != null and !&quot;&quot;.equals(record.tablecolumns)">
  142. and tableColumns = #{record.tablecolumns}
  143. </if>
  144. <if test="record.databasetype != null and !&quot;&quot;.equals(record.databasetype)">
  145. and dataBaseType = #{record.databasetype}
  146. </if>
  147. <if test="record.modules != null and !&quot;&quot;.equals(record.modules)">
  148. and modules = #{record.modules}
  149. </if>
  150. <if test="record.searchKey != null and !&quot;&quot;.equals(record.searchKey)">
  151. <trim prefix="and (" suffix=")" prefixOverrides="OR">
  152. OR code LIKE concat('%',#{record.searchKey},'%')
  153. OR table_name LIKE concat('%',#{record.searchKey},'%')
  154. OR tableColumns LIKE concat('%',#{record.searchKey},'%')
  155. OR dataBaseType LIKE concat('%',#{record.searchKey},'%')
  156. </trim>
  157. </if>
  158. <if test="record.advancedQuery != null and !&quot;&quot;.equals(record.advancedQuery)">
  159. <foreach item="item" index="index" collection="record.advancedQuery.split('_;')">
  160. <choose>
  161. <when test="item.indexOf('like') != -1">
  162. <foreach item="itemDetail" index="detailIndex" collection="item.split('_,')">
  163. <if test="detailIndex == 3">
  164. concat('%',#{itemDetail},'%')
  165. </if>
  166. <if test="detailIndex &lt; 3">
  167. ${itemDetail}
  168. </if>
  169. </foreach>
  170. </when>
  171. <otherwise>
  172. <foreach item="itemDetail" index="detailIndex" collection="item.split('_,')">
  173. <if test="detailIndex == 3">
  174. #{itemDetail}
  175. </if>
  176. <if test="detailIndex &lt; 3">
  177. ${itemDetail}
  178. </if>
  179. </foreach>
  180. </otherwise>
  181. </choose>
  182. </foreach>
  183. </if>
  184. </where>
  185. order by id desc
  186. </select>
  187. <select id="queryAllQueryConfig" parameterType="java.util.Map"
  188. resultType="com.izouma.awesomeadmin.model.QueryConfig">
  189. select
  190. <include refid="Base_Column_List"/>
  191. from query_config
  192. <where>
  193. and del_flag = 'N'
  194. <if test="id != null and !&quot;&quot;.equals(id)">
  195. and id = #{id}
  196. </if>
  197. <if test="delFlag != null and !&quot;&quot;.equals(delFlag)">
  198. and del_flag = #{delFlag}
  199. </if>
  200. <if test="code != null and !&quot;&quot;.equals(code)">
  201. and code = #{code}
  202. </if>
  203. <if test="tableName != null and !&quot;&quot;.equals(tableName)">
  204. and table_name = #{tableName}
  205. </if>
  206. <if test="tablecolumns != null and !&quot;&quot;.equals(tablecolumns)">
  207. and tableColumns = #{tablecolumns}
  208. </if>
  209. <if test="databasetype != null and !&quot;&quot;.equals(databasetype)">
  210. and dataBaseType = #{databasetype}
  211. </if>
  212. <if test="modules != null and !&quot;&quot;.equals(modules)">
  213. and modules = #{modules}
  214. </if>
  215. <if test="searchKey != null and !&quot;&quot;.equals(searchKey)">
  216. <trim prefix="and (" suffix=")" prefixOverrides="OR">
  217. OR code LIKE concat('%',#{searchKey},'%')
  218. OR table_name LIKE concat('%',#{searchKey},'%')
  219. OR tableColumns LIKE concat('%',#{searchKey},'%')
  220. OR dataBaseType LIKE concat('%',#{searchKey},'%')
  221. </trim>
  222. </if>
  223. <if test="advancedQuery != null and !&quot;&quot;.equals(advancedQuery)">
  224. <foreach item="item" index="index" collection="advancedQuery.split('_;')">
  225. <choose>
  226. <when test="item.indexOf('like') != -1">
  227. <foreach item="itemDetail" index="detailIndex" collection="item.split('_,')">
  228. <if test="detailIndex == 3">
  229. concat('%',#{itemDetail},'%')
  230. </if>
  231. <if test="detailIndex &lt; 3">
  232. ${itemDetail}
  233. </if>
  234. </foreach>
  235. </when>
  236. <otherwise>
  237. <foreach item="itemDetail" index="detailIndex" collection="item.split('_,')">
  238. <if test="detailIndex == 3">
  239. #{itemDetail}
  240. </if>
  241. <if test="detailIndex &lt; 3">
  242. ${itemDetail}
  243. </if>
  244. </foreach>
  245. </otherwise>
  246. </choose>
  247. </foreach>
  248. </if>
  249. </where>
  250. order by id desc
  251. </select>
  252. <select id="queryQueryConfig" parameterType="java.util.Map" resultType="com.izouma.awesomeadmin.model.QueryConfig">
  253. select
  254. <include refid="Base_Column_List"/>
  255. from query_config
  256. <where>
  257. and del_flag = 'N'
  258. <if test="id != null and !&quot;&quot;.equals(id)">
  259. and id = #{id}
  260. </if>
  261. <if test="delFlag != null and !&quot;&quot;.equals(delFlag)">
  262. and del_flag = #{delFlag}
  263. </if>
  264. <if test="code != null and !&quot;&quot;.equals(code)">
  265. and code = #{code}
  266. </if>
  267. <if test="tableName != null and !&quot;&quot;.equals(tableName)">
  268. and table_name = #{tableName}
  269. </if>
  270. <if test="tablecolumns != null and !&quot;&quot;.equals(tablecolumns)">
  271. and tableColumns = #{tablecolumns}
  272. </if>
  273. <if test="databasetype != null and !&quot;&quot;.equals(databasetype)">
  274. and dataBaseType = #{databasetype}
  275. </if>
  276. <if test="modules != null and !&quot;&quot;.equals(modules)">
  277. and modules = #{modules}
  278. </if>
  279. </where>
  280. LIMIT 1
  281. </select>
  282. <update id="delete">
  283. UPDATE query_config SET del_flag = 'Y'
  284. <where>
  285. AND id = #{id}
  286. </where>
  287. </update>
  288. <select id="query" parameterType="java.util.Map" resultType="com.izouma.awesomeadmin.model.QueryConfig">
  289. select
  290. <include refid="Base_Column_List"/>
  291. from query_config
  292. <where>
  293. and del_flag = 'N'
  294. </where>
  295. order by id desc
  296. </select>
  297. </mapper>