<?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="me.zhengjie.modules.maint.mapper.DatabaseMapper">
    <resultMap id="BaseResultMap" type="me.zhengjie.modules.maint.domain.Database">
        <id column="db_id" property="id"/>
        <result column="name" property="name"/>
        <result column="jdbc_url" property="jdbcUrl"/>
        <result column="pwd" property="pwd"/>
        <result column="user_name" property="userName"/>
        <result column="create_by" property="createBy"/>
        <result column="update_by" property="updateBy"/>
        <result column="create_time" property="createTime"/>
        <result column="update_time" property="updateTime"/>
    </resultMap>

    <sql id="Base_Column_List">
        db_id, name, jdbc_url, pwd, user_name, create_by, update_by, create_time, update_time
    </sql>

    <select id="findAll" resultMap="BaseResultMap">
        SELECT
        <include refid="Base_Column_List"/>
        FROM mnt_database
        <where>
            <if test="criteria.name != null and criteria.name != ''">
                AND name LIKE CONCAT('%',#{criteria.name},'%')
            </if>
            <if test="criteria.jdbcUrl != null and criteria.jdbcUrl != ''">
                AND jdbc_url = #{criteria.jdbcUrl}
            </if>
            <if test="criteria.createTime != null and criteria.createTime.size() != 0">
                AND create_time BETWEEN #{criteria.createTime[0]} AND #{criteria.createTime[1]}
            </if>
        </where>
    </select>
</mapper>