<?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.devplatform.transfer.modules.datasource.dao.SysDatasourceDao">
  <!-- Result Map -->
  <resultMap id="BaseResultMap" type="com.devplatform.transfer.modules.datasource.bean.SysDatasource">
    <result column="id" property="id"/>
    <result column="url" property="url"/>
    <result column="username" property="username"/>
    <result column="password" property="password"/>
    <result column="ip" property="ip"/>
    <result column="port" property="port"/>
    <result column="detail" property="detail"/>
    <result column="type" property="type"/>
    <result column="deleted" property="deleted"/>
    <result column="create_user_id" property="createUserId"/>
    <result column="create_time" property="createTime"/>
    <result column="update_user_id" property="updateUserId"/>
    <result column="update_time" property="updateTime"/>
    <result column="byx1" property="byx1"/>
    <result column="byx2" property="byx2"/>
    <result column="byx3" property="byx3"/>
  </resultMap>

  <!-- sys_datasource table all fields -->
  <sql id="Base_Column_List">
        `id`,`url`,`username`,`PASSWORD`,`ip`,`PORT`,
        `detail`,type,deleted,create_user_id,create_time,update_user_id,update_time,byx1,byx2,byx3
    </sql>

  <!-- 公共查询条件 -->
  <sql id="Example_Where_Clause">
    where deleted=0
    <if test="params.id!=null and params.id!=''">and `id` = #{params.id}</if>
    <if test="params.url!=null and params.url!=''">and INSTR(`url`, #{params.url})</if>
    <if test="params.username!=null and params.username!=''">and INSTR(`username`, #{params.username})</if>
    <if test="params.password!=null and params.password!=''">and `password` = #{params.password}</if>
    <if test="params.ip!=null and params.ip!=''">and INSTR(`ip`, #{params.ip})</if>
    <if test="params.port!=null and params.port!=''">and `port` = #{params.port}</if>
    <if test="params.detail!=null and params.detail!=''">and INSTR(`detail`, #{params.detail})</if>
    <if test="params.type!=null ">and `type` = #{params.type}</if>
    <if test="params.deleted!=null ">and `deleted` = #{params.deleted}</if>
    <if test="params.createUserId!=null and params.createUserId!=''">and `create_user_id` = #{params.createUserId}</if>
    <if test="params.createTime!=null ">and `create_time` = #{params.createTime}</if>
    <if test="params.updateUserId!=null and updateUserId!=''">and `update_user_id` = #{params.updateUserId}</if>
    <if test="params.updateTime!=null ">and `update_time` = #{params.updateTime}</if>
    <if test="params.byx1!=null and params.byx1!=''">and byx1 = #{params.byx1}</if>
    <if test="params.byx2!=null and params.byx2!=''">and byx2 = #{params.byx2}</if>
    <if test="params.byx3!=null and params.byx3!=''">and byx3 = #{params.byx3}</if>
  </sql>
  <select id="getListPage" resultType="com.devplatform.transfer.modules.datasource.bean.SysDatasource">
    SELECT
    <include refid="Base_Column_List"/>
    FROM sys_datasource sd
    <include refid="Example_Where_Clause"/>
    <if test="params.sort != null and params.sort != '' and params.order != null and params.order != ''">
      ORDER BY ${params.sort} ${params.order}
    </if>
  </select>
  <select id="getList" resultType="com.devplatform.transfer.modules.datasource.bean.SysDatasource">
    SELECT
    <include refid="Base_Column_List"/>
    FROM sys_datasource sd
    <include refid="Example_Where_Clause"/>
    <if test="params.sort != null and params.sort != '' and params.order != null and params.order != ''">
      ORDER BY ${params.sort} ${params.order}
    </if>
  </select>


</mapper>


