1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586 |
- <?xml version="1.0" encoding="UTF-8" ?>
- <!DOCTYPE mapper
- PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
- "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
- <mapper namespace="com.xzl.web.mapper.DatabaseConfigMapper">
-
- <resultMap type="com.xzl.web.model.databaseConfig.DatabaseConfig" id="DatabaseConfigResult">
- <result property="id" column="id" />
- <result property="connectionName" column="connection_name" />
- <result property="databaseType" column="database_type" />
- <result property="driver" column="driver" />
- <result property="url" column="url" />
- <result property="username" column="username" />
- <result property="password" column="password" />
- <result property="tables" column="tables" />
- </resultMap>
- <sql id="selectDatabaseConfigVo">
- select id, connection_name, database_type, driver, url, username, password, tables from database_config
- </sql>
- <select id="selectDatabaseConfigList" parameterType="com.xzl.web.model.databaseConfig.DatabaseConfig" resultMap="DatabaseConfigResult">
- <include refid="selectDatabaseConfigVo"/>
- <where>
- <if test="connectionName != null and connectionName != ''"> and connection_name like concat('%', #{connectionName}, '%')</if>
- <if test="databaseType != null and databaseType != ''"> and database_type = #{databaseType}</if>
- <if test="driver != null and driver != ''"> and driver = #{driver}</if>
- <if test="url != null and url != ''"> and url = #{url}</if>
- <if test="username != null and username != ''"> and username like concat('%', #{username}, '%')</if>
- <if test="password != null and password != ''"> and password = #{password}</if>
- <if test="tables != null and tables != ''"> and tables = #{tables}</if>
- </where>
- </select>
-
- <select id="selectDatabaseConfigById" parameterType="Long" resultMap="DatabaseConfigResult">
- <include refid="selectDatabaseConfigVo"/>
- where id = #{id}
- </select>
-
- <insert id="insertDatabaseConfig" parameterType="com.xzl.web.model.databaseConfig.DatabaseConfig" useGeneratedKeys="true" keyProperty="id">
- insert into database_config
- <trim prefix="(" suffix=")" suffixOverrides=",">
- <if test="connectionName != null and connectionName != ''">connection_name,</if>
- <if test="databaseType != null and databaseType != ''">database_type,</if>
- <if test="driver != null and driver != ''">driver,</if>
- <if test="url != null and url != ''">url,</if>
- <if test="username != null and username != ''">username,</if>
- <if test="password != null and password != ''">password,</if>
- <if test="tables != null">tables,</if>
- </trim>
- <trim prefix="values (" suffix=")" suffixOverrides=",">
- <if test="connectionName != null and connectionName != ''">#{connectionName},</if>
- <if test="databaseType != null and databaseType != ''">#{databaseType},</if>
- <if test="driver != null and driver != ''">#{driver},</if>
- <if test="url != null and url != ''">#{url},</if>
- <if test="username != null and username != ''">#{username},</if>
- <if test="password != null and password != ''">#{password},</if>
- <if test="tables != null">#{tables},</if>
- </trim>
- </insert>
- <update id="updateDatabaseConfig" parameterType="com.xzl.web.model.databaseConfig.DatabaseConfig">
- update database_config
- <trim prefix="SET" suffixOverrides=",">
- <if test="connectionName != null and connectionName != ''">connection_name = #{connectionName},</if>
- <if test="databaseType != null and databaseType != ''">database_type = #{databaseType},</if>
- <if test="driver != null and driver != ''">driver = #{driver},</if>
- <if test="url != null and url != ''">url = #{url},</if>
- <if test="username != null and username != ''">username = #{username},</if>
- <if test="password != null and password != ''">password = #{password},</if>
- <if test="tables != null">tables = #{tables},</if>
- </trim>
- where id = #{id}
- </update>
- <delete id="deleteDatabaseConfigById" parameterType="Long">
- delete from database_config where id = #{id}
- </delete>
- <delete id="deleteDatabaseConfigByIds" parameterType="String">
- delete from database_config where id in
- <foreach item="id" collection="array" open="(" separator="," close=")">
- #{id}
- </foreach>
- </delete>
- </mapper>
|