<?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.OrderSoundLogMapper">
    
    <resultMap type="OrderSoundLog" id="OrderSoundLogResult">
        <result property="id"    column="id"    />
        <result property="oid"    column="oid"    />
        <result property="file"    column="file"    />
        <result property="createdAt"    column="created_at"    />
        <result property="isMerge"    column="is_merge"    />
    </resultMap>

    <sql id="selectOrderSoundLogVo">
        select id, oid, file, created_at, is_merge from order_sound_log
    </sql>

    <select id="selectCountOrderSoundLogByoId"  parameterType="Long" resultType="Integer">
         select count(1) from order_sound_log where oid = #{oid}
    </select>

    <select id="selectOrderSoundLogList" parameterType="OrderSoundLog" resultMap="OrderSoundLogResult">
        <include refid="selectOrderSoundLogVo"/>
        <where>  
            <if test="oid != null "> and oid = #{oid}</if>
            <if test="file != null  and file != ''"> and file = #{file}</if>
            <if test="createdAt != null "> and created_at = #{createdAt}</if>
            <if test="isMerge != null "> and is_merge = #{isMerge}</if>
        </where>
    </select>
    
    <select id="selectOrderSoundLogById" parameterType="Integer" resultMap="OrderSoundLogResult">
        <include refid="selectOrderSoundLogVo"/>
        where id = #{id}
    </select>

    <insert id="insertOrderSoundLog" parameterType="OrderSoundLog" useGeneratedKeys="true" keyProperty="id">
        insert into order_sound_log
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="oid != null">oid,</if>
            <if test="file != null">file,</if>
            <if test="createdAt != null">created_at,</if>
            <if test="isMerge != null">is_merge,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="oid != null">#{oid},</if>
            <if test="file != null">#{file},</if>
            <if test="createdAt != null">#{createdAt},</if>
            <if test="isMerge != null">#{isMerge},</if>
         </trim>
    </insert>

    <update id="updateOrderSoundLog" parameterType="OrderSoundLog">
        update order_sound_log
        <trim prefix="SET" suffixOverrides=",">
            <if test="oid != null">oid = #{oid},</if>
            <if test="file != null">file = #{file},</if>
            <if test="createdAt != null">created_at = #{createdAt},</if>
            <if test="isMerge != null">is_merge = #{isMerge},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteOrderSoundLogById" parameterType="Integer">
        delete from order_sound_log where id = #{id}
    </delete>

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