package com.fs.course.mapper;

import java.util.List;
import com.fs.course.domain.FsUserCourseStudy;
import com.fs.course.domain.FsUserCourseVideo;
import com.fs.course.param.FsUserCourseListUParam;
import com.fs.course.vo.FsUserCourseStudyListUVO;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

/**
 * 课程用户关联Mapper接口
 *
 * @author fs
 * @date 2024-05-15
 */
public interface FsUserCourseStudyMapper
{
    /**
     * 查询课程用户关联
     *
     * @param studyId 课程用户关联主键
     * @return 课程用户关联
     */
    public FsUserCourseStudy selectFsUserCourseStudyByStudyId(String studyId);

    /**
     * 查询课程用户关联列表
     *
     * @param fsUserCourseStudy 课程用户关联
     * @return 课程用户关联集合
     */
    public List<FsUserCourseStudy> selectFsUserCourseStudyList(FsUserCourseStudy fsUserCourseStudy);

    /**
     * 新增课程用户关联
     *
     * @param fsUserCourseStudy 课程用户关联
     * @return 结果
     */
    public int insertFsUserCourseStudy(FsUserCourseStudy fsUserCourseStudy);

    /**
     * 修改课程用户关联
     *
     * @param fsUserCourseStudy 课程用户关联
     * @return 结果
     */
    public int updateFsUserCourseStudy(FsUserCourseStudy fsUserCourseStudy);

    /**
     * 删除课程用户关联
     *
     * @param studyId 课程用户关联主键
     * @return 结果
     */
    public int deleteFsUserCourseStudyByStudyId(String studyId);

    /**
     * 批量删除课程用户关联
     *
     * @param studyIds 需要删除的数据主键集合
     * @return 结果
     */
    public int deleteFsUserCourseStudyByStudyIds(String[] studyIds);


    @Select({"<script> " +
            "select s.*,c.img_url  from fs_user_course_study s left join fs_user_course c on c.course_id = s.course_id " +
            "where c.is_del = 0   " +
            "<if test = ' maps.userId  '> " +
            "and s.user_id = #{maps.userId} " +
            "</if>" +
            " order by s.study_id  "+
            "</script>"})
    List<FsUserCourseStudyListUVO> selectFsUserCourseStudyListUVO(@Param("maps")FsUserCourseListUParam param);

    @Select("select * from fs_user_course_study where user_id = #{userId} and course_id = #{courseId} limit 1")
    FsUserCourseStudy selectFsUserCourseStudyByAddStudy(@Param("userId")Long userId,@Param("courseId")Long courseId);

}
