<?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.system.mapper.AlgConfigMapper">
    
    <resultMap type="AlgConfig" id="AlgConfigResult">
        <result property="id"    column="id"    />
        <result property="algName"    column="alg_name"    />
        <result property="algType"    column="alg_type"    />
        <result property="algLang"    column="alg_lang"    />
        <result property="fixed"    column="fixed"    />
        <result property="algUrl"    column="alg_url"    />
        <result property="inputUrl"    column="input_url"    />
        <result property="outUrl"    column="out_url"    />
        <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="selectAlgConfigVo">
        select id, alg_name, alg_type, alg_lang, fixed, alg_url, input_url, out_url, create_by, create_time, update_by, update_time, remark from t_alg_config
    </sql>

    <select id="selectAlgConfigList" parameterType="AlgConfig" resultMap="AlgConfigResult">
        <include refid="selectAlgConfigVo"/>
        <where>  
            <if test="algName != null  and algName != ''"> and alg_name like concat('%', #{algName}, '%')</if>
            <if test="algType != null  and algType != ''"> and alg_type = #{algType}</if>
            <if test="algLang != null  and algLang != ''"> and alg_lang = #{algLang}</if>
            <if test="fixed != null  and fixed != ''"> and fixed = #{fixed}</if>
            <if test="algUrl != null  and algUrl != ''"> and alg_url = #{algUrl}</if>
            <if test="inputUrl != null  and inputUrl != ''"> and input_url = #{inputUrl}</if>
            <if test="outUrl != null  and outUrl != ''"> and out_url = #{outUrl}</if>
        </where>
        order by create_time desc
    </select>
    
    <select id="selectAlgConfigById" parameterType="Long" resultMap="AlgConfigResult">
        <include refid="selectAlgConfigVo"/>
        where id = #{id}
    </select>
        
    <insert id="insertAlgConfig" parameterType="AlgConfig" useGeneratedKeys="true" keyProperty="id">
        insert into t_alg_config
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="algName != null and algName != ''">alg_name,</if>
            <if test="algType != null and algType != ''">alg_type,</if>
            <if test="algLang != null and algLang != ''">alg_lang,</if>
            <if test="fixed != null and fixed != ''">fixed,</if>
            <if test="algUrl != null and algUrl != ''">alg_url,</if>
            <if test="inputUrl != null">input_url,</if>
            <if test="outUrl != null">out_url,</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="algName != null and algName != ''">#{algName},</if>
            <if test="algType != null and algType != ''">#{algType},</if>
            <if test="algLang != null and algLang != ''">#{algLang},</if>
            <if test="fixed != null and fixed != ''">#{fixed},</if>
            <if test="algUrl != null and algUrl != ''">#{algUrl},</if>
            <if test="inputUrl != null">#{inputUrl},</if>
            <if test="outUrl != null">#{outUrl},</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="updateAlgConfig" parameterType="AlgConfig">
        update t_alg_config
        <trim prefix="SET" suffixOverrides=",">
            <if test="algName != null and algName != ''">alg_name = #{algName},</if>
            <if test="algType != null and algType != ''">alg_type = #{algType},</if>
            <if test="algLang != null and algLang != ''">alg_lang = #{algLang},</if>
            <if test="fixed != null and fixed != ''">fixed = #{fixed},</if>
            <if test="algUrl != null and algUrl != ''">alg_url = #{algUrl},</if>
            <if test="inputUrl != null">input_url = #{inputUrl},</if>
            <if test="outUrl != null">out_url = #{outUrl},</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="deleteAlgConfigById" parameterType="Long">
        delete from t_alg_config where id = #{id}
    </delete>

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