TemplateDataSourceMapper.xml 5.48 KB
<?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.lhcredit.project.business.templateDataSource.mapper.TemplateDataSourceMapper">
    
    <resultMap type="TemplateDataSource" id="TemplateDataSourceResult">
        <result property="id"    column="id"    />
        <result property="modelKey"    column="modelKey"    />
        <result property="modelName"    column="modelName"    />
        <result property="apiUrl"    column="apiUrl"    />
        <result property="localFunction"    column="localFunction"    />
        <result property="dataHandle"    column="dataHandle"    />
        <result property="docPath"    column="docPath"    />
        <result property="dataType"    column="dataType"    />
        <result property="reportKey"    column="reportKey"    />
        <result property="lastUpdateTime"    column="lastUpdateTime"    />
    </resultMap>
	
	<sql id="selectTemplateDataSourceVo">
        select id, modelKey, modelName, apiUrl,reportKey, localFunction, dataType,dataHandle, docPath, lastUpdateTime from template_data_source
    </sql>
	
    <select id="selectTemplateDataSourceList" parameterType="TemplateDataSource" resultMap="TemplateDataSourceResult">
        <include refid="selectTemplateDataSourceVo"/>
        <where>  
            <if test="id != null "> and id = #{id}</if>
            <if test="modelKey != null  and modelKey != '' "> and modelKey = #{modelKey}</if>
            <if test="modelName != null  and modelName != '' "> and modelName = #{modelName}</if>
            <if test="apiUrl != null  and apiUrl != '' "> and apiUrl = #{apiUrl}</if>
            <if test="localFunction != null  and localFunction != '' "> and localFunction = #{localFunction}</if>
            <if test="dataHandle != null  and dataHandle != '' "> and dataHandle = #{dataHandle}</if>
            <if test="reportKey != null  and reportKey != '' "> and reportKey = #{reportKey}</if>
            <if test="docPath != null  and docPath != '' "> and docPath = #{docPath}</if>
            <if test="dataType != null  and dataType != '' "> and dataType = #{dataType}</if>
            <if test="lastUpdateTime != null "> and lastUpdateTime = #{lastUpdateTime}</if>
        </where>
    </select>
    
    <select id="selectTemplateDataSourceById" parameterType="Integer" resultMap="TemplateDataSourceResult">
        <include refid="selectTemplateDataSourceVo"/>
        where id = #{id}
    </select>
        
    <insert id="insertTemplateDataSource" parameterType="TemplateDataSource" useGeneratedKeys="true" keyProperty="id">
        insert into template_data_source
		<trim prefix="(" suffix=")" suffixOverrides=",">
			<if test="modelKey != null  and modelKey != ''  ">modelKey,</if>
			<if test="modelName != null  and modelName != ''  ">modelName,</if>
			<if test="apiUrl != null  and apiUrl != ''  ">apiUrl,</if>
			<if test="localFunction != null  and localFunction != ''  ">localFunction,</if>
			<if test="dataHandle != null  and dataHandle != ''  ">dataHandle,</if>
			<if test="docPath != null  and docPath != ''  ">docPath,</if>
			<if test="dataType != null  and dataType != ''  ">dataType,</if>
			<if test="reportKey != null  and reportKey != ''  ">reportKey,</if>
			<if test="lastUpdateTime != null  ">lastUpdateTime,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
			<if test="modelKey != null  and modelKey != ''  ">#{modelKey},</if>
			<if test="modelName != null  and modelName != ''  ">#{modelName},</if>
			<if test="apiUrl != null  and apiUrl != ''  ">#{apiUrl},</if>
			<if test="localFunction != null  and localFunction != ''  ">#{localFunction},</if>
			<if test="dataHandle != null  and dataHandle != ''  ">#{dataHandle},</if>
			<if test="docPath != null  and docPath != ''  ">#{docPath},</if>
			<if test="dataType != null  and dataType != ''  ">#{dataType},</if>
			<if test="reportKey != null  and reportKey != ''  ">#{reportKey},</if>
			<if test="lastUpdateTime != null  ">#{lastUpdateTime},</if>
         </trim>
    </insert>
	 
    <update id="updateTemplateDataSource" parameterType="TemplateDataSource">
        update template_data_source
        <trim prefix="SET" suffixOverrides=",">
            <if test="modelKey != null  and modelKey != ''  ">modelKey = #{modelKey},</if>
            <if test="modelName != null  and modelName != ''  ">modelName = #{modelName},</if>
            <if test="apiUrl != null  and apiUrl != ''  ">apiUrl = #{apiUrl},</if>
            <if test="localFunction != null  and localFunction != ''  ">localFunction = #{localFunction},</if>
            <if test="dataHandle != null  and dataHandle != ''  ">dataHandle = #{dataHandle},</if>
            <if test="docPath != null  and docPath != ''  ">docPath = #{docPath},</if>
            <if test="dataType != null  and dataType != ''  ">dataType = #{dataType},</if>
            <if test="reportKey != null  and reportKey != ''  ">reportKey = #{reportKey},</if>
            <if test="lastUpdateTime != null  ">lastUpdateTime = #{lastUpdateTime},</if>
        </trim>
        where id = #{id}
    </update>

	<delete id="deleteTemplateDataSourceById" parameterType="Integer">
        delete from template_data_source where id = #{id}
    </delete>
	
    <delete id="deleteTemplateDataSourceByIds" parameterType="String">
        delete from template_data_source where id in 
        <foreach item="id" collection="array" open="(" separator="," close=")">
            #{id}
        </foreach>
    </delete>
    
</mapper>