<?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.cn.fdapfe.biz.mapper.FdAlgorithmMapper">
    
    <resultMap type="FdAlgorithm" id="FdAlgorithmResult">
        <result property="id"    column="id"    />
        <result property="name"    column="name"    />
        <result property="modelId"    column="model_id"    />
        <result property="dataId"    column="data_id"    />
        <result property="truthLabels"    column="truth_labels"    />
        <result property="testLabels"    column="test_labels"    />
        <result property="remark"    column="remark"    />
        <result property="startTime"    column="start_time"    />
        <result property="endTime"    column="end_time"    />
        <result property="createBy"    column="create_by"    />
        <result property="createTime"    column="create_time"    />
        <result property="updateBy"    column="update_by"    />
        <result property="updateTime"    column="update_time"    />
    </resultMap>

    <sql id="selectFdAlgorithmVo">
        select id, name, model_id, data_id, truth_labels, test_labels, remark, start_time, end_time, create_by, create_time, update_by, update_time from biz_fd_algorithm
    </sql>

    <select id="selectFdAlgorithmList" parameterType="FdAlgorithm" resultMap="FdAlgorithmResult">
        <include refid="selectFdAlgorithmVo"/>
        <where>  
            <if test="name != null  and name != ''"> and name like concat('%', #{name}, '%')</if>
            <if test="truthLabels != null  and truthLabels != ''"> and truth_labels = #{truthLabels}</if>
            <if test="testLabels != null  and testLabels != ''"> and test_labels = #{testLabels}</if>
            <if test="startTime != null "> and start_time = #{startTime}</if>
            <if test="endTime != null "> and end_time = #{endTime}</if>
        </where>
    </select>
    
    <select id="selectFdAlgorithmById" parameterType="Long" resultMap="FdAlgorithmResult">
        <include refid="selectFdAlgorithmVo"/>
        where id = #{id}
    </select>

    <insert id="insertFdAlgorithm" parameterType="FdAlgorithm" useGeneratedKeys="true" keyProperty="id">
        insert into biz_fd_algorithm
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="name != null">name,</if>
            <if test="modelId != null">model_id,</if>
            <if test="dataId != null">data_id,</if>
            <if test="truthLabels != null">truth_labels,</if>
            <if test="testLabels != null">test_labels,</if>
            <if test="remark != null">remark,</if>
            <if test="startTime != null">start_time,</if>
            <if test="endTime != null">end_time,</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>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="name != null">#{name},</if>
            <if test="modelId != null">#{modelId},</if>
            <if test="dataId != null">#{dataId},</if>
            <if test="truthLabels != null">#{truthLabels},</if>
            <if test="testLabels != null">#{testLabels},</if>
            <if test="remark != null">#{remark},</if>
            <if test="startTime != null">#{startTime},</if>
            <if test="endTime != null">#{endTime},</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>
         </trim>
    </insert>

    <update id="updateFdAlgorithm" parameterType="FdAlgorithm">
        update biz_fd_algorithm
        <trim prefix="SET" suffixOverrides=",">
            <if test="name != null">name = #{name},</if>
            <if test="modelId != null">model_id = #{modelId},</if>
            <if test="dataId != null">data_id = #{dataId},</if>
            <if test="truthLabels != null">truth_labels = #{truthLabels},</if>
            <if test="testLabels != null">test_labels = #{testLabels},</if>
            <if test="remark != null">remark = #{remark},</if>
            <if test="startTime != null">start_time = #{startTime},</if>
            <if test="endTime != null">end_time = #{endTime},</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>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteFdAlgorithmById" parameterType="Long">
        delete from biz_fd_algorithm where id = #{id}
    </delete>

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

    <select id="getOptions" resultType="map">
        select id,name from biz_fd_algorithm order by id desc
    </select>
</mapper>