package com.xhkjedu.sclass.service.classroom;

import com.xhkjedu.sclass.mapper.classroom.ClassroomVideoMapper;
import com.xhkjedu.sclass.model.classroom.TClassroomVideo;
import com.xhkjedu.utils.N_Utils;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

@Service
public class ClassroomVideoService {
    @Resource
    private ClassroomVideoMapper classroomVideoMapper;

    //课堂视频列表
    public List<Map> listByRoomId(Long roomid) {
        return classroomVideoMapper.listByRoomId(roomid);
    }

    //添加
    public void save(TClassroomVideo video) {
        //获取同名称、路径视频上传个数；上传过的不在保存
        Integer num = classroomVideoMapper.getNumByNamePath(video.getRvname(), video.getRvpath());
        if (num != 0) return;
        video.setCreatetime(N_Utils.getSecondTimestamp());
        classroomVideoMapper.insertSelective(video);
    }

    //删除
    public Integer deleteById(Integer id) {
        return classroomVideoMapper.deleteByPrimaryKey(id);
    }

    //修改
    public Integer update(TClassroomVideo video) {
        return classroomVideoMapper.update(video);
    }
}
