<?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.RobotOpsBroadcastContentMapper">

    <resultMap type="RobotOpsBroadcastContent" id="RobotOpsBroadcastContentResult">
        <result property="id"    column="id"    />
        <result property="contentName"    column="content_name"    />
        <result property="contentType"    column="content_type"    />
        <result property="broadcastText"    column="broadcast_text"    />
        <result property="status"    column="status"    />
        <result property="remark"    column="remark"    />
        <result property="audioPath"    column="audio_path"    />
        <result property="audioStatus"    column="audio_status"    />
        <result property="audioTaskId"    column="audio_task_id"    />
        <result property="audioDuration"    column="audio_duration"    />
        <result property="audioErrorMsg"    column="audio_error_msg"    />
        <result property="createTime"    column="create_time"    />
        <result property="updateTime"    column="update_time"    />
        <result property="createBy"    column="create_by"    />
        <result property="updateBy"    column="update_by"    />
    </resultMap>

    <sql id="selectRobotOpsBroadcastContentVo">
        select id, content_name, content_type, broadcast_text, status, remark,
               audio_path, audio_status, audio_task_id, audio_duration, audio_error_msg,
               create_time, update_time, create_by, update_by
        from robot_ops_broadcast_content
    </sql>

    <select id="selectRobotOpsBroadcastContentList" parameterType="RobotOpsBroadcastContent" resultMap="RobotOpsBroadcastContentResult">
        <include refid="selectRobotOpsBroadcastContentVo"/>
        <where>
            <if test="contentName != null  and contentName != ''"> and content_name like concat('%', #{contentName}, '%')</if>
            <if test="contentType != null "> and content_type = #{contentType}</if>
            <if test="broadcastText != null  and broadcastText != ''"> and broadcast_text = #{broadcastText}</if>
            <if test="status != null  and status != ''"> and status = #{status}</if>
            <if test="audioStatus != null and audioStatus != ''"> and audio_status = #{audioStatus}</if>
        </where>
    </select>

    <select id="selectRobotOpsBroadcastContentById" parameterType="Long" resultMap="RobotOpsBroadcastContentResult">
        <include refid="selectRobotOpsBroadcastContentVo"/>
        where id = #{id}
    </select>

    <insert id="insertRobotOpsBroadcastContent" parameterType="RobotOpsBroadcastContent" useGeneratedKeys="true" keyProperty="id">
        insert into robot_ops_broadcast_content
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="contentName != null and contentName != ''">content_name,</if>
            <if test="contentType != null">content_type,</if>
            <if test="broadcastText != null and broadcastText != ''">broadcast_text,</if>
            <if test="status != null and status != ''">status,</if>
            <if test="remark != null">remark,</if>
            <if test="audioPath != null">audio_path,</if>
            <if test="audioStatus != null">audio_status,</if>
            <if test="audioTaskId != null">audio_task_id,</if>
            <if test="audioDuration != null">audio_duration,</if>
            <if test="audioErrorMsg != null">audio_error_msg,</if>
            <if test="createTime != null">create_time,</if>
            <if test="updateTime != null">update_time,</if>
            <if test="createBy != null and createBy != ''">create_by,</if>
            <if test="updateBy != null">update_by,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="contentName != null and contentName != ''">#{contentName},</if>
            <if test="contentType != null">#{contentType},</if>
            <if test="broadcastText != null and broadcastText != ''">#{broadcastText},</if>
            <if test="status != null and status != ''">#{status},</if>
            <if test="remark != null">#{remark},</if>
            <if test="audioPath != null">#{audioPath},</if>
            <if test="audioStatus != null">#{audioStatus},</if>
            <if test="audioTaskId != null">#{audioTaskId},</if>
            <if test="audioDuration != null">#{audioDuration},</if>
            <if test="audioErrorMsg != null">#{audioErrorMsg},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="updateTime != null">#{updateTime},</if>
            <if test="createBy != null and createBy != ''">#{createBy},</if>
            <if test="updateBy != null">#{updateBy},</if>
         </trim>
    </insert>

    <update id="updateRobotOpsBroadcastContent" parameterType="RobotOpsBroadcastContent">
        update robot_ops_broadcast_content
        <trim prefix="SET" suffixOverrides=",">
            <if test="contentName != null and contentName != ''">content_name = #{contentName},</if>
            <if test="contentType != null">content_type = #{contentType},</if>
            <if test="broadcastText != null and broadcastText != ''">broadcast_text = #{broadcastText},</if>
            <if test="status != null and status != ''">status = #{status},</if>
            <if test="remark != null">remark = #{remark},</if>
            <if test="audioPath != null">audio_path = #{audioPath},</if>
            <if test="audioStatus != null">audio_status = #{audioStatus},</if>
            <if test="audioTaskId != null">audio_task_id = #{audioTaskId},</if>
            <if test="audioDuration != null">audio_duration = #{audioDuration},</if>
            <if test="audioErrorMsg != null">audio_error_msg = #{audioErrorMsg},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
            <if test="createBy != null and createBy != ''">create_by = #{createBy},</if>
            <if test="updateBy != null">update_by = #{updateBy},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteRobotOpsBroadcastContentById" parameterType="Long">
        delete from robot_ops_broadcast_content where id = #{id}
    </delete>

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