package com.fs.statis.mapper;

import com.fs.statis.domain.FsStatisSalerWatch;
import com.fs.statis.dto.StatsWatchLogPageListDTO;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

/**
 * 销售观看统计Mapper接口
 */
@Mapper
public interface FsStatisSalerWatchMapper {

    /**
     * 根据ID查询销售观看统计
     * @param id 主键ID
     * @return 销售观看统计对象
     */
    @Select("SELECT * FROM fs_statis_saler_watch WHERE id = #{id}")
    FsStatisSalerWatch findById(@Param("id") Integer id);

    /**
     * 查询所有销售观看统计
     * @return 销售观看统计列表
     */
    @Select("SELECT * FROM fs_statis_saler_watch")
    List<FsStatisSalerWatch> findAll();

    /**
     * 新增销售观看统计
     * @param fsStatisSalerWatch 销售观看统计对象
     * @return 受影响的行数
     */
    @Insert("INSERT INTO fs_statis_saler_watch (dept_id, company_user_id, train_camp_num, not_registered_num, " +
            "registered_num, reg_rate, finished_rate, offline_total, offline_not_part, offline_not_watched, " +
            "online_total, online_online_rate, online_playback_comple_rate, online_incomplete_playback, " +
            "online_complete_playback) " +
            "VALUES (#{deptId}, #{companyUserId}, #{trainCampNum}, #{notRegisteredNum}, #{registeredNum}, " +
            "#{regRate}, #{finishedRate}, #{offlineTotal}, #{offlineNotPart}, #{offlineNotWatched}, #{onlineTotal}, " +
            "#{onlineOnlineRate}, #{onlinePlaybackCompleRate}, #{onlineIncompletePlayback}, #{onlineCompletePlayback})")
    @Options(useGeneratedKeys = true, keyProperty = "id", keyColumn = "id")
    int insert(FsStatisSalerWatch fsStatisSalerWatch);

    /**
     * 更新销售观看统计
     * @param fsStatisSalerWatch 销售观看统计对象
     * @return 受影响的行数
     */
    @Update("UPDATE fs_statis_saler_watch SET " +
            "dept_id = #{deptId}, " +
            "company_user_id = #{companyUserId}, " +
            "train_camp_num = #{trainCampNum}, " +
            "not_registered_num = #{notRegisteredNum}, " +
            "registered_num = #{registeredNum}, " +
            "reg_rate = #{regRate}, " +
            "finished_rate = #{finishedRate}, " +
            "offline_total = #{offlineTotal}, " +
            "offline_not_part = #{offlineNotPart}, " +
            "offline_not_watched = #{offlineNotWatched}, " +
            "online_total = #{onlineTotal}, " +
            "online_online_rate = #{onlineOnlineRate}, " +
            "online_playback_comple_rate = #{onlinePlaybackCompleRate}, " +
            "online_incomplete_playback = #{onlineIncompletePlayback}, " +
            "online_complete_playback = #{onlineCompletePlayback} " +
            "WHERE id = #{id}")
    int update(FsStatisSalerWatch fsStatisSalerWatch);

    /**
     * 根据ID删除销售观看统计
     * @param id 主键ID
     * @return 受影响的行数
     */
    @Delete("DELETE FROM fs_statis_saler_watch WHERE id = #{id}")
    int deleteById(@Param("id") Integer id);

    List<FsStatisSalerWatch> queryList(StatsWatchLogPageListDTO param);

    void batchSave(@Param("list") List<FsStatisSalerWatch> writeData);


    List<FsStatisSalerWatch> queryPeriodList(StatsWatchLogPageListDTO param);
    List<FsStatisSalerWatch> queryTodayList(StatsWatchLogPageListDTO param);

}
