<?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.pdaaphm.biz.mapper.AlgorithmSubTypeMapper">

    <resultMap type="AlgorithmSubType" id="AlgorithmSubTypeResult">
        <result property="id"    column="id"    />
        <result property="type"    column="type"    />
        <result property="name"    column="name"    />
        <result property="url"    column="url"    />
        <result property="runType"    column="run_type"    />
        <result property="dataType"    column="data_type"    />
        <result property="createBy"    column="create_by"    />
        <result property="createTime"    column="create_time"    />
        <result property="updateBy"    column="update_by"    />
        <result property="updateTime"    column="update_time"    />
        <result property="remark"    column="remark"    />
    </resultMap>

    <sql id="selectAlgorithmSubTypeVo">
        select id, `type`, `name`, url, run_type, data_type, create_by, create_time, update_by, update_time, remark from t_algorithm_sub_type
    </sql>

    <select id="selectAlgorithmSubTypeList" parameterType="AlgorithmSubType" resultMap="AlgorithmSubTypeResult">
        <include refid="selectAlgorithmSubTypeVo"/>
        <where>
            <if test="type != null  and type != ''"> and `type` = #{type}</if>
            <if test="name != null  and name != ''"> and `name` like concat('%', #{name}, '%')</if>
            <if test="url != null  and url != ''"> and url = #{url}</if>
            <if test="runType != null  and runType != ''"> and run_type = #{runType}</if>
        </where>
    </select>

    <select id="selectAlgorithmSubTypeById" parameterType="Long" resultMap="AlgorithmSubTypeResult">
        <include refid="selectAlgorithmSubTypeVo"/>
        where id = #{id}
    </select>

    <insert id="insertAlgorithmSubType" parameterType="AlgorithmSubType" useGeneratedKeys="true" keyProperty="id">
        insert into t_algorithm_sub_type
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="type != null">`type`,</if>
            <if test="name != null">`name`,</if>
            <if test="url != null">url,</if>
            <if test="runType != null">run_type,</if>
            <if test="dataType != null">data_type,</if>
            <if test="createBy != null">create_by,</if>
            <if test="createTime != null">create_time,</if>
            <if test="updateBy != null">update_by,</if>
            <if test="updateTime != null">update_time,</if>
            <if test="remark != null">remark,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="type != null">#{type},</if>
            <if test="name != null">#{name},</if>
            <if test="url != null">#{url},</if>
            <if test="runType != null">#{runType},</if>
            <if test="dataType != null">#{dataType},</if>
            <if test="createBy != null">#{createBy},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="updateBy != null">#{updateBy},</if>
            <if test="updateTime != null">#{updateTime},</if>
            <if test="remark != null">#{remark},</if>
         </trim>
    </insert>

    <update id="updateAlgorithmSubType" parameterType="AlgorithmSubType">
        update t_algorithm_sub_type
        <trim prefix="SET" suffixOverrides=",">
            <if test="type != null">`type` = #{type},</if>
            <if test="name != null">`name` = #{name},</if>
            <if test="url != null">url = #{url},</if>
            <if test="runType != null">run_type = #{runType},</if>
            <if test="dataType != null">data_type = #{dataType},</if>
            <if test="createBy != null">create_by = #{createBy},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="updateBy != null">update_by = #{updateBy},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
            <if test="remark != null">remark = #{remark},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteAlgorithmSubTypeById" parameterType="Long">
        delete from t_algorithm_sub_type where id = #{id}
    </delete>

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