<?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.hzya.frame.sys.dataSource.dao.impl.SysDataSourceDaoImpl">

    <resultMap id="get-SysDataSourceEntity-result" type="com.hzya.frame.sys.dataSource.entity.SysDataSourceEntity">
        <result property="id" column="id" jdbcType="VARCHAR"/>
        <result property="sourceCode" column="source_code" jdbcType="VARCHAR"/>
        <result property="sourceName" column="source_name" jdbcType="VARCHAR"/>
        <result property="sourceIp" column="source_ip" jdbcType="VARCHAR"/>
        <result property="sourcePort" column="source_port" jdbcType="VARCHAR"/>
        <result property="dbName" column="db_name" jdbcType="VARCHAR"/>
        <result property="sourceType" column="source_type" jdbcType="VARCHAR"/>
        <result property="loginName" column="login_name" jdbcType="VARCHAR"/>
        <result property="password" column="password" jdbcType="VARCHAR"/>
        <result property="serviceName" column="service_name" jdbcType="VARCHAR"/>
        <result property="useState" column="use_state" jdbcType="INTEGER"/>
        <result property="dataState" column="data_state" jdbcType="INTEGER"/>
        <result property="sorts" column="sorts" jdbcType="INTEGER"/>
        <result property="create_user_id" column="create_user_id" jdbcType="VARCHAR"/>
        <result property="create_time" column="create_time" jdbcType="TIMESTAMP"/>
        <result property="modify_user_id" column="modify_user_id" jdbcType="VARCHAR"/>
        <result property="modify_time" column="modify_time" jdbcType="TIMESTAMP"/>
        <result property="sts" column="sts" jdbcType="VARCHAR"/>
        <result property="org_id" column="org_id" jdbcType="VARCHAR"/>
    </resultMap>
    <!-- 查询的字段-->
    <sql id="SysDataSourceEntity_Base_Column_List">
        id
       ,source_code 
        ,source_name 
        ,source_ip 
        ,source_port 
        ,db_name 
        ,source_type 
        ,login_name 
        ,password 
        ,service_name 
        ,use_state 
        ,data_state
        ,sorts
        ,create_user_id 
        ,create_time 
        ,modify_user_id 
        ,modify_time 
        ,sts 
        ,org_id 
     </sql>
    <!-- 查询 采用==查询 -->
    <select id="entity_list_base" resultMap="get-SysDataSourceEntity-result"
            parameterType="com.hzya.frame.sys.dataSource.entity.SysDataSourceEntity">
        select
        <include refid="SysDataSourceEntity_Base_Column_List"/>
        from sys_data_source
        <trim prefix="where" prefixOverrides="and">
            <if test="id != null and id != ''">and id = #{id}</if>
            <if test="sourceCode != null and sourceCode != ''">and source_code = #{sourceCode}</if>
            <if test="sourceName != null and sourceName != ''">and source_name = #{sourceName}</if>
            <if test="sourceIp != null and sourceIp != ''">and source_ip = #{sourceIp}</if>
            <if test="sourcePort != null and sourcePort != ''">and source_port = #{sourcePort}</if>
            <if test="dbName != null and dbName != ''">and db_name = #{dbName}</if>
            <if test="sourceType != null and sourceType != ''">and source_type = #{sourceType}</if>
            <if test="loginName != null and loginName != ''">and login_name = #{loginName}</if>
            <if test="password != null and password != ''">and password = #{password}</if>
            <if test="serviceName != null and serviceName != ''">and service_name = #{serviceName}</if>
            <if test="useState != null">and use_state = #{useState}</if>
            <if test="dataState != null">and data_state = #{dataState}</if>
            <if test="sorts != null">and sorts = #{sorts}</if>
            <if test="create_user_id != null and create_user_id != ''">and create_user_id = #{create_user_id}</if>
            <if test="create_time != null">and create_time = #{create_time}</if>
            <if test="modify_user_id != null and modify_user_id != ''">and modify_user_id = #{modify_user_id}</if>
            <if test="modify_time != null">and modify_time = #{modify_time}</if>
            <if test="sts != null and sts != ''">and sts = #{sts}</if>
            <if test="org_id != null and org_id != ''">and org_id = #{org_id}</if>
            and sts='Y'
        </trim>
        <if test=" sort == null or sort == ''.toString() ">order by sorts asc</if>
        <if test=" sort !='' and sort!=null and order !='' and order!=null ">order by ${sort} ${order}</if>
    </select>

    <!-- 查询 采用==查询 -->
    <select id="entity_count_not_id" resultType="Integer"
            parameterType="com.hzya.frame.sys.dataSource.entity.SysDataSourceEntity">
        select
        count(1)
        from sys_data_source
        <trim prefix="where" prefixOverrides="and">
            <if test="id != null and id != ''">and id != #{id}</if>
            <if test="sourceCode != null and sourceCode != ''">and source_code = #{sourceCode}</if>
            <if test="sourceName != null and sourceName != ''">and source_name = #{sourceName}</if>
            <if test="sourceIp != null and sourceIp != ''">and source_ip = #{sourceIp}</if>
            <if test="sourcePort != null and sourcePort != ''">and source_port = #{sourcePort}</if>
            <if test="dbName != null and dbName != ''">and db_name = #{dbName}</if>
            <if test="sourceType != null and sourceType != ''">and source_type = #{sourceType}</if>
            <if test="loginName != null and loginName != ''">and login_name = #{loginName}</if>
            <if test="password != null and password != ''">and password = #{password}</if>
            <if test="serviceName != null and serviceName != ''">and service_name = #{serviceName}</if>
            <if test="useState != null">and use_state = #{useState}</if>
            <if test="dataState != null">and data_state = #{dataState}</if>
            <if test="sorts != null">and sorts = #{sorts}</if>
            <if test="create_user_id != null and create_user_id != ''">and create_user_id = #{create_user_id}</if>
            <if test="create_time != null">and create_time = #{create_time}</if>
            <if test="modify_user_id != null and modify_user_id != ''">and modify_user_id = #{modify_user_id}</if>
            <if test="modify_time != null">and modify_time = #{modify_time}</if>
            <if test="sts != null and sts != ''">and sts = #{sts}</if>
            <if test="org_id != null and org_id != ''">and org_id = #{org_id}</if>
            and sts='Y'
        </trim>
    </select>

    <!-- 查询符合条件的数量 -->
    <select id="entity_count" resultType="Integer"
            parameterType="com.hzya.frame.sys.dataSource.entity.SysDataSourceEntity">
        select count(1) from sys_data_source
        <trim prefix="where" prefixOverrides="and">
            <if test="id != null and id != ''">and id = #{id}</if>
            <if test="sourceCode != null and sourceCode != ''">and source_code = #{sourceCode}</if>
            <if test="sourceName != null and sourceName != ''">and source_name = #{sourceName}</if>
            <if test="sourceIp != null and sourceIp != ''">and source_ip = #{sourceIp}</if>
            <if test="sourcePort != null and sourcePort != ''">and source_port = #{sourcePort}</if>
            <if test="dbName != null and dbName != ''">and db_name = #{dbName}</if>
            <if test="sourceType != null and sourceType != ''">and source_type = #{sourceType}</if>
            <if test="loginName != null and loginName != ''">and login_name = #{loginName}</if>
            <if test="password != null and password != ''">and password = #{password}</if>
            <if test="serviceName != null and serviceName != ''">and service_name = #{serviceName}</if>
            <if test="useState != null">and use_state = #{useState}</if>
            <if test="dataState != null">and data_state = #{dataState}</if>
            <if test="sorts != null">and sorts = #{sorts}</if>
            <if test="create_user_id != null and create_user_id != ''">and create_user_id = #{create_user_id}</if>
            <if test="create_time != null">and create_time = #{create_time}</if>
            <if test="modify_user_id != null and modify_user_id != ''">and modify_user_id = #{modify_user_id}</if>
            <if test="modify_time != null">and modify_time = #{modify_time}</if>
            <if test="sts != null and sts != ''">and sts = #{sts}</if>
            <if test="org_id != null and org_id != ''">and org_id = #{org_id}</if>
            and sts='Y'
        </trim>
        <if test=" sort == null or sort == ''.toString() ">order by sorts asc</if>
        <if test=" sort !='' and sort!=null and order !='' and order!=null ">order by ${sort} ${order}</if>
    </select>

    <!-- 分页查询列表 采用like格式 -->
    <select id="entity_list_like" resultMap="get-SysDataSourceEntity-result"
            parameterType="com.hzya.frame.sys.dataSource.entity.SysDataSourceEntity">
        select
        <include refid="SysDataSourceEntity_Base_Column_List"/>
        from sys_data_source
        <trim prefix="where" prefixOverrides="and">
            <if test="id != null and id != ''">and id like concat('%',#{id},'%')</if>
            <if test="sourceCode != null and sourceCode != ''">and source_code like concat('%',#{sourceCode},'%')</if>
            <if test="sourceName != null and sourceName != ''">and source_name like concat('%',#{sourceName},'%')</if>
            <if test="sourceIp != null and sourceIp != ''">and source_ip like concat('%',#{sourceIp},'%')</if>
            <if test="sourcePort != null and sourcePort != ''">and source_port like concat('%',#{sourcePort},'%')</if>
            <if test="dbName != null and dbName != ''">and db_name like concat('%',#{dbName},'%')</if>
            <if test="sourceType != null and sourceType != ''">and source_type like concat('%',#{sourceType},'%')</if>
            <if test="loginName != null and loginName != ''">and login_name like concat('%',#{loginName},'%')</if>
            <if test="password != null and password != ''">and password like concat('%',#{password},'%')</if>
            <if test="serviceName != null and serviceName != ''">and service_name like concat('%',#{serviceName},'%')
            </if>
            <if test="useState != null">and use_state like concat('%',#{useState},'%')</if>
            <if test="dataState != null">and data_state like concat('%',#{dataState},'%')</if>
            <if test="sorts != null">and sorts like concat('%',#{sorts},'%')</if>
            <if test="create_user_id != null and create_user_id != ''">and create_user_id like
                concat('%',#{create_user_id},'%')
            </if>
            <if test="create_time != null">and create_time like concat('%',#{create_time},'%')</if>
            <if test="modify_user_id != null and modify_user_id != ''">and modify_user_id like
                concat('%',#{modify_user_id},'%')
            </if>
            <if test="modify_time != null">and modify_time like concat('%',#{modify_time},'%')</if>
            <if test="sts != null and sts != ''">and sts like concat('%',#{sts},'%')</if>
            <if test="org_id != null and org_id != ''">and org_id like concat('%',#{org_id},'%')</if>
            and sts='Y'
        </trim>
        <if test=" sort == null or sort == ''.toString() ">order by sorts asc</if>
        <if test=" sort !='' and sort!=null and order !='' and order!=null ">order by ${sort} ${order}</if>
    </select>


    <!-- 分页查询列表 采用like格式 -->
    <select id="queryVoList" resultType="com.hzya.frame.sys.dataSource.entity.SysDataSourceVo"
            parameterType="com.hzya.frame.sys.dataSource.entity.SysDataSourceEntity">
        select
        id,
        source_code as sourceCode,
        source_name as sourceName,
        source_ip as sourceIp,
        source_port as sourcePort,
        db_name as dbName,
        source_type as sourceType,
        login_name as loginName,
        password as password,
        service_name as serviceName,
        use_state as useState,
        data_state as dataState
        from sys_data_source
        <trim prefix="where" prefixOverrides="and">
            <if test="id != null and id != ''">and id like concat('%',#{id},'%')</if>
            <if test="sourceCode != null and sourceCode != ''">and source_code like concat('%',#{sourceCode},'%')</if>
            <if test="sourceName != null and sourceName != ''">and source_name like concat('%',#{sourceName},'%')</if>
            <if test="sourceIp != null and sourceIp != ''">and source_ip like concat('%',#{sourceIp},'%')</if>
            <if test="sourcePort != null and sourcePort != ''">and source_port like concat('%',#{sourcePort},'%')</if>
            <if test="dbName != null and dbName != ''">and db_name like concat('%',#{dbName},'%')</if>
            <if test="sourceType != null and sourceType != ''">and source_type like concat('%',#{sourceType},'%')</if>
            <if test="loginName != null and loginName != ''">and login_name like concat('%',#{loginName},'%')</if>
            <if test="password != null and password != ''">and password like concat('%',#{password},'%')</if>
            <if test="serviceName != null and serviceName != ''">and service_name like concat('%',#{serviceName},'%')
            </if>
            <if test="useState != null">and use_state like concat('%',#{useState},'%')</if>
            <if test="dataState != null">and data_state like concat('%',#{dataState},'%')</if>
            <if test="sorts != null">and sorts like concat('%',#{sorts},'%')</if>
            <if test="create_user_id != null and create_user_id != ''">and create_user_id like
                concat('%',#{create_user_id},'%')
            </if>
            <if test="create_time != null">and create_time like concat('%',#{create_time},'%')</if>
            <if test="modify_user_id != null and modify_user_id != ''">and modify_user_id like
                concat('%',#{modify_user_id},'%')
            </if>
            <if test="modify_time != null">and modify_time like concat('%',#{modify_time},'%')</if>
            <if test="sts != null and sts != ''">and sts like concat('%',#{sts},'%')</if>
            <if test="org_id != null and org_id != ''">and org_id like concat('%',#{org_id},'%')</if>
            and sts='Y'
        </trim>
        <if test=" sort == null or sort == ''.toString() ">order by sorts asc</if>
        <if test=" sort !='' and sort!=null and order !='' and order!=null ">order by ${sort} ${order}</if>
    </select>
    <select id="queryDSBase" resultType="com.hzya.frame.sys.dataSource.entity.SysDataSourceVo"
            parameterType="com.hzya.frame.sys.dataSource.entity.SysDataSourceEntity">
        select
        id,
        source_code as sourceCode,
        source_name as sourceName,
        source_ip as sourceIp,
        source_port as sourcePort,
        db_name as dbName,
        source_type as sourceType,
        login_name as loginName,
        password as password,
        service_name as serviceName,
        use_state as useState,
        data_state as dataState
        from sys_data_source
        <trim prefix="where" prefixOverrides="and">
            <if test="id != null and id != ''">and id = #{id}</if>
            <if test="sourceCode != null and sourceCode != ''">and source_code = #{sourceCode}</if>
            <if test="sourceName != null and sourceName != ''">and source_name = #{sourceName}</if>
            <if test="sourceIp != null and sourceIp != ''">and source_ip = #{sourceIp}</if>
            <if test="sourcePort != null and sourcePort != ''">and source_port = #{sourcePort}</if>
            <if test="dbName != null and dbName != ''">and db_name = #{dbName}</if>
            <if test="sourceType != null and sourceType != ''">and source_type = #{sourceType}</if>
            <if test="loginName != null and loginName != ''">and login_name = #{loginName}</if>
            <if test="password != null and password != ''">and password = #{password}</if>
            <if test="serviceName != null and serviceName != ''">and service_name = #{serviceName}</if>
            <if test="useState != null">and use_state = #{useState}</if>
            <if test="dataState != null">and data_state = #{dataState}</if>
            <if test="sorts != null">and sorts = #{sorts}</if>
            <if test="create_user_id != null and create_user_id != ''">and create_user_id = #{create_user_id}</if>
            <if test="create_time != null">and create_time = #{create_time}</if>
            <if test="modify_user_id != null and modify_user_id != ''">and modify_user_id = #{modify_user_id}</if>
            <if test="modify_time != null">and modify_time = #{modify_time}</if>
            <if test="sts != null and sts != ''">and sts = #{sts}</if>
            <if test="org_id != null and org_id != ''">and org_id = #{org_id}</if>
            and sts='Y'
        </trim>
    </select>


    <!-- 分页查询列表 采用like格式 -->
    <select id="queryVoList_COUNT" resultType="int" parameterType="com.hzya.frame.sys.dataSource.entity.SysDataSourceEntity">
        select
        count(*)
        from sys_data_source
        <trim prefix="where" prefixOverrides="and">
            <if test="id != null and id != ''">and id like concat('%',#{id},'%')</if>
            <if test="sourceCode != null and sourceCode != ''">and source_code like concat('%',#{sourceCode},'%')</if>
            <if test="sourceName != null and sourceName != ''">and source_name like concat('%',#{sourceName},'%')</if>
            <if test="sourceIp != null and sourceIp != ''">and source_ip like concat('%',#{sourceIp},'%')</if>
            <if test="sourcePort != null and sourcePort != ''">and source_port like concat('%',#{sourcePort},'%')</if>
            <if test="dbName != null and dbName != ''">and db_name like concat('%',#{dbName},'%')</if>
            <if test="sourceType != null and sourceType != ''">and source_type like concat('%',#{sourceType},'%')</if>
            <if test="loginName != null and loginName != ''">and login_name like concat('%',#{loginName},'%')</if>
            <if test="password != null and password != ''">and password like concat('%',#{password},'%')</if>
            <if test="serviceName != null and serviceName != ''">and service_name like concat('%',#{serviceName},'%')
            </if>
            <if test="useState != null">and use_state like concat('%',#{useState},'%')</if>
            <if test="dataState != null">and data_state like concat('%',#{dataState},'%')</if>
            <if test="sorts != null">and sorts like concat('%',#{sorts},'%')</if>
            <if test="create_user_id != null and create_user_id != ''">and create_user_id like
                concat('%',#{create_user_id},'%')
            </if>
            <if test="create_time != null">and create_time like concat('%',#{create_time},'%')</if>
            <if test="modify_user_id != null and modify_user_id != ''">and modify_user_id like
                concat('%',#{modify_user_id},'%')
            </if>
            <if test="modify_time != null">and modify_time like concat('%',#{modify_time},'%')</if>
            <if test="sts != null and sts != ''">and sts like concat('%',#{sts},'%')</if>
            <if test="org_id != null and org_id != ''">and org_id like concat('%',#{org_id},'%')</if>
            and sts='Y'
        </trim>
    </select>

    <!-- 查询列表 字段采用or格式 -->
    <select id="SysDataSourceentity_list_or" resultMap="get-SysDataSourceEntity-result"
            parameterType="com.hzya.frame.sys.dataSource.entity.SysDataSourceEntity">
        select
        <include refid="SysDataSourceEntity_Base_Column_List"/>
        from sys_data_source
        <trim prefix="where" prefixOverrides="and">
            <if test="id != null and id != ''">or id = #{id}</if>
            <if test="sourceCode != null and sourceCode != ''">or source_code = #{sourceCode}</if>
            <if test="sourceName != null and sourceName != ''">or source_name = #{sourceName}</if>
            <if test="sourceIp != null and sourceIp != ''">or source_ip = #{sourceIp}</if>
            <if test="sourcePort != null and sourcePort != ''">or source_port = #{sourcePort}</if>
            <if test="dbName != null and dbName != ''">or db_name = #{dbName}</if>
            <if test="sourceType != null and sourceType != ''">or source_type = #{sourceType}</if>
            <if test="loginName != null and loginName != ''">or login_name = #{loginName}</if>
            <if test="password != null and password != ''">or password = #{password}</if>
            <if test="serviceName != null and serviceName != ''">or service_name = #{serviceName}</if>
            <if test="useState != null">or use_state = #{useState}</if>
            <if test="dataState != null">or data_state = #{dataState}</if>
            <if test="sorts != null">or sorts = #{sorts}</if>
            <if test="create_user_id != null and create_user_id != ''">or create_user_id = #{create_user_id}</if>
            <if test="create_time != null">or create_time = #{create_time}</if>
            <if test="modify_user_id != null and modify_user_id != ''">or modify_user_id = #{modify_user_id}</if>
            <if test="modify_time != null">or modify_time = #{modify_time}</if>
            <if test="sts != null and sts != ''">or sts = #{sts}</if>
            <if test="org_id != null and org_id != ''">or org_id = #{org_id}</if>
            and sts='Y'
        </trim>
        <if test=" sort == null or sort == ''.toString()  ">order by sorts asc</if>
        <if test=" sort !='' and sort!=null and order !='' and order!=null ">order by ${sort} ${order}</if>
    </select>

    <!--新增所有列-->
    <insert id="entity_insert" parameterType="com.hzya.frame.sys.dataSource.entity.SysDataSourceEntity" keyProperty="id"
            useGeneratedKeys="true">
        insert into sys_data_source(
        <trim suffix="" suffixOverrides=",">
            <if test="id != null and id != ''">id ,</if>
            <if test="sourceCode != null and sourceCode != ''">source_code ,</if>
            <if test="sourceName != null and sourceName != ''">source_name ,</if>
            <if test="sourceIp != null and sourceIp != ''">source_ip ,</if>
            <if test="sourcePort != null and sourcePort != ''">source_port ,</if>
            <if test="dbName != null and dbName != ''">db_name ,</if>
            <if test="sourceType != null and sourceType != ''">source_type ,</if>
            <if test="loginName != null and loginName != ''">login_name ,</if>
            <if test="password != null and password != ''">password ,</if>
            <if test="serviceName != null and serviceName != ''">service_name ,</if>
            <if test="useState != null">use_state ,</if>
            <if test="dataState != null">data_state ,</if>
            <if test="sorts != null">sorts ,</if>
            <if test="create_user_id != null and create_user_id != ''">create_user_id ,</if>
            <if test="create_time != null">create_time ,</if>
            <if test="modify_user_id != null and modify_user_id != ''">modify_user_id ,</if>
            <if test="modify_time != null">modify_time ,</if>
            <if test="sts != null and sts != ''">sts ,</if>
            <if test="org_id != null and org_id != ''">org_id ,</if>
            <if test="sorts == null ">sorts,</if>
            <if test="sts == null ">sts,</if>
        </trim>
        )values(
        <trim suffix="" suffixOverrides=",">
            <if test="id != null and id != ''">#{id} ,</if>
            <if test="sourceCode != null and sourceCode != ''">#{sourceCode} ,</if>
            <if test="sourceName != null and sourceName != ''">#{sourceName} ,</if>
            <if test="sourceIp != null and sourceIp != ''">#{sourceIp} ,</if>
            <if test="sourcePort != null and sourcePort != ''">#{sourcePort} ,</if>
            <if test="dbName != null and dbName != ''">#{dbName} ,</if>
            <if test="sourceType != null and sourceType != ''">#{sourceType} ,</if>
            <if test="loginName != null and loginName != ''">#{loginName} ,</if>
            <if test="password != null and password != ''">#{password} ,</if>
            <if test="serviceName != null and serviceName != ''">#{serviceName} ,</if>
            <if test="useState != null">#{useState} ,</if>
            <if test="dataState != null">#{dataState} ,</if>
            <if test="sorts != null">#{sorts} ,</if>
            <if test="create_user_id != null and create_user_id != ''">#{create_user_id} ,</if>
            <if test="create_time != null">#{create_time} ,</if>
            <if test="modify_user_id != null and modify_user_id != ''">#{modify_user_id} ,</if>
            <if test="modify_time != null">#{modify_time} ,</if>
            <if test="sts != null and sts != ''">#{sts} ,</if>
            <if test="org_id != null and org_id != ''">#{org_id} ,</if>
            <if test="sorts == null ">(select (max(IFNULL( a.sorts, 0 )) + 1) as sort from sys_data_source a WHERE a.sts
                = 'Y' ),
            </if>
            <if test="sts == null ">'Y',</if>
        </trim>
        )
    </insert>
    <!-- 批量新增 -->
    <insert id="entityInsertBatch" keyProperty="id" useGeneratedKeys="true">
        insert into sys_data_source(source_code, source_name, source_ip, source_port, db_name, source_type, login_name,
        password, service_name, use_state, data_state, sorts, create_user_id, create_time, modify_user_id, modify_time, sts, org_id,
        sts)
        values
        <foreach collection="entities" item="entity" separator=",">
            (#{entity.sourceCode},#{entity.sourceName},#{entity.sourceIp},#{entity.sourcePort},#{entity.dbName},#{entity.sourceType},#{entity.loginName},#{entity.password},#{entity.serviceName},#{entity.useState},#{entity.dataState},#{entity.sorts},#{entity.create_user_id},#{entity.create_time},#{entity.modify_user_id},#{entity.modify_time},#{entity.sts},#{entity.org_id},
            'Y')
        </foreach>
    </insert>
    <!-- 批量新增或者修改-->
    <insert id="entityInsertOrUpdateBatch" keyProperty="id" useGeneratedKeys="true">
        insert into sys_data_source(source_code, source_name, source_ip, source_port, db_name, source_type, login_name,
        password, service_name, use_state, data_state, sorts, create_user_id, create_time, modify_user_id, modify_time, sts, org_id)
        values
        <foreach collection="entities" item="entity" separator=",">
            (#{entity.sourceCode},#{entity.sourceName},#{entity.sourceIp},#{entity.sourcePort},#{entity.dbName},#{entity.sourceType},#{entity.loginName},#{entity.password},#{entity.serviceName},#{entity.useState},#{entity.dataState},#{entity.sorts},#{entity.create_user_id},#{entity.create_time},#{entity.modify_user_id},#{entity.modify_time},#{entity.sts},#{entity.org_id})
        </foreach>
        on duplicate key update
        source_code = values(source_code),
        source_name = values(source_name),
        source_ip = values(source_ip),
        source_port = values(source_port),
        db_name = values(db_name),
        source_type = values(source_type),
        login_name = values(login_name),
        password = values(password),
        service_name = values(service_name),
        use_state = values(use_state),
        data_state = values(data_state),
        sorts = values(sorts),
        create_user_id = values(create_user_id),
        create_time = values(create_time),
        modify_user_id = values(modify_user_id),
        modify_time = values(modify_time),
        sts = values(sts),
        org_id = values(org_id)
    </insert>
    <!--通过主键修改方法-->
    <update id="entity_update" parameterType="com.hzya.frame.sys.dataSource.entity.SysDataSourceEntity">
        update sys_data_source set
        <trim suffix="" suffixOverrides=",">
            <if test="sourceCode != null and sourceCode != ''">source_code = #{sourceCode},</if>
            <if test="sourceName != null and sourceName != ''">source_name = #{sourceName},</if>
            <if test="sourceIp != null and sourceIp != ''">source_ip = #{sourceIp},</if>
            <if test="sourcePort != null and sourcePort != ''">source_port = #{sourcePort},</if>
            <if test="dbName != null and dbName != ''">db_name = #{dbName},</if>
            <if test="sourceType != null and sourceType != ''">source_type = #{sourceType},</if>
            <if test="loginName != null and loginName != ''">login_name = #{loginName},</if>
            <if test="password != null and password != ''">password = #{password},</if>
            <if test="serviceName != null and serviceName != ''">service_name = #{serviceName},</if>
            <if test="useState != null">use_state = #{useState},</if>
            <if test="dataState != null">data_state = #{dataState},</if>
            <if test="sorts != null">sorts = #{sorts},</if>
            <if test="create_user_id != null and create_user_id != ''">create_user_id = #{create_user_id},</if>
            <if test="create_time != null">create_time = #{create_time},</if>
            <if test="modify_user_id != null and modify_user_id != ''">modify_user_id = #{modify_user_id},</if>
            <if test="modify_time != null">modify_time = #{modify_time},</if>
            <if test="sts != null and sts != ''">sts = #{sts},</if>
            <if test="org_id != null and org_id != ''">org_id = #{org_id},</if>
        </trim>
        where id = #{id}
    </update>
    <!-- 逻辑删除 -->
    <update id="entity_logicDelete" parameterType="com.hzya.frame.sys.dataSource.entity.SysDataSourceEntity">
update sys_data_source  set sts= 'N' ,modify_time = #{modify_time},modify_user_id = #{modify_user_id}
where id = #{id}
</update>
    <!-- 多条件逻辑删除 -->
    <update id="entity_logicDelete_Multi_Condition"
            parameterType="com.hzya.frame.sys.dataSource.entity.SysDataSourceEntity">
        update sys_data_source set sts= 'N' ,modify_time = #{modify_time},modify_user_id = #{modify_user_id}
        <trim prefix="where" prefixOverrides="and">
            <if test="id != null and id != ''">and id = #{id}</if>
            <if test="sourceCode != null and sourceCode != ''">and source_code = #{sourceCode}</if>
            <if test="sourceName != null and sourceName != ''">and source_name = #{sourceName}</if>
            <if test="sourceIp != null and sourceIp != ''">and source_ip = #{sourceIp}</if>
            <if test="sourcePort != null and sourcePort != ''">and source_port = #{sourcePort}</if>
            <if test="dbName != null and dbName != ''">and db_name = #{dbName}</if>
            <if test="sourceType != null and sourceType != ''">and source_type = #{sourceType}</if>
            <if test="loginName != null and loginName != ''">and login_name = #{loginName}</if>
            <if test="password != null and password != ''">and password = #{password}</if>
            <if test="serviceName != null and serviceName != ''">and service_name = #{serviceName}</if>
            <if test="useState != null">and use_state = #{useState}</if>
            <if test="dataState != null">and data_state = #{dataState}</if>
            <if test="sorts != null">and sorts = #{sorts}</if>
            <if test="sts != null and sts != ''">and sts = #{sts}</if>
            and sts='Y'
        </trim>
    </update>
    <!--通过主键删除-->
    <delete id="entity_delete">
    delete from sys_data_source where id = #{id}
</delete>

</mapper>

