LiveDictMapper.xml 2.64 KB
<?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.subsidy.mapper.LiveDictMapper">

    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="com.subsidy.model.LiveDictDO">
        <id column="id" property="id" />
        <result column="create_date" property="createDate" />
        <result column="update_date" property="updateDate" />
        <result column="delete_date" property="deleteDate" />
        <result column="channel" property="channel" />
        <result column="live_name" property="liveName" />
        <result column="start_time" property="startTime" />
        <result column="playback_status" property="playbackStatus" />
        <result column="live_status" property="liveStatus" />
    </resultMap>

    <!-- 通用查询结果列 -->
    <sql id="Base_Column_List">
        create_date,
        update_date,
        delete_date,
        id, channel, live_name, start_time, playback_status, live_status
    </sql>

    <select id="allLives" resultType="com.subsidy.vo.live.AllLivesVO">
        SELECT
            distinct t.id,
            t.channel,
            t.live_name,
            t.start_time,
            t.live_status
        FROM
            live_dict t
            LEFT JOIN live_classes t2 ON t.id = t2.live_id
        WHERE
            t.delete_date IS NULL
            AND t2.delete_date IS NULL
            <if test="liveName != null and liveName != ''">
                and t.live_name like concat('%',#{liveName} ,'%')
            </if>
            <if test="liveStatus != null and liveStatus != ''">
                and t.live_status = #{liveStatus}
            </if>
            order by t.create_date desc
    </select>

    <select id="liveClasses" parameterType="long" resultType="com.subsidy.vo.live.LiveClassesVO">
        SELECT
            distinct t2.id,
            t2.class_name
        FROM
            live_classes t
            LEFT JOIN class_dict t2 ON t.class_id = t2.id
        WHERE
            t.delete_date IS NULL
            AND t2.delete_date IS NULL
            and t.live_id = #{liveId}
    </select>

    <select id="liveClassesIds" parameterType="long" resultType="long">
        SELECT
            t2.id
        FROM
            live_classes t
            LEFT JOIN class_dict t2 ON t.class_id = t2.id
        WHERE
            t.delete_date IS NULL
            AND t2.delete_date IS NULL
            and t.live_id = #{liveId}
    </select>

    <update id="updateStatus" parameterType="long">
        update live_dict set live_status = '已开始' where id = #{id}
    </update>
</mapper>