<?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.base.mapper.RobotOpsBroadcastTaskMapper">
    
    <resultMap type="RobotOpsBroadcastTask" id="RobotOpsBroadcastTaskResult">
        <result property="id"    column="id"    />
        <result property="taskName"    column="task_name"    />
        <result property="contentId"    column="content_id"    />
        <result property="startTime"    column="start_time"    />
        <result property="endTime"    column="end_time"    />
        <result property="frequencyMinutes"    column="frequency_minutes"    />
        <result property="cycleType"    column="cycle_type"    />
        <result property="cycleValue"    column="cycle_value"    />
        <result property="status"    column="status"    />
        <result property="remark"    column="remark"    />
        <result property="createTime"    column="create_time"    />
        <result property="updateTime"    column="update_time"    />
    </resultMap>

    <sql id="selectRobotOpsBroadcastTaskVo">
        select id, task_name, content_id, start_time, end_time, frequency_minutes, cycle_type, cycle_value, status, remark, create_time, update_time from robot_ops_broadcast_task
    </sql>

    <select id="selectRobotOpsBroadcastTaskList" parameterType="RobotOpsBroadcastTask" resultMap="RobotOpsBroadcastTaskResult">
        <include refid="selectRobotOpsBroadcastTaskVo"/>
        <where>  
            <if test="taskName != null  and taskName != ''"> and task_name like concat('%', #{taskName}, '%')</if>
            <if test="contentId != null "> and content_id = #{contentId}</if>
            <if test="startTime != null  and startTime != ''"> and start_time = #{startTime}</if>
            <if test="endTime != null  and endTime != ''"> and end_time = #{endTime}</if>
            <if test="frequencyMinutes != null "> and frequency_minutes = #{frequencyMinutes}</if>
            <if test="cycleType != null "> and cycle_type = #{cycleType}</if>
            <if test="cycleValue != null  and cycleValue != ''"> and cycle_value = #{cycleValue}</if>
            <if test="status != null  and status != ''"> and status = #{status}</if>
        </where>
    </select>
    
    <select id="selectRobotOpsBroadcastTaskById" parameterType="Long" resultMap="RobotOpsBroadcastTaskResult">
        <include refid="selectRobotOpsBroadcastTaskVo"/>
        where id = #{id}
    </select>

    <insert id="insertRobotOpsBroadcastTask" parameterType="RobotOpsBroadcastTask" useGeneratedKeys="true" keyProperty="id">
        insert into robot_ops_broadcast_task
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="taskName != null and taskName != ''">task_name,</if>
            <if test="contentId != null">content_id,</if>
            <if test="startTime != null">start_time,</if>
            <if test="endTime != null">end_time,</if>
            <if test="frequencyMinutes != null">frequency_minutes,</if>
            <if test="cycleType != null">cycle_type,</if>
            <if test="cycleValue != null">cycle_value,</if>
            <if test="status != null and status != ''">status,</if>
            <if test="remark != null">remark,</if>
            <if test="createTime != null">create_time,</if>
            <if test="updateTime != null">update_time,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="taskName != null and taskName != ''">#{taskName},</if>
            <if test="contentId != null">#{contentId},</if>
            <if test="startTime != null">#{startTime},</if>
            <if test="endTime != null">#{endTime},</if>
            <if test="frequencyMinutes != null">#{frequencyMinutes},</if>
            <if test="cycleType != null">#{cycleType},</if>
            <if test="cycleValue != null">#{cycleValue},</if>
            <if test="status != null and status != ''">#{status},</if>
            <if test="remark != null">#{remark},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="updateTime != null">#{updateTime},</if>
         </trim>
    </insert>

    <update id="updateRobotOpsBroadcastTask" parameterType="RobotOpsBroadcastTask">
        update robot_ops_broadcast_task
        <trim prefix="SET" suffixOverrides=",">
            <if test="taskName != null and taskName != ''">task_name = #{taskName},</if>
            <if test="contentId != null">content_id = #{contentId},</if>
            <if test="startTime != null">start_time = #{startTime},</if>
            <if test="endTime != null">end_time = #{endTime},</if>
            <if test="frequencyMinutes != null">frequency_minutes = #{frequencyMinutes},</if>
            <if test="cycleType != null">cycle_type = #{cycleType},</if>
            <if test="cycleValue != null">cycle_value = #{cycleValue},</if>
            <if test="status != null and status != ''">status = #{status},</if>
            <if test="remark != null">remark = #{remark},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteRobotOpsBroadcastTaskById" parameterType="Long">
        delete from robot_ops_broadcast_task where id = #{id}
    </delete>

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