package com.fs.course.mapper;

import com.fs.course.domain.FsUserCourseVideoRedPackage;
import com.fs.course.param.FsUserCourseVideoParam;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

/**
 * 课程公司红包Mapper接口
 *
 * @author fs
 * @date 2024-10-25
 */
public interface FsUserCourseVideoRedPackageMapper
{
    /**
     * 查询课程公司红包
     *
     * @param id 课程公司红包主键
     * @return 课程公司红包
     */
    public FsUserCourseVideoRedPackage selectFsUserCourseVideoRedPackageById(Long id);

    /**
     * 查询课程公司红包列表
     *
     * @param fsUserCourseVideoRedPackage 课程公司红包
     * @return 课程公司红包集合
     */
    public List<FsUserCourseVideoRedPackage> selectFsUserCourseVideoRedPackageList(FsUserCourseVideoRedPackage fsUserCourseVideoRedPackage);

    /**
     * 新增课程公司红包
     *
     * @param fsUserCourseVideoRedPackage 课程公司红包
     * @return 结果
     */
    public int insertFsUserCourseVideoRedPackage(FsUserCourseVideoRedPackage fsUserCourseVideoRedPackage);

    /**
     * 修改课程公司红包
     *
     * @param fsUserCourseVideoRedPackage 课程公司红包
     * @return 结果
     */
    public int updateFsUserCourseVideoRedPackage(FsUserCourseVideoRedPackage fsUserCourseVideoRedPackage);

    /**
     * 删除课程公司红包
     *
     * @param id 课程公司红包主键
     * @return 结果
     */
    public int deleteFsUserCourseVideoRedPackageById(Long id);

    /**
     * 批量删除课程公司红包
     *
     * @param ids 需要删除的数据主键集合
     * @return 结果
     */
    public int deleteFsUserCourseVideoRedPackageByIds(Long[] ids);
    @Update("INSERT INTO fs_user_course_video_red_package (company_id, video_id, red_packet_money) " +
            "VALUES (#{companyId}, #{videoId}, #{redPacketMoney}) " +
            "ON DUPLICATE KEY UPDATE red_packet_money = VALUES(red_packet_money);")
    void insertOrUpdateFsUserCourseVideoRedPackage(FsUserCourseVideoParam fsUserCourseVideo);

    @Select("select * from fs_user_course_video_red_package where video_id =#{videoId} and company_id = #{companyId} and period_id = #{periodId}")
    FsUserCourseVideoRedPackage selectRedPacketByCompanyId(@Param("videoId") Long videoId,@Param("companyId") Long companyId, @Param("periodId") Long periodId);

    int batchSaveFsUserCourseVideoRedPackage(@Param("list") List<FsUserCourseVideoRedPackage> redPackageList);

    int batchDeleteParams(@Param("list") List<FsUserCourseVideoRedPackage> videoRedPackageList);

    List<FsUserCourseVideoRedPackage> listByCompanyIdAndVideoIds(@Param("companyId") Long companyId, @Param("videoIdList") List<Long> videoIdList);

    List<FsUserCourseVideoRedPackage> listByRuleIds(@Param("ids") List<Long> ids);
    /**
     * 批量更新红包数据
     *
     * @param list 红包数据列表
     * @return 更新结果
     */
    int batchUpdateFsUserCourseVideoRedPackage(@Param("list") List<FsUserCourseVideoRedPackage> list);

    /**
     * 批量查询匹配的红包数据
     *
     * @param list 红包数据列表
     * @return 匹配的红包数据列表
     */
    List<FsUserCourseVideoRedPackage> selectByParamsList(@Param("list") List<FsUserCourseVideoRedPackage> list);

    int updateRedPackageByParams(FsUserCourseVideoRedPackage videoRedPackage);

    List<FsUserCourseVideoRedPackage> selectByRuleIds(@Param("ruleIds") List<Long> ruleIds);
}
