<?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.manage.mapper.ParameterSetMapper">
    
    <resultMap type="ParameterSet" id="ParameterSetResult">
        <result property="parameterId"    column="parameter_id"    />
        <result property="channelId"    column="channel_id"    />
        <result property="equipmentId"    column="equipment_id"    />
        <result property="equipmentNum"    column="equipment_num"    />
        <result property="equipmentName"    column="equipment_name"    />
        <result property="channelNum"    column="channel_num"    />
        <result property="channelRange"    column="channel_range"    />
        <result property="leaveTime"    column="leave_time"    />
        <result property="playTime"    column="play_time"    />
        <result property="leaveRate"    column="leave_rate"    />
        <result property="playRate"    column="play_rate"    />
        <result property="delFlag"    column="del_flag"    />
        <result property="createBy"    column="create_by"    />
        <result property="createTime"    column="create_time"    />
        <result property="updateBy"    column="update_by"    />
        <result property="updateTime"    column="update_time"    />
        <result property="remark"    column="remark"    />
    </resultMap>

    <sql id="selectParameterSetVo">
        select parameter_id, channel_id, equipment_id, equipment_num, equipment_name, channel_num, channel_range, leave_time, play_time, leave_rate, play_rate, del_flag, create_by, create_time, update_by, update_time, remark from parameter_set
    </sql>

    <select id="selectParameterSetList" parameterType="ParameterSet" resultMap="ParameterSetResult">
        <include refid="selectParameterSetVo"/>
        <where>  
            <if test="channelId != null "> and channel_id = #{channelId}</if>
            <if test="equipmentId != null "> and equipment_id = #{equipmentId}</if>
            <if test="equipmentNum != null  and equipmentNum != ''"> and equipment_num = #{equipmentNum}</if>
            <if test="equipmentName != null  and equipmentName != ''"> and equipment_name like concat('%', #{equipmentName}, '%')</if>
            <if test="channelNum != null  and channelNum != ''"> and channel_num = #{channelNum}</if>
            <if test="channelRange != null  and channelRange != ''"> and channel_range = #{channelRange}</if>
            <if test="leaveTime != null  and leaveTime != ''"> and leave_time = #{leaveTime}</if>
            <if test="playTime != null  and playTime != ''"> and play_time = #{playTime}</if>
            <if test="leaveRate != null  and leaveRate != ''"> and leave_rate = #{leaveRate}</if>
            <if test="playRate != null  and playRate != ''"> and play_rate = #{playRate}</if>
        </where>
    </select>
    
    <select id="selectParameterSetByParameterId" parameterType="Long" resultMap="ParameterSetResult">
        <include refid="selectParameterSetVo"/>
        where parameter_id = #{parameterId}
    </select>
    <select id="selectParameterSetByChannelId" parameterType="Long" resultMap="ParameterSetResult">
        <include refid="selectParameterSetVo"/>
        where channel_id = #{channelId}
    </select>
    <insert id="insertParameterSet" parameterType="ParameterSet" useGeneratedKeys="true" keyProperty="parameterId">
        insert into parameter_set
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="channelId != null">channel_id,</if>
            <if test="equipmentId != null">equipment_id,</if>
            <if test="equipmentNum != null">equipment_num,</if>
            <if test="equipmentName != null">equipment_name,</if>
            <if test="channelNum != null">channel_num,</if>
            <if test="channelRange != null">channel_range,</if>
            <if test="leaveTime != null">leave_time,</if>
            <if test="playTime != null">play_time,</if>
            <if test="leaveRate != null">leave_rate,</if>
            <if test="playRate != null">play_rate,</if>
            <if test="delFlag != null">del_flag,</if>
            <if test="createBy != null">create_by,</if>
            <if test="createTime != null">create_time,</if>
            <if test="updateBy != null">update_by,</if>
            <if test="updateTime != null">update_time,</if>
            <if test="remark != null">remark,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="channelId != null">#{channelId},</if>
            <if test="equipmentId != null">#{equipmentId},</if>
            <if test="equipmentNum != null">#{equipmentNum},</if>
            <if test="equipmentName != null">#{equipmentName},</if>
            <if test="channelNum != null">#{channelNum},</if>
            <if test="channelRange != null">#{channelRange},</if>
            <if test="leaveTime != null">#{leaveTime},</if>
            <if test="playTime != null">#{playTime},</if>
            <if test="leaveRate != null">#{leaveRate},</if>
            <if test="playRate != null">#{playRate},</if>
            <if test="delFlag != null">#{delFlag},</if>
            <if test="createBy != null">#{createBy},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="updateBy != null">#{updateBy},</if>
            <if test="updateTime != null">#{updateTime},</if>
            <if test="remark != null">#{remark},</if>
         </trim>
    </insert>

    <update id="updateParameterSet" parameterType="ParameterSet">
        update parameter_set
        <trim prefix="SET" suffixOverrides=",">
            <if test="channelId != null">channel_id = #{channelId},</if>
            <if test="equipmentId != null">equipment_id = #{equipmentId},</if>
            <if test="equipmentNum != null">equipment_num = #{equipmentNum},</if>
            <if test="equipmentName != null">equipment_name = #{equipmentName},</if>
            <if test="channelNum != null">channel_num = #{channelNum},</if>
            <if test="channelRange != null">channel_range = #{channelRange},</if>
            <if test="leaveTime != null">leave_time = #{leaveTime},</if>
            <if test="playTime != null">play_time = #{playTime},</if>
            <if test="leaveRate != null">leave_rate = #{leaveRate},</if>
            <if test="playRate != null">play_rate = #{playRate},</if>
            <if test="delFlag != null">del_flag = #{delFlag},</if>
            <if test="createBy != null">create_by = #{createBy},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="updateBy != null">update_by = #{updateBy},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
            <if test="remark != null">remark = #{remark},</if>
        </trim>
        where parameter_id = #{parameterId}
    </update>

    <delete id="deleteParameterSetByParameterId" parameterType="Long">
        delete from parameter_set where parameter_id = #{parameterId}
    </delete>

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