<?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.oa.mapper.CmcSafeRequestMapper">
    
    <resultMap type="CmcSafeRequest" id="CmcSafeRequestResult">
        <result property="requestId"    column="request_id"    />
        <result property="safeType"    column="safe_type"    />
        <result property="content"    column="content"    />
    </resultMap>

    <sql id="selectCmcSafeRequestVo">
        select request_id, safe_type, content from cmc_safe_request
    </sql>

    <select id="selectCmcSafeRequestList" parameterType="CmcSafeRequest" resultMap="CmcSafeRequestResult">
        <include refid="selectCmcSafeRequestVo"/>
        <where>  
            <if test="safeType != null  and safeType != ''"> and safe_type = #{safeType}</if>
            <if test="content != null  and content != ''"> and content = #{content}</if>
        </where>
    </select>
    
    <select id="selectCmcSafeRequestByRequestId" parameterType="Integer" resultMap="CmcSafeRequestResult">
        <include refid="selectCmcSafeRequestVo"/>
        where request_id = #{requestId}
    </select>
        
    <insert id="insertCmcSafeRequest" parameterType="CmcSafeRequest" useGeneratedKeys="true" keyProperty="requestId">
        insert into cmc_safe_request
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="safeType != null">safe_type,</if>
            <if test="content != null">content,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="safeType != null">#{safeType},</if>
            <if test="content != null">#{content},</if>
         </trim>
    </insert>

    <update id="updateCmcSafeRequest" parameterType="CmcSafeRequest">
        update cmc_safe_request
        <trim prefix="SET" suffixOverrides=",">
            <if test="safeType != null">safe_type = #{safeType},</if>
            <if test="content != null">content = #{content},</if>
        </trim>
        where request_id = #{requestId}
    </update>

    <delete id="deleteCmcSafeRequestByRequestId" parameterType="Integer">
        delete from cmc_safe_request where request_id = #{requestId}
    </delete>

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