package com.yanzhu.manage.service.impl;

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

import com.yanzhu.common.core.context.SecurityContextHolder;
import com.yanzhu.common.core.utils.DateUtils;
import com.yanzhu.common.security.utils.SecurityUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.yanzhu.manage.mapper.BusTrainingVideoMapper;
import com.yanzhu.manage.domain.BusTrainingVideo;
import com.yanzhu.manage.service.IBusTrainingVideoService;

/**
 * 培训视频Service业务层处理
 * 
 * @author JiangYuQi
 * @date 2024-08-25
 */
@Service
public class BusTrainingVideoServiceImpl implements IBusTrainingVideoService 
{
    @Autowired
    private BusTrainingVideoMapper busTrainingVideoMapper;

    /**
     * 查询培训视频
     * 
     * @param id 培训视频主键
     * @return 培训视频
     */
    @Override
    public BusTrainingVideo selectBusTrainingVideoById(Long id)
    {
        return busTrainingVideoMapper.selectBusTrainingVideoById(id);
    }

    /**
     * 查询培训视频列表
     * 
     * @param busTrainingVideo 培训视频
     * @return 培训视频
     */
    @Override
    public List<BusTrainingVideo> selectBusTrainingVideoList(BusTrainingVideo busTrainingVideo)
    {
        busTrainingVideo.setActiveComId(SecurityUtils.getLoginUser().getProjectDeptId());
        busTrainingVideo.setActiveProjectId(SecurityUtils.getLoginUser().getProjectId());
        return busTrainingVideoMapper.selectBusTrainingVideoList(busTrainingVideo);
    }

    /**
     * 统计培训视频列表
     *
     * @param busTrainingVideo 培训视频
     * @return 培训视频集合
     */
    @Override
    public List<Map<String, Object>> findBusTrainingVideoByLevel(BusTrainingVideo busTrainingVideo){
        busTrainingVideo.setActiveComId(SecurityUtils.getLoginUser().getProjectDeptId());
        busTrainingVideo.setActiveProjectId(SecurityUtils.getLoginUser().getProjectId());
        return busTrainingVideoMapper.findBusTrainingVideoByLevel(busTrainingVideo);
    }

    /**
     * 新增培训视频
     * 
     * @param busTrainingVideo 培训视频
     * @return 结果
     */
    @Override
    public int insertBusTrainingVideo(BusTrainingVideo busTrainingVideo)
    {
        busTrainingVideo.setCreateTime(DateUtils.getNowDate());
        busTrainingVideo.setCreateBy(SecurityContextHolder.getUserName());
        return busTrainingVideoMapper.insertBusTrainingVideo(busTrainingVideo);
    }

    /**
     * 修改培训视频
     * 
     * @param busTrainingVideo 培训视频
     * @return 结果
     */
    @Override
    public int updateBusTrainingVideo(BusTrainingVideo busTrainingVideo)
    {
        busTrainingVideo.setUpdateTime(DateUtils.getNowDate());
        busTrainingVideo.setUpdateBy(SecurityContextHolder.getUserName());
        return busTrainingVideoMapper.updateBusTrainingVideo(busTrainingVideo);
    }

    /**
     * 批量删除培训视频
     * 
     * @param ids 需要删除的培训视频主键
     * @return 结果
     */
    @Override
    public int deleteBusTrainingVideoByIds(Long[] ids)
    {
        return busTrainingVideoMapper.deleteBusTrainingVideoByIds(ids);
    }

    /**
     * 删除培训视频信息
     * 
     * @param id 培训视频主键
     * @return 结果
     */
    @Override
    public int deleteBusTrainingVideoById(Long id)
    {
        return busTrainingVideoMapper.deleteBusTrainingVideoById(id);
    }
}
