recordInfoController.js 3.2 KB
const recordInfoService = require('../services/recordInfoService')
const moment = require('moment')
const uuid = require('../util/UuidUtil');
const recordStatus =require( '../model/RecordStatusModel')
const recordInfo =require( '../model/RecordInfoModel');


function recordInfoController(){

};
recordInfoController.prototype.updaterecordInfo = async(ctx,next)=>{
    try {
        const channel =  ctx.params.channel;        
        let updaterecordInfo = await recordInfoService.updaterecordInfo(channel)
        return updaterecordInfo
    } catch (error) {
        console.error(error);
        throw error;
    }
}
recordInfoController.prototype.getRecordInfo = async(ctx,next)=>{
    try {
        const channel =  ctx.params.channel;  
        let channelinfo = await recordInfoService.getRecordInfo(channel);
        return channelinfo;            
    } catch (error) {
        console.error(error);
        throw error;
    }
}
recordInfoController.prototype.addRecordInfo = async(ctx,next)=>{
    try {
        let params = ctx.request.body;        
        let recordInfo = await recordInfoService.addRecordInfo(params)
        return recordInfo
    } catch (error) {
        console.error(error);
        throw error;
    }
}
recordInfoController.prototype.addRecordInfo = async(ctx,next)=>{
    try {
        let params = ctx.request.body;        
        let recordInfo = await recordInfoService.addRecordInfo(params)
        return recordInfo
    } catch (error) {
        console.error(error);
        throw error;
    }
}
recordInfoController.prototype.stopRecording = async(ctx,next)=>{
    try {
        const channel =  ctx.request.body.channel; 
        const body =  ctx.request.body; 
        body.id =   uuid.db32() 
        body.createTime = new Date().getTime();
        let   old = await recordStatus.findOne({where:{channel:channel,status:1}})
        if(old){
            throw new Error('没有正在录制的课堂')
        }
        let  r =  await recordInfo.create(body);            
        let recording = await recordStatus.update({status:0},{where:{channel:channel}});
    
        return recording;
    } catch (error) {
        console.error(error);
        throw error;
    }
}
recordInfoController.prototype.tencentRecordInfo = async(ctx,next)=>{
    try {
        const channelId =  ctx.request.body.channelId;         
        let recordInfo = await recordInfoService.tencentRecordInfo(channelId) 
        return recordInfo;       
    } catch (error) {
        console.error(error);
        throw error;
    }
}

recordInfoController.prototype.getRecordFileURL = async(ctx,next)=>{
    try {
        const time =  ctx.request.body.time;     
        const path =  ctx.request.body.path;                 
        let recordInfo = await recordInfoService.getRecordFileURL(path,time) 
        return recordInfo;
    } catch (e) {
        console.log(e)
        throw e
    }

}
recordInfoController.prototype.getOldRecordInfo = async(ctx,next)=>{
    try {
        const meetingNumber =  ctx.request.body.meetingNumber;     
        let recordInfo = await recordInfoService.getOldRecordInfo(meetingNumber) 
        return recordInfo;
    } catch (e) {
        console.log(e)
        throw e
    }

}

module.exports = new recordInfoController()