DatabaseConfigMapper.xml 4.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. <?xml version="1.0" encoding="UTF-8" ?>
  2. <!DOCTYPE mapper
  3. PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
  4. "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  5. <mapper namespace="com.xzl.web.mapper.DatabaseConfigMapper">
  6. <resultMap type="com.xzl.web.model.databaseConfig.DatabaseConfig" id="DatabaseConfigResult">
  7. <result property="id" column="id" />
  8. <result property="connectionName" column="connection_name" />
  9. <result property="databaseType" column="database_type" />
  10. <result property="driver" column="driver" />
  11. <result property="url" column="url" />
  12. <result property="username" column="username" />
  13. <result property="password" column="password" />
  14. <result property="tables" column="tables" />
  15. </resultMap>
  16. <sql id="selectDatabaseConfigVo">
  17. select id, connection_name, database_type, driver, url, username, password, tables from database_config
  18. </sql>
  19. <select id="selectDatabaseConfigList" parameterType="com.xzl.web.model.databaseConfig.DatabaseConfig" resultMap="DatabaseConfigResult">
  20. <include refid="selectDatabaseConfigVo"/>
  21. <where>
  22. <if test="connectionName != null and connectionName != ''"> and connection_name like concat('%', #{connectionName}, '%')</if>
  23. <if test="databaseType != null and databaseType != ''"> and database_type = #{databaseType}</if>
  24. <if test="driver != null and driver != ''"> and driver = #{driver}</if>
  25. <if test="url != null and url != ''"> and url = #{url}</if>
  26. <if test="username != null and username != ''"> and username like concat('%', #{username}, '%')</if>
  27. <if test="password != null and password != ''"> and password = #{password}</if>
  28. <if test="tables != null and tables != ''"> and tables = #{tables}</if>
  29. </where>
  30. </select>
  31. <select id="selectDatabaseConfigById" parameterType="Long" resultMap="DatabaseConfigResult">
  32. <include refid="selectDatabaseConfigVo"/>
  33. where id = #{id}
  34. </select>
  35. <insert id="insertDatabaseConfig" parameterType="com.xzl.web.model.databaseConfig.DatabaseConfig" useGeneratedKeys="true" keyProperty="id">
  36. insert into database_config
  37. <trim prefix="(" suffix=")" suffixOverrides=",">
  38. <if test="connectionName != null and connectionName != ''">connection_name,</if>
  39. <if test="databaseType != null and databaseType != ''">database_type,</if>
  40. <if test="driver != null and driver != ''">driver,</if>
  41. <if test="url != null and url != ''">url,</if>
  42. <if test="username != null and username != ''">username,</if>
  43. <if test="password != null and password != ''">password,</if>
  44. <if test="tables != null">tables,</if>
  45. </trim>
  46. <trim prefix="values (" suffix=")" suffixOverrides=",">
  47. <if test="connectionName != null and connectionName != ''">#{connectionName},</if>
  48. <if test="databaseType != null and databaseType != ''">#{databaseType},</if>
  49. <if test="driver != null and driver != ''">#{driver},</if>
  50. <if test="url != null and url != ''">#{url},</if>
  51. <if test="username != null and username != ''">#{username},</if>
  52. <if test="password != null and password != ''">#{password},</if>
  53. <if test="tables != null">#{tables},</if>
  54. </trim>
  55. </insert>
  56. <update id="updateDatabaseConfig" parameterType="com.xzl.web.model.databaseConfig.DatabaseConfig">
  57. update database_config
  58. <trim prefix="SET" suffixOverrides=",">
  59. <if test="connectionName != null and connectionName != ''">connection_name = #{connectionName},</if>
  60. <if test="databaseType != null and databaseType != ''">database_type = #{databaseType},</if>
  61. <if test="driver != null and driver != ''">driver = #{driver},</if>
  62. <if test="url != null and url != ''">url = #{url},</if>
  63. <if test="username != null and username != ''">username = #{username},</if>
  64. <if test="password != null and password != ''">password = #{password},</if>
  65. <if test="tables != null">tables = #{tables},</if>
  66. </trim>
  67. where id = #{id}
  68. </update>
  69. <delete id="deleteDatabaseConfigById" parameterType="Long">
  70. delete from database_config where id = #{id}
  71. </delete>
  72. <delete id="deleteDatabaseConfigByIds" parameterType="String">
  73. delete from database_config where id in
  74. <foreach item="id" collection="array" open="(" separator="," close=")">
  75. #{id}
  76. </foreach>
  77. </delete>
  78. </mapper>