DataSourceInfoMapper.xml 15 KB

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