<?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.ruoyi.system.mapper.EpsBusinessScriptMapper">
    
    <resultMap type="EpsBusinessScript" id="EpsBusinessScriptResult">
        <result property="id"    column="id"    />
        <result property="scriptName"    column="script_name"    />
        <result property="scriptPath"    column="script_path"    />
        <result property="defaultParams"    column="default_params"    />
        <result property="createTime"    column="create_time"    />
        <result property="updateTime"    column="update_time"    />
        <result property="createBy"    column="create_by"    />
        <result property="updateBy"    column="update_by"    />
    </resultMap>

    <sql id="selectEpsBusinessScriptVo">
        select id, script_name, script_path, default_params, create_time, update_time, create_by, update_by from eps_business_script
    </sql>

    <select id="selectEpsBusinessScriptList" parameterType="EpsBusinessScript" resultMap="EpsBusinessScriptResult">
        <include refid="selectEpsBusinessScriptVo"/>
        <where>  
            <if test="scriptName != null  and scriptName != ''"> and script_name like concat('%', #{scriptName}, '%')</if>
            <if test="scriptPath != null  and scriptPath != ''"> and script_path = #{scriptPath}</if>
            <if test="defaultParams != null  and defaultParams != ''"> and default_params = #{defaultParams}</if>
        </where>
    </select>
    
    <select id="selectEpsBusinessScriptById" parameterType="Long" resultMap="EpsBusinessScriptResult">
        <include refid="selectEpsBusinessScriptVo"/>
        where id = #{id}
    </select>

    <insert id="insertEpsBusinessScript" parameterType="EpsBusinessScript" useGeneratedKeys="true" keyProperty="id">
        insert into eps_business_script
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="scriptName != null">script_name,</if>
            <if test="scriptPath != null">script_path,</if>
            <if test="defaultParams != null">default_params,</if>
            <if test="createTime != null">create_time,</if>
            <if test="updateTime != null">update_time,</if>
            <if test="createBy != null">create_by,</if>
            <if test="updateBy != null">update_by,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="scriptName != null">#{scriptName},</if>
            <if test="scriptPath != null">#{scriptPath},</if>
            <if test="defaultParams != null">#{defaultParams},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="updateTime != null">#{updateTime},</if>
            <if test="createBy != null">#{createBy},</if>
            <if test="updateBy != null">#{updateBy},</if>
         </trim>
    </insert>

    <update id="updateEpsBusinessScript" parameterType="EpsBusinessScript">
        update eps_business_script
        <trim prefix="SET" suffixOverrides=",">
            <if test="scriptName != null">script_name = #{scriptName},</if>
            <if test="scriptPath != null">script_path = #{scriptPath},</if>
            default_params = #{defaultParams},
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
            <if test="createBy != null">create_by = #{createBy},</if>
            <if test="updateBy != null">update_by = #{updateBy},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteEpsBusinessScriptById" parameterType="Long">
        delete from eps_business_script where id = #{id}
    </delete>

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