正在显示
9 个修改的文件
包含
290 行增加
和
22 行删除
| @@ -20,6 +20,8 @@ const meeting = require('./routes/meeting') | @@ -20,6 +20,8 @@ const meeting = require('./routes/meeting') | ||
| 20 | const studentMeeting = require('./routes/studentMeeting') | 20 | const studentMeeting = require('./routes/studentMeeting') |
| 21 | const upload = require('./routes/upload') | 21 | const upload = require('./routes/upload') |
| 22 | const email = require('./routes/email') | 22 | const email = require('./routes/email') |
| 23 | +const RecordInfo = require('./routes/RecordInfo') | ||
| 24 | + | ||
| 23 | 25 | ||
| 24 | 26 | ||
| 25 | 27 | ||
| @@ -51,7 +53,6 @@ app.use(async (ctx, next) => { | @@ -51,7 +53,6 @@ app.use(async (ctx, next) => { | ||
| 51 | try{ | 53 | try{ |
| 52 | const start = new Date(); | 54 | const start = new Date(); |
| 53 | const url = ctx.request.url.split('?'); | 55 | const url = ctx.request.url.split('?'); |
| 54 | - console.log(url); | ||
| 55 | if(filterUrl.indexOf(url[0]) != -1){ | 56 | if(filterUrl.indexOf(url[0]) != -1){ |
| 56 | 57 | ||
| 57 | await next(); | 58 | await next(); |
| @@ -78,6 +79,7 @@ app.use(meeting.routes(), meeting.allowedMethods()) | @@ -78,6 +79,7 @@ app.use(meeting.routes(), meeting.allowedMethods()) | ||
| 78 | app.use(studentMeeting.routes(), studentMeeting.allowedMethods()) | 79 | app.use(studentMeeting.routes(), studentMeeting.allowedMethods()) |
| 79 | app.use(upload.routes(), upload.allowedMethods()) | 80 | app.use(upload.routes(), upload.allowedMethods()) |
| 80 | app.use(email.routes(), email.allowedMethods()) | 81 | app.use(email.routes(), email.allowedMethods()) |
| 82 | +app.use(RecordInfo.routes(), RecordInfo.allowedMethods()) | ||
| 81 | 83 | ||
| 82 | 84 | ||
| 83 | 85 |
controller/recordInfoController.js
0 → 100644
| 1 | +const recordInfoService = require('../services/recordInfoService') | ||
| 2 | +const moment = require('moment') | ||
| 3 | +const uuid = require('../util/UuidUtil'); | ||
| 4 | +const recordStatus =require( '../model/RecordStatusModel') | ||
| 5 | +const recordInfo =require( '../model/RecordInfoModel'); | ||
| 6 | + | ||
| 7 | + | ||
| 8 | +function recordInfoController(){ | ||
| 9 | + | ||
| 10 | +}; | ||
| 11 | +recordInfoController.prototype.updaterecordInfo = async(ctx,next)=>{ | ||
| 12 | + try { | ||
| 13 | + const channel = ctx.params.channel; | ||
| 14 | + let updaterecordInfo = await recordInfoService.updaterecordInfo(channel) | ||
| 15 | + return updaterecordInfo | ||
| 16 | + } catch (error) { | ||
| 17 | + console.error(error); | ||
| 18 | + throw error; | ||
| 19 | + } | ||
| 20 | +} | ||
| 21 | +recordInfoController.prototype.getRecordInfo = async(ctx,next)=>{ | ||
| 22 | + try { | ||
| 23 | + const channel = ctx.params.channel; | ||
| 24 | + let channelinfo = await recordInfoService.getRecordInfo(channel); | ||
| 25 | + return channelinfo; | ||
| 26 | + } catch (error) { | ||
| 27 | + console.error(error); | ||
| 28 | + throw error; | ||
| 29 | + } | ||
| 30 | +} | ||
| 31 | +recordInfoController.prototype.addRecordInfo = async(ctx,next)=>{ | ||
| 32 | + try { | ||
| 33 | + let params = ctx.request.body; | ||
| 34 | + let recordInfo = await recordInfoService.addRecordInfo(params) | ||
| 35 | + return recordInfo | ||
| 36 | + } catch (error) { | ||
| 37 | + console.error(error); | ||
| 38 | + throw error; | ||
| 39 | + } | ||
| 40 | +} | ||
| 41 | +recordInfoController.prototype.addRecordInfo = async(ctx,next)=>{ | ||
| 42 | + try { | ||
| 43 | + let params = ctx.request.body; | ||
| 44 | + let recordInfo = await recordInfoService.addRecordInfo(params) | ||
| 45 | + return recordInfo | ||
| 46 | + } catch (error) { | ||
| 47 | + console.error(error); | ||
| 48 | + throw error; | ||
| 49 | + } | ||
| 50 | +} | ||
| 51 | +recordInfoController.prototype.stopRecording = async(ctx,next)=>{ | ||
| 52 | + try { | ||
| 53 | + const channel = ctx.request.body.channel; | ||
| 54 | + const body = ctx.request.body; | ||
| 55 | + body.id = uuid.db32() | ||
| 56 | + body.createTime = new Date().getTime(); | ||
| 57 | + let old = await recordStatus.findOne({where:{channel:channel,status:0}}) | ||
| 58 | + if(old){ | ||
| 59 | + throw new Error('没有正在录制的课堂') | ||
| 60 | + } | ||
| 61 | + let r = await recordInfo.create(body); | ||
| 62 | + let recording = await recordStatus.update({status:0},{where:{channel:channel}}); | ||
| 63 | + | ||
| 64 | + return recording; | ||
| 65 | + } catch (error) { | ||
| 66 | + console.error(error); | ||
| 67 | + throw error; | ||
| 68 | + } | ||
| 69 | +} | ||
| 70 | +module.exports = new recordInfoController() |
model/RecordInfoModel.js
0 → 100644
| 1 | +var sequelize = require('../config'); | ||
| 2 | +var Sequelize = require('sequelize'); | ||
| 3 | +var uuid = require('../util/UuidUtil') | ||
| 4 | + | ||
| 5 | + | ||
| 6 | +var recordInfo = sequelize.define('3m_record_info', { | ||
| 7 | + id: { | ||
| 8 | + type: Sequelize.STRING(32), | ||
| 9 | + defaultValue:uuid.db32(), | ||
| 10 | + allowNull: false, | ||
| 11 | + unique: true, | ||
| 12 | + primaryKey: true, | ||
| 13 | + field: "id" | ||
| 14 | + }, | ||
| 15 | + appId: { | ||
| 16 | + allowNull: false, | ||
| 17 | + type:Sequelize.STRING(50), | ||
| 18 | + field: "app_id" | ||
| 19 | + }, | ||
| 20 | + channel: { | ||
| 21 | + allowNull: false, | ||
| 22 | + type:Sequelize.STRING(50), | ||
| 23 | + field: "channel" | ||
| 24 | + }, | ||
| 25 | + channelKey:{ | ||
| 26 | + type:Sequelize.STRING(50), | ||
| 27 | + field: "channel_key" | ||
| 28 | + }, | ||
| 29 | + uid:{ | ||
| 30 | + type:Sequelize.STRING(50), | ||
| 31 | + field: "uid" | ||
| 32 | + }, | ||
| 33 | + userId:{ | ||
| 34 | + type:Sequelize.STRING(50), | ||
| 35 | + field: "user_id" | ||
| 36 | + }, | ||
| 37 | + userRole:{ | ||
| 38 | + type:Sequelize.STRING(50), | ||
| 39 | + field: "user_role" | ||
| 40 | + }, | ||
| 41 | + userName:{ | ||
| 42 | + type:Sequelize.STRING(50), | ||
| 43 | + field: "user_name" | ||
| 44 | + }, | ||
| 45 | + timestamp:{ | ||
| 46 | + type:Sequelize.STRING(50), | ||
| 47 | + field: "timestamp" | ||
| 48 | + }, | ||
| 49 | + recordTimestamp:{ | ||
| 50 | + type:Sequelize.STRING(50), | ||
| 51 | + field: "recordTimestamp" | ||
| 52 | + }, | ||
| 53 | + createTime:{ | ||
| 54 | + type:Sequelize.STRING(50), | ||
| 55 | + field: "create_time" | ||
| 56 | + }, | ||
| 57 | + status:{ | ||
| 58 | + type:Sequelize.INTEGER(1), | ||
| 59 | + field:'status', | ||
| 60 | + }, | ||
| 61 | + type:{ | ||
| 62 | + type:Sequelize.INTEGER(1), | ||
| 63 | + field:'type', | ||
| 64 | + } | ||
| 65 | + | ||
| 66 | + | ||
| 67 | +}, { | ||
| 68 | + timestamps: false, | ||
| 69 | + freezeTableName: true | ||
| 70 | + }); | ||
| 71 | + | ||
| 72 | +module.exports = recordInfo; |
model/RecordStatusModel.js
0 → 100644
| 1 | +var sequelize = require('../config'); | ||
| 2 | +var Sequelize = require('sequelize'); | ||
| 3 | +var uuid = require('../util/UuidUtil') | ||
| 4 | + | ||
| 5 | + | ||
| 6 | +var recordStatus = sequelize.define('3m_record_status', { | ||
| 7 | + id: { | ||
| 8 | + type: Sequelize.STRING(32), | ||
| 9 | + defaultValue:uuid.db32(), | ||
| 10 | + allowNull: false, | ||
| 11 | + unique: true, | ||
| 12 | + primaryKey: true, | ||
| 13 | + field: "id" | ||
| 14 | + }, | ||
| 15 | + channel:{ | ||
| 16 | + type:Sequelize.STRING(50), | ||
| 17 | + field: "channel" | ||
| 18 | + }, | ||
| 19 | + status:{ | ||
| 20 | + type:Sequelize.INTEGER(1), | ||
| 21 | + field:'status', | ||
| 22 | + }, | ||
| 23 | +}, { | ||
| 24 | + timestamps: false, | ||
| 25 | + freezeTableName: true | ||
| 26 | +}); | ||
| 27 | + | ||
| 28 | +module.exports = recordStatus; |
routes/RecordInfo.js
0 → 100644
| 1 | +const router = require('koa-router')() | ||
| 2 | +var meetingContoller = require('../controller/recordInfoController') | ||
| 3 | +var status = require('../util/resTemplate') | ||
| 4 | + | ||
| 5 | + | ||
| 6 | +router.prefix('/recordInfo'); | ||
| 7 | + | ||
| 8 | + | ||
| 9 | +router.put('/updaterecordInfo/:channel', async (ctx, next) => { | ||
| 10 | + try{ | ||
| 11 | + var data = await meetingContoller.updaterecordInfo(ctx, next); | ||
| 12 | + status.successTemp(ctx,200,data); | ||
| 13 | + }catch(e){ | ||
| 14 | + console.error(e) | ||
| 15 | + status.catchError(ctx,400,e.message); | ||
| 16 | + } | ||
| 17 | + }) | ||
| 18 | + router.get('/getRecordInfo/:channel', async (ctx, next) => { | ||
| 19 | + try{ | ||
| 20 | + var data = await meetingContoller.getRecordInfo(ctx, next); | ||
| 21 | + status.successTemp(ctx,200,data); | ||
| 22 | + }catch(e){ | ||
| 23 | + console.error(e) | ||
| 24 | + status.catchError(ctx,400,e.message); | ||
| 25 | + } | ||
| 26 | + }) | ||
| 27 | + | ||
| 28 | + router.post('/addRecordInfo', async (ctx, next) => { | ||
| 29 | + try{ | ||
| 30 | + var data = await meetingContoller.addRecordInfo(ctx, next); | ||
| 31 | + status.successTemp(ctx,200,data); | ||
| 32 | + }catch(e){ | ||
| 33 | + console.error(e) | ||
| 34 | + status.catchError(ctx,400,e.message); | ||
| 35 | + } | ||
| 36 | + }) | ||
| 37 | + router.post('/stopRecording', async (ctx, next) => { | ||
| 38 | + try{ | ||
| 39 | + var data = await meetingContoller.stopRecording(ctx, next); | ||
| 40 | + status.successTemp(ctx,200,data); | ||
| 41 | + }catch(e){ | ||
| 42 | + console.error(e) | ||
| 43 | + status.catchError(ctx,400,e.message); | ||
| 44 | + } | ||
| 45 | + }) | ||
| 46 | + | ||
| 47 | + module.exports = router |
| @@ -146,12 +146,12 @@ router.post('/Recording',async (ctx, next) => { | @@ -146,12 +146,12 @@ router.post('/Recording',async (ctx, next) => { | ||
| 146 | try{ | 146 | try{ |
| 147 | let body = ctx.request.body; | 147 | let body = ctx.request.body; |
| 148 | console.log() | 148 | console.log() |
| 149 | - let Recording = await shellUtil.Recording(body.appId,body.uid,body.channel,body.channelKey) | 149 | + let Recording = await shellUtil.Recording(body.appId,body.uid,body.channel,body.channelKey,body) |
| 150 | ctx.response.status= 200; | 150 | ctx.response.status= 200; |
| 151 | ctx.response.body= {msg:Recording}; | 151 | ctx.response.body= {msg:Recording}; |
| 152 | }catch(e){ | 152 | }catch(e){ |
| 153 | - console.log(e) | ||
| 154 | - status.catchError(ctx,400,e.message); | 153 | + ctx.response.status= 200; |
| 154 | + ctx.response.body= {msg:e}; | ||
| 155 | } | 155 | } |
| 156 | }) | 156 | }) |
| 157 | 157 |
services/recordInfoService.js
0 → 100644
| 1 | +const recordInfo =require( '../model/RecordInfoModel') | ||
| 2 | + | ||
| 3 | +function recordInfoService(){ | ||
| 4 | + | ||
| 5 | +} | ||
| 6 | +recordInfoService.prototype.updaterecordInfo = async(channel)=>{ | ||
| 7 | + try { | ||
| 8 | + let channelupdate = await recordInfo.update( | ||
| 9 | + {status:0}, | ||
| 10 | + {where: | ||
| 11 | + {channel:channel}}) | ||
| 12 | + return channelupdate; | ||
| 13 | + } catch (error) { | ||
| 14 | + throw error; | ||
| 15 | + } | ||
| 16 | +} | ||
| 17 | +recordInfoService.prototype.addRecordInfo = async(body) =>{ | ||
| 18 | + try { | ||
| 19 | + let addrecord = await recordInfo.create(body); | ||
| 20 | + return addrecord; | ||
| 21 | + } catch (error) { | ||
| 22 | + throw error; | ||
| 23 | + } | ||
| 24 | +} | ||
| 25 | +recordInfoService.prototype.getRecordInfo = async(channel) =>{ | ||
| 26 | + try { | ||
| 27 | + let addrecord = await recordInfo.findAll({where:{channel:channel}}); | ||
| 28 | + return addrecord; | ||
| 29 | + } catch (error) { | ||
| 30 | + throw error; | ||
| 31 | + } | ||
| 32 | +} | ||
| 33 | +module.exports = new recordInfoService(); |
| 1 | const callfile = require('child_process'); | 1 | const callfile = require('child_process'); |
| 2 | +const recordInfo =require( '../../../model/RecordInfoModel'); | ||
| 3 | +const recordStatus =require( '../../../model/RecordStatusModel') | ||
| 4 | +const uuid = require('../../UuidUtil'); | ||
| 5 | +const moment = require('moment') | ||
| 2 | 6 | ||
| 3 | 7 | ||
| 4 | function shell(){ | 8 | function shell(){ |
| 5 | 9 | ||
| 6 | } | 10 | } |
| 7 | 11 | ||
| 8 | -shell.prototype.Recording =async(appId,uid,channel,channelKey)=>{ | ||
| 9 | - return new Promise((resolve, reject) =>{ | ||
| 10 | - let shell =`cd /netWorkSchool/Agora_Recording_SDK_for_Linux_FULL/samples/ && ./Recorder_local`+ | ||
| 11 | - ` --appId ` +appId + | ||
| 12 | - //` --uid ` +uid + | ||
| 13 | - ` --channel ` + channel + | ||
| 14 | - //` --channelKey ` + channelKey + | ||
| 15 | - " --appliteDir \`pwd\`/../bin"; | ||
| 16 | - console.log(shell) | ||
| 17 | - callfile.exec(shell,function(err, stdout, stderr){ | ||
| 18 | - console.log(arguments); | ||
| 19 | - if(err){ | ||
| 20 | - reject(err); | 12 | +shell.prototype.Recording =async(appId,uid,channel,channelKey,body)=>{ |
| 13 | + // return new Promise((resolve, reject) =>{ | ||
| 14 | + try { | ||
| 15 | + body.id = uuid.db32() | ||
| 16 | + body.createTime = new Date().getTime(); | ||
| 17 | + var channelInfo = await recordStatus.findOne({where:{channel:channel}}); | ||
| 18 | + let r = await recordInfo.create(body); | ||
| 19 | + if(channelInfo){ | ||
| 20 | + if(channelInfo.status == 0){ | ||
| 21 | + var channelInfo = await recordStatus.update({status:1},{where:{channel:channel}}); | ||
| 22 | + }else if(channelInfo.status == 1){ | ||
| 23 | + throw false ; | ||
| 24 | + } | ||
| 25 | + }else{ | ||
| 26 | + var channelInfo = await recordStatus.create({id:uuid.db32(),channel:channel,status:1}); | ||
| 21 | } | 27 | } |
| 22 | - resolve(arguments); | ||
| 23 | - }) | ||
| 24 | - resolve(true) | ||
| 25 | - }) | 28 | + let shell =`cd /netWorkSchool/Agora_Recording_SDK_for_Linux_FULL/samples/ && ./Recorder_local`+ |
| 29 | + ` --appId ` +appId + | ||
| 30 | + //` --uid ` +uid + | ||
| 31 | + ` --channel ` + channel + | ||
| 32 | + //` --channelKey ` + channelKey + | ||
| 33 | + " --appliteDir \`pwd\`/../bin"; | ||
| 34 | + | ||
| 35 | + | ||
| 36 | + await callfile.exec(shell) | ||
| 37 | + return true | ||
| 38 | + } catch (error) { | ||
| 39 | + throw error | ||
| 40 | + } | ||
| 41 | + | ||
| 42 | + // }) | ||
| 26 | 43 | ||
| 27 | } | 44 | } |
| 28 | 45 |
| @@ -30,7 +30,6 @@ module.exports = { | @@ -30,7 +30,6 @@ module.exports = { | ||
| 30 | }; | 30 | }; |
| 31 | }, | 31 | }, |
| 32 | successTemp: (ctx,code,data)=>{ | 32 | successTemp: (ctx,code,data)=>{ |
| 33 | - console.log(code) | ||
| 34 | ctx.response.status= 200; | 33 | ctx.response.status= 200; |
| 35 | ctx.response.body= { | 34 | ctx.response.body= { |
| 36 | code:!data.code ? 200:data.code, | 35 | code:!data.code ? 200:data.code, |
-
请 注册 或 登录 后发表评论