<?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.microservices.pms.pipeline.mapper.PmsCiPipelineGraphicsMapper">
    
    <resultMap type="PmsCiPipelineGraphics" id="PmsCiPipelineGraphicsResult">
        <result property="id"    column="id"    />
        <result property="pmsCiPipelineId"    column="pms_ci_pipeline_id"    />
        <result property="pipelineName"    column="pipeline_name"    />
        <result property="pmsCiPipelineGraphicJson"    column="pms_ci_pipeline_graphic_json"    />
        <result property="updateTime"    column="update_time"    />
        <result property="updateBy"    column="update_by"    />
        <result property="createTime"    column="create_time"    />
        <result property="createBy"    column="create_by"    />
    </resultMap>

    <sql id="selectPmsCiPipelineGraphicsVo">
        select id, pms_ci_pipeline_id, pipeline_name, pms_ci_pipeline_graphic_json, update_time, update_by, create_time, create_by from pms_ci_pipeline_graphics
    </sql>

    <select id="selectPmsCiPipelineGraphicsList" parameterType="PmsCiPipelineGraphics" resultMap="PmsCiPipelineGraphicsResult">
        <include refid="selectPmsCiPipelineGraphicsVo"/>
        <where>  
            <if test="pmsCiPipelineId != null "> and pms_ci_pipeline_id = #{pmsCiPipelineId}</if>
            <if test="pipelineName != null  and pipelineName != ''"> and pipeline_name like concat('%', #{pipelineName}, '%')</if>
            <if test="pmsCiPipelineGraphicJson != null  and pmsCiPipelineGraphicJson != ''"> and pms_ci_pipeline_graphic_json = #{pmsCiPipelineGraphicJson}</if>
        </where>
    </select>
    
    <select id="selectPmsCiPipelineGraphicsById" parameterType="Long" resultMap="PmsCiPipelineGraphicsResult">
        <include refid="selectPmsCiPipelineGraphicsVo"/>
        where id = #{id}
    </select>
    <select id="selectPmsCiPipelineGraphicsByPmsCiPipelineId"
            parameterType="Long" resultMap="PmsCiPipelineGraphicsResult">
        <include refid="selectPmsCiPipelineGraphicsVo"/>
        where pms_ci_pipeline_id = #{pmsCiPipelineId}
    </select>

    <insert id="insertPmsCiPipelineGraphics" parameterType="PmsCiPipelineGraphics" useGeneratedKeys="true" keyProperty="id">
        insert into pms_ci_pipeline_graphics
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="pmsCiPipelineId != null">pms_ci_pipeline_id,</if>
            <if test="pipelineName != null">pipeline_name,</if>
            <if test="pmsCiPipelineGraphicJson != null">pms_ci_pipeline_graphic_json,</if>
            <if test="updateTime != null">update_time,</if>
            <if test="updateBy != null">update_by,</if>
            <if test="createTime != null">create_time,</if>
            <if test="createBy != null">create_by,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="pmsCiPipelineId != null">#{pmsCiPipelineId},</if>
            <if test="pipelineName != null">#{pipelineName},</if>
            <if test="pmsCiPipelineGraphicJson != null">#{pmsCiPipelineGraphicJson},</if>
            <if test="updateTime != null">#{updateTime},</if>
            <if test="updateBy != null">#{updateBy},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="createBy != null">#{createBy},</if>
         </trim>
    </insert>

    <update id="updatePmsCiPipelineGraphics" parameterType="PmsCiPipelineGraphics">
        update pms_ci_pipeline_graphics
        <trim prefix="SET" suffixOverrides=",">
            <if test="pmsCiPipelineId != null">pms_ci_pipeline_id = #{pmsCiPipelineId},</if>
            <if test="pipelineName != null">pipeline_name = #{pipelineName},</if>
            <if test="pmsCiPipelineGraphicJson != null">pms_ci_pipeline_graphic_json = #{pmsCiPipelineGraphicJson},</if>
            <if test="updateBy != null">update_by = #{updateBy},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="createBy != null">create_by = #{createBy},</if>
            update_time = sysdate()
        </trim>
        where id = #{id}
    </update>

    <delete id="deletePmsCiPipelineGraphicsById" parameterType="Long">
        delete from pms_ci_pipeline_graphics where id = #{id}
    </delete>

    <delete id="deletePmsCiPipelineGraphicsByIds" parameterType="String">
        delete from pms_ci_pipeline_graphics where id in 
        <foreach item="id" collection="array" open="(" separator="," close=")">
            #{id}
        </foreach>
    </delete>
    <delete id="deletePmsCiPipelineGraphicsByPmsCiPipelineIds">
        delete from pms_ci_pipeline_graphics where pms_ci_pipeline_id in
        <foreach item="pmsCiPipelineId" collection="array" open="(" separator="," close=")">
        #{pmsCiPipelineId}
        </foreach>
    </delete>
</mapper>