<?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.ems.mapper.DevProcessMapper">
    
    <resultMap type="com.ruoyi.ems.domain.DevProcess" id="DevProcessResult">
        <result property="id"    column="id"    />
        <result property="psCode"    column="ps_code"    />
        <result property="psName"    column="ps_name"    />
        <result property="desc"    column="desc"    />
        <result property="categoryCode"    column="category_code"    />
        <result property="subcategoryCode"    column="subcategory_code"    />
        <result property="version"    column="version"    />
    </resultMap>

    <sql id="selectDevProcessVo">
        select id, ps_code, ps_name, `desc`, category_code, subcategory_code, version from dim_ems_dev_process
    </sql>

    <select id="selectDevProcessList" parameterType="com.ruoyi.ems.domain.DevProcess" resultMap="DevProcessResult">
        <include refid="selectDevProcessVo"/>
        <where>  
            <if test="psCode != null  and psCode != ''"> and ps_code = #{psCode}</if>
            <if test="psName != null  and psName != ''"> and ps_name like concat('%', #{psName}, '%')</if>
            <if test="categoryCode != null  and categoryCode != ''"> and category_code = #{categoryCode}</if>
            <if test="subcategoryCode != null  and subcategoryCode != ''"> and subcategory_code = #{subcategoryCode}</if>
        </where>
    </select>
    
    <select id="selectDevProcessById" parameterType="Long" resultMap="DevProcessResult">
        <include refid="selectDevProcessVo"/>
        where id = #{id}
    </select>
        
    <insert id="insertDevProcess" parameterType="com.ruoyi.ems.domain.DevProcess" useGeneratedKeys="true" keyProperty="id">
        insert into dim_ems_dev_process
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="psCode != null and psCode != ''">ps_code,</if>
            <if test="psName != null and psName != ''">ps_name,</if>
            <if test="desc != null">`desc`,</if>
            <if test="categoryCode != null">category_code,</if>
            <if test="subcategoryCode != null">subcategory_code,</if>
            <if test="version != null">version,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="psCode != null and psCode != ''">#{psCode},</if>
            <if test="psName != null and psName != ''">#{psName},</if>
            <if test="desc != null">#{desc},</if>
            <if test="categoryCode != null">#{categoryCode},</if>
            <if test="subcategoryCode != null">#{subcategoryCode},</if>
            <if test="version != null">#{version},</if>
         </trim>
    </insert>

    <update id="updateDevProcess" parameterType="com.ruoyi.ems.domain.DevProcess">
        update dim_ems_dev_process
        <trim prefix="SET" suffixOverrides=",">
            <if test="psCode != null and psCode != ''">ps_code = #{psCode},</if>
            <if test="psName != null and psName != ''">ps_name = #{psName},</if>
            <if test="desc != null">`desc` = #{desc},</if>
            <if test="categoryCode != null">category_code = #{categoryCode},</if>
            <if test="subcategoryCode != null">subcategory_code = #{subcategoryCode},</if>
            <if test="version != null">version = #{version},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteDevProcessById" parameterType="Long">
        delete from dim_ems_dev_process where id = #{id}
    </delete>

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