<?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.EpsBusinessDeployMapper">
    
    <resultMap type="EpsBusinessDeploy" id="EpsBusinessDeployResult">
        <result property="id"    column="id"    />
        <result property="taskName"    column="task_name"    />
        <result property="businessCode"    column="business_code"    />
        <result property="businessName"    column="business_name"    />
        <result property="scriptName"    column="script_name"    />
        <result property="scriptPath"    column="script_path"    />
        <result property="scriptParams"    column="script_params"    />
        <result property="deployDevice"    column="deploy_device"    />
        <result property="submitBy"    column="submit_by"    />
        <result property="reviewBy"    column="review_by"    />
        <result property="reviewStatus"    column="review_status"    />
        <result property="reviewTime"    column="review_time"    />
        <result property="reviewComment"    column="review_comment"    />
        <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="selectEpsBusinessDeployVo">
        select id, task_name, business_code, business_name, script_name, script_path, script_params, deploy_device, submit_by, review_by, review_status, review_time, review_comment, create_time, update_time, create_by, update_by from eps_business_deploy
    </sql>

    <select id="selectEpsBusinessDeployList" parameterType="EpsBusinessDeploy" resultMap="EpsBusinessDeployResult">
        <include refid="selectEpsBusinessDeployVo"/>
        <where>  
            <if test="taskName != null  and taskName != ''"> and task_name like concat('%', #{taskName}, '%')</if>
            <if test="businessCode != null  and businessCode != ''"> and business_code = #{businessCode}</if>
            <if test="businessName != null  and businessName != ''"> and business_name like concat('%', #{businessName}, '%')</if>
            <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="scriptParams != null  and scriptParams != ''"> and script_params = #{scriptParams}</if>
            <if test="deployDevice != null  and deployDevice != ''"> and deploy_device = #{deployDevice}</if>
            <if test="submitBy != null  and submitBy != ''"> and submit_by = #{submitBy}</if>
            <if test="reviewBy != null  and reviewBy != ''"> and review_by = #{reviewBy}</if>
            <if test="reviewStatus != null  and reviewStatus != ''"> and review_status = #{reviewStatus}</if>
            <if test="reviewTime != null "> and review_time = #{reviewTime}</if>
            <if test="reviewComment != null  and reviewComment != ''"> and review_comment = #{reviewComment}</if>
            <if test="clientId != null  and clientId != ''">
                and FIND_IN_SET(#{clientId}, REPLACE(deploy_device, '\n', ',')) > 0
             </if>
        </where>
    </select>
    
    <select id="selectEpsBusinessDeployById" parameterType="Long" resultMap="EpsBusinessDeployResult">
        <include refid="selectEpsBusinessDeployVo"/>
        where id = #{id}
    </select>

    <insert id="insertEpsBusinessDeploy" parameterType="EpsBusinessDeploy" useGeneratedKeys="true" keyProperty="id">
        insert into eps_business_deploy
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="taskName != null">task_name,</if>
            <if test="businessCode != null">business_code,</if>
            <if test="businessName != null">business_name,</if>
            <if test="scriptName != null">script_name,</if>
            <if test="scriptPath != null">script_path,</if>
            <if test="scriptParams != null">script_params,</if>
            <if test="deployDevice != null">deploy_device,</if>
            <if test="submitBy != null">submit_by,</if>
            <if test="reviewBy != null">review_by,</if>
            <if test="reviewStatus != null">review_status,</if>
            <if test="reviewTime != null">review_time,</if>
            <if test="reviewComment != null">review_comment,</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="taskName != null">#{taskName},</if>
            <if test="businessCode != null">#{businessCode},</if>
            <if test="businessName != null">#{businessName},</if>
            <if test="scriptName != null">#{scriptName},</if>
            <if test="scriptPath != null">#{scriptPath},</if>
            <if test="scriptParams != null">#{scriptParams},</if>
            <if test="deployDevice != null">#{deployDevice},</if>
            <if test="submitBy != null">#{submitBy},</if>
            <if test="reviewBy != null">#{reviewBy},</if>
            <if test="reviewStatus != null">#{reviewStatus},</if>
            <if test="reviewTime != null">#{reviewTime},</if>
            <if test="reviewComment != null">#{reviewComment},</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="updateEpsBusinessDeploy" parameterType="EpsBusinessDeploy">
        update eps_business_deploy
        <trim prefix="SET" suffixOverrides=",">
            <if test="taskName != null">task_name = #{taskName},</if>
            <if test="businessCode != null">business_code = #{businessCode},</if>
            <if test="businessName != null">business_name = #{businessName},</if>
            <if test="scriptName != null">script_name = #{scriptName},</if>
            <if test="scriptPath != null">script_path = #{scriptPath},</if>
            <if test="scriptParams != null">script_params = #{scriptParams},</if>
            <if test="deployDevice != null">deploy_device = #{deployDevice},</if>
            <if test="submitBy != null">submit_by = #{submitBy},</if>
            <if test="reviewBy != null">review_by = #{reviewBy},</if>
            <if test="reviewStatus != null">review_status = #{reviewStatus},</if>
            <if test="reviewTime != null">review_time = #{reviewTime},</if>
            <if test="reviewComment != null">review_comment = #{reviewComment},</if>
            <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="deleteEpsBusinessDeployById" parameterType="Long">
        delete from eps_business_deploy where id = #{id}
    </delete>

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