<?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.inspect.metadata.bdconfig.mapper.BasedataBdConfigAlgConvertMapper">

    <resultMap type="BasedataBdConfigAlgConvert" id="BasedataBdConfigAlgConvertResult">
        <result property="algConvertId" column="alg_convert_id"/>
        <result property="mainSystemCode" column="main_system_code"/>
        <result property="mainSystemName" column="main_system_name"/>
        <result property="manufacturerCode" column="manufacturer_code"/>
        <result property="manufacturerName" column="manufacturer_name"/>
        <result property="algId" column="alg_id"/>
        <result property="algCode" column="alg_code"/>
        <result property="originalAlgCode" column="original_alg_code"/>
        <result property="delFlag" column="del_flag"/>
        <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="algName" column="alg_name"/>
    </resultMap>

    <sql id="selectBasedataBdConfigAlgConvertVo">
        select alg_convert_id,
               main_system_code,
               main_system_name,
               manufacturer_code,
               manufacturer_name,
               alg_id,
               alg_code,
               original_alg_code,
               del_flag,
               create_by,
               create_time,
               update_by,
               update_time,
               alg_name
        from basedata_bdconfig_alg_convert
    </sql>

    <select id="selectBasedataBdConfigAlgConvertList" parameterType="BasedataBdConfigAlgConvert"
            resultMap="BasedataBdConfigAlgConvertResult">
        <include refid="selectBasedataBdConfigAlgConvertVo"/>
        <where>
            <if test="mainSystemCode != null  and mainSystemCode != ''">and main_system_code = #{mainSystemCode}</if>
            <if test="mainSystemName != null  and mainSystemName != ''">and main_system_name like concat('%',
                #{mainSystemName}, '%')
            </if>
            <if test="manufacturerCode != null  and manufacturerCode != ''">and manufacturer_code =
                #{manufacturerCode}
            </if>
            <if test="manufacturerName != null  and manufacturerName != ''">and manufacturer_name like concat('%',
                #{manufacturerName}, '%')
            </if>
            <if test="algId != null ">and alg_id = #{algId}</if>
            <if test="algCode != null  and algCode != ''">and alg_code = #{algCode}</if>
            <if test="originalAlgCode != null  and originalAlgCode != ''">and original_alg_code = #{originalAlgCode}
            </if>
            <if test="algName != null  and algName != ''">and alg_name like concat('%', #{algName}, '%')</if>
        </where>
    </select>

    <select id="selectBasedataBdConfigAlgConvertByAlgConvertId" parameterType="Long"
            resultMap="BasedataBdConfigAlgConvertResult">
        <include refid="selectBasedataBdConfigAlgConvertVo"/>
        where alg_convert_id = #{algConvertId}
    </select>

    <insert id="insertBasedataBdConfigAlgConvert" parameterType="BasedataBdConfigAlgConvert" useGeneratedKeys="true"
            keyProperty="algConvertId">
        insert into basedata_bdconfig_alg_convert
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="mainSystemCode != null and mainSystemCode != ''">main_system_code,</if>
            <if test="mainSystemName != null">main_system_name,</if>
            <if test="manufacturerCode != null and manufacturerCode != ''">manufacturer_code,</if>
            <if test="manufacturerName != null">manufacturer_name,</if>
            <if test="algId != null">alg_id,</if>
            <if test="algCode != null">alg_code,</if>
            <if test="originalAlgCode != null">original_alg_code,</if>
            <if test="delFlag != null">del_flag,</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="algName != null">alg_name,</if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="mainSystemCode != null and mainSystemCode != ''">#{mainSystemCode},</if>
            <if test="mainSystemName != null">#{mainSystemName},</if>
            <if test="manufacturerCode != null and manufacturerCode != ''">#{manufacturerCode},</if>
            <if test="manufacturerName != null">#{manufacturerName},</if>
            <if test="algId != null">#{algId},</if>
            <if test="algCode != null">#{algCode},</if>
            <if test="originalAlgCode != null">#{originalAlgCode},</if>
            <if test="delFlag != null">#{delFlag},</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="algName != null">#{algName},</if>
        </trim>
    </insert>

    <update id="updateBasedataBdConfigAlgConvert" parameterType="BasedataBdConfigAlgConvert">
        update basedata_bdconfig_alg_convert
        <trim prefix="SET" suffixOverrides=",">
            <if test="mainSystemCode != null and mainSystemCode != ''">main_system_code = #{mainSystemCode},</if>
            <if test="mainSystemName != null">main_system_name = #{mainSystemName},</if>
            <if test="manufacturerCode != null and manufacturerCode != ''">manufacturer_code = #{manufacturerCode},</if>
            <if test="manufacturerName != null">manufacturer_name = #{manufacturerName},</if>
            <if test="algId != null">alg_id = #{algId},</if>
            <if test="algCode != null">alg_code = #{algCode},</if>
            <if test="originalAlgCode != null">original_alg_code = #{originalAlgCode},</if>
            <if test="delFlag != null">del_flag = #{delFlag},</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="algName != null">alg_name = #{algName},</if>
        </trim>
        where alg_convert_id = #{algConvertId}
    </update>

    <delete id="deleteBasedataBdConfigAlgConvertByAlgConvertId" parameterType="Long">
        delete
        from basedata_bdconfig_alg_convert
        where alg_convert_id = #{algConvertId}
    </delete>

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