package com.fs.tag.mapper;

import java.util.List;
import java.util.Map;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.fs.tag.domain.FsVideoCourseTag;
import org.apache.ibatis.annotations.MapKey;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

/**
 * 视频小节看课标签关联Mapper接口
 *
 * @author fs
 * @date 2025-11-05
 */
public interface FsVideoCourseTagMapper extends BaseMapper<FsVideoCourseTag>{
    /**
     * 查询视频小节看课标签关联
     *
     * @param id 视频小节看课标签关联主键
     * @return 视频小节看课标签关联
     */
    FsVideoCourseTag selectFsVideoCourseTagById(Long id);

    /**
     * 查询视频小节看课标签关联列表
     *
     * @param fsVideoCourseTag 视频小节看课标签关联
     * @return 视频小节看课标签关联集合
     */
    List<FsVideoCourseTag> selectFsVideoCourseTagList(FsVideoCourseTag fsVideoCourseTag);

    /**
     * 新增视频小节看课标签关联
     *
     * @param fsVideoCourseTag 视频小节看课标签关联
     * @return 结果
     */
    int insertFsVideoCourseTag(FsVideoCourseTag fsVideoCourseTag);

    /**
     * 修改视频小节看课标签关联
     *
     * @param fsVideoCourseTag 视频小节看课标签关联
     * @return 结果
     */
    int updateFsVideoCourseTag(FsVideoCourseTag fsVideoCourseTag);

    /**
     * 删除视频小节看课标签关联
     *
     * @param id 视频小节看课标签关联主键
     * @return 结果
     */
    int deleteFsVideoCourseTagById(Long id);

    /**
     * 批量删除视频小节看课标签关联
     *
     * @param ids 需要删除的数据主键集合
     * @return 结果
     */
    int deleteFsVideoCourseTagByIds(Long[] ids);

    @Select("select * from fs_video_course_tag where corp_id=#{corpId} and video_id=#{videoId}")
    FsVideoCourseTag selectFsVideoCourseTagByCorpIdAndVideoId(@Param("corpId") String corpId, @Param("videoId") Long videoId);

    @Select("SELECT id,corp_id,video_id,watching_group_id,watched_group_id,watching_tg_id,watched_tg_id,watching_group_tag_id as watching_group_tg_id,watched_group_tag_id as watched_group_tg_id,watching_tag_id,watched_tag_id, CONCAT(corp_id, '_', video_id) AS composite_key FROM fs_video_course_tag")
    @MapKey("compositeKey")
    Map<String,FsVideoCourseTag> selectAll();
}
