<?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.model.mapper.AppCleanRequestMapper">
    
    <resultMap type="AppCleanRequest" id="AppCleanRequestResult">
        <result property="cleanRequestId"    column="clean_request_id"    />
        <result property="cleanItemsId"    column="clean_items_id"    />
        <result property="serviceFileId"    column="service_file_id"    />
        <result property="cleanRequestImage"    column="clean_request_image"    />
        <result property="cleanRequestFrequencyDay"    column="clean_request_frequency_day"    />
        <result property="cleanRequestFrequencyTimes"    column="clean_request_frequency_times"    />
        <result property="remark"    column="remark"    />
    </resultMap>

    <sql id="selectAppCleanRequestVo">
        select clean_request_id, clean_items_id, service_file_id, clean_request_image, clean_request_frequency_day, clean_request_frequency_times, remark from app_clean_request
    </sql>

    <select id="selectAppCleanRequestList" parameterType="AppCleanRequest" resultMap="AppCleanRequestResult">
        <include refid="selectAppCleanRequestVo"/>
        <where>  
            <if test="cleanItemsId != null "> and clean_items_id = #{cleanItemsId}</if>
            <if test="serviceFileId != null "> and service_file_id = #{serviceFileId}</if>
            <if test="cleanRequestImage != null  and cleanRequestImage != ''"> and clean_request_image = #{cleanRequestImage}</if>
            <if test="cleanRequestFrequencyDay != null "> and clean_request_frequency_day = #{cleanRequestFrequencyDay}</if>
            <if test="cleanRequestFrequencyTimes != null "> and clean_request_frequency_times = #{cleanRequestFrequencyTimes}</if>
        </where>
    </select>
    
    <select id="selectAppCleanRequestByCleanRequestId" parameterType="Long" resultMap="AppCleanRequestResult">
        <include refid="selectAppCleanRequestVo"/>
        where clean_request_id = #{cleanRequestId}
    </select>
    <select id="getAppCleanRequestList" resultType="com.ruoyi.model.domain.AppCleanRequest">
        <include refid="selectAppCleanRequestVo"/>
    </select>

    <insert id="insertAppCleanRequest" parameterType="AppCleanRequest">
        insert into app_clean_request
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="cleanRequestId != null">clean_request_id,</if>
            <if test="cleanItemsId != null">clean_items_id,</if>
            <if test="serviceFileId != null">service_file_id,</if>
            <if test="cleanRequestImage != null">clean_request_image,</if>
            <if test="cleanRequestFrequencyDay != null">clean_request_frequency_day,</if>
            <if test="cleanRequestFrequencyTimes != null">clean_request_frequency_times,</if>
            <if test="remark != null">remark,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="cleanRequestId != null">#{cleanRequestId},</if>
            <if test="cleanItemsId != null">#{cleanItemsId},</if>
            <if test="serviceFileId != null">#{serviceFileId},</if>
            <if test="cleanRequestImage != null">#{cleanRequestImage},</if>
            <if test="cleanRequestFrequencyDay != null">#{cleanRequestFrequencyDay},</if>
            <if test="cleanRequestFrequencyTimes != null">#{cleanRequestFrequencyTimes},</if>
            <if test="remark != null">#{remark},</if>
         </trim>
    </insert>

    <update id="updateAppCleanRequest" parameterType="AppCleanRequest">
        update app_clean_request
        <trim prefix="SET" suffixOverrides=",">
            <if test="cleanItemsId != null">clean_items_id = #{cleanItemsId},</if>
            <if test="serviceFileId != null">service_file_id = #{serviceFileId},</if>
            <if test="cleanRequestImage != null">clean_request_image = #{cleanRequestImage},</if>
            <if test="cleanRequestFrequencyDay != null">clean_request_frequency_day = #{cleanRequestFrequencyDay},</if>
            <if test="cleanRequestFrequencyTimes != null">clean_request_frequency_times = #{cleanRequestFrequencyTimes},</if>
            <if test="remark != null">remark = #{remark},</if>
        </trim>
        where clean_request_id = #{cleanRequestId}
    </update>

    <delete id="deleteAppCleanRequestByCleanRequestId" parameterType="Long">
        delete from app_clean_request where clean_request_id = #{cleanRequestId}
    </delete>

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