QueryConfigMapper.xml 13 KB

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