package com.yanzhu.manage.service.impl;

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

import java.util.List;

/**
 * 用户培训视频Service业务层处理
 * 
 * @author JiangYuQi
 * @date 2024-08-25
 */
@Service
public class BusTrainingVideoUserServiceImpl implements IBusTrainingVideoUserService
{
    @Autowired
    private BusTrainingVideoUserMapper busTrainingVideoUserMapper;

    /**
     * 查询用户培训视频
     * 
     * @param id 用户培训视频主键
     * @return 用户培训视频
     */
    @Override
    public BusTrainingVideoUser selectBusTrainingVideoUserById(Long id)
    {
        return busTrainingVideoUserMapper.selectBusTrainingVideoUserById(id);
    }

    /**
     * 查询用户培训视频列表
     * 
     * @param busTrainingVideoUser 用户培训视频
     * @return 用户培训视频
     */
    @Override
    public List<BusTrainingVideoUser> selectBusTrainingVideoUserList(BusTrainingVideoUser busTrainingVideoUser)
    {
        busTrainingVideoUser.setActiveComId(SecurityUtils.getLoginUser().getProjectDeptId());
        busTrainingVideoUser.setActiveProjectId(SecurityUtils.getLoginUser().getProjectId());
        return busTrainingVideoUserMapper.selectBusTrainingVideoUserList(busTrainingVideoUser);
    }

    /**
     * 新增用户培训视频
     * 
     * @param busTrainingVideoUser 用户培训视频
     * @return 结果
     */
    @Override
    public int insertBusTrainingVideoUser(BusTrainingVideoUser busTrainingVideoUser)
    {
        busTrainingVideoUser.setCreateTime(DateUtils.getNowDate());
        busTrainingVideoUser.setCreateBy(SecurityContextHolder.getUserName());
        return busTrainingVideoUserMapper.insertBusTrainingVideoUser(busTrainingVideoUser);
    }

    /**
     * 修改用户培训视频
     * 
     * @param busTrainingVideoUser 用户培训视频
     * @return 结果
     */
    @Override
    public int updateBusTrainingVideoUser(BusTrainingVideoUser busTrainingVideoUser)
    {
        busTrainingVideoUser.setUpdateTime(DateUtils.getNowDate());
        busTrainingVideoUser.setUpdateBy(SecurityContextHolder.getUserName());
        return busTrainingVideoUserMapper.updateBusTrainingVideoUser(busTrainingVideoUser);
    }

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

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