meetingController.js
9.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
var userModel = require('../model/userModel');
var siteModel = require('../model/siteModel');
const moment = require('moment')
var saitMd5 = require('../util/saltMD5')
var status = require('../util/resTemplate')
const meetingService = require('../services/meetingService')
const uuid = require('../util/UuidUtil')
const emailUtil = require('../util/emailUtil')
const request = require('request')
const xml2js = require('xml2js');
const requestUtil = require('../util/requestUtil')
const builder = new xml2js.Builder(); // JSON->xml
const parser = new xml2js.Parser(); //xml -> json
function meetingController(){
};
meetingController.prototype.createMeeting = async(ctx,next)=>{
try {
let meetingbody = ctx.request.body;
if(!meetingbody.presenterPassword){
return status.paramError('meetingName');
}else if(!meetingbody.meetingName){
return status.paramError('meetingName','不能为空');
}
let num = JSON.stringify(Math.floor(Math.random() * 99999) + 1000)
let site = await siteModel.findOne({where:{siteId:meetingbody.siteId}})
let authIdMd5 = site.siteKey+meetingbody.siteId+num+meetingbody.userId+meetingbody.userType+123321
console.log(authIdMd5)
let meeting = {
siteId:meetingbody.siteId, //站点ID
mtgKey:meetingbody.mtgKey ? meetingbody.mtgKey:num,//课堂序号
mtgTitle:meetingbody.meetingName, //课堂名字
language:2,//语言
userId:meetingbody.userId,
userName:meetingbody.userName,//用户名
userType:meetingbody.userType, //用户类型用户类型:1:主持人(所有权限)2:主讲人(不能操作摄像头) 8:普通与会者32: 监课人员
meetingType:meetingbody.meetingType ,//1、互动 2、直播;默认为1
timestamp:123321,
autoRecord:meetingbody.autoRecord, //是否自动录制:(1是,0否)
interaction:meetingbody.interaction,
backUrl:meetingbody.backUrl,// 课堂结束回调地址
mediaID:meetingbody.mediaID,//伴音id
meetingContent:meetingbody.meetingContent, //课堂描述
create_user:meetingbody.userName, //创建用户名
duration:meetingbody.duration,//持续时长
presenterPassword:meetingbody.presenterPassword, //主讲人密码
startTime: moment(meetingbody.beginTime).format("YYYY-MM-DD HH:MM:SS "), //开始时间
endTime: moment(meetingbody.endTime).format("YYYY-MM-DD HH:MM:SS"), // 结束时间
isPublic:meetingbody.isPublic, //是否公开课
hostPwd:meetingbody.hostPwd,
//repeatmode:meetingbody.repeatmode, //是否重复周期
meetingType:meetingbody.meetingType, //课堂类型
h5Module:Number( meetingbody.h5Module), // 是否支持H5
//attendeePassword:meetingbody.attendeePassword, //学生密码
videoModule:meetingbody.videoModule, //视频是否启用
//chatInterval:meetingbody.chatInterval, //聊天延时时间
//aheadTime:Number( meetingbody.aheadTime), // 提前进入课堂时间
maxVideoChannels:meetingbody.maxVideoChannels, //最大视频路数
maxAudioChannels:meetingbody.max_audioChannels, // 最大音频路数
videoQuality:meetingbody.video_quality, //视频画质
//pagenaviUserprivilege:meetingbody.pagenaviUserprivilege, //换页权限是否开启
//markerUserprivilege:meetingbody.markerUserprivilege, // 批注权限是否开启
//chatToNormalUserprivilege:meetingbody.chatToNormalUserprivilege, //与参会者聊天权限是否开启
//chatToHostUserprivilege:meetingbody.chatToHostUserprivilege, //与主持人聊天权限是否开启
docModule:meetingbody.docModule, //文档共享是否开启
screenModule:meetingbody.screenModule, //屏幕共享是否开启
mediaModule:meetingbody.mediaModule, //媒体共享是否开启
whiteboardModule:meetingbody.whiteboardModule, //白板共享是否开启
recordModule:meetingbody.recordModule, //录制是否启用
//chatModule:meetingbody.chatModule, //聊天模式是否启用
authId:saitMd5.md5(authIdMd5)
}
builder.options.rootName = 'param'
console.log(JSON.stringify(meeting))
var xml = builder.buildObject(meeting);
console.log(xml)
let info = await requestUtil.post('http://markettest.xuedianyun.com/3m/meeting/join_mtg.do',xml);
var jsonXml = await requestUtil.json2xml(info);
console.log('json string',jsonXml)
let backJsonMeeting ={
code:jsonXml.result.errorCode,
meetingUrl:jsonXml.result.url[0]//+'?param='+jsonXml.result.param[0],
}
return backJsonMeeting;
} catch (error) {
throw error;
}
}
meetingController.prototype.getMeeting = async(ctx,next) =>{
try {
var sql = `SELECT
id,
meeting_number AS meetingNumber,
meeting_name AS meetingName,
meeting_content AS meetingContent,
create_user,
create_time AS createTime,
begin_time AS beginTime,
end_time AS endTime,
invite_user AS inviteUser,
meeting_type AS meetingType,
meeting_status AS meetingStatus,
user_ip AS userIp,
meeting_key AS meetingKey,
host_password AS hostPassword,
presenter_password AS presenterPassword,
assistant_password AS assistantPassword,
attendee_password AS attendeePassword,
capacity,
top_node_id AS topNodeId,
top_node_addr AS topNodeAddr,
user_data AS userData,
site_id AS siteId,
classroom_number AS classroomNumber,
ui_language AS uiLanguage,
is_public AS isPublic,
control_mode AS controlMode,
mic_auto AS micAuto,
has_interaction AS hasInteraction,
auto_record AS autoRecord,
max_videoChannels AS maxVideoChannels,
max_audioChannels AS maxAudioChannels,
video_quality AS videoQuality,
pagenavi_Userprivilege AS pagenaviUserprivilege,
marker_Userprivilege AS markerUserprivilege,
chatToNormal_Userprivilege AS chatToNormalUserprivilege,
chatToHost_Userprivilege AS chatToHostUserprivilege,
doc_module AS docModule,
screen_module AS screenModule,
media_module AS mediaModule,
whiteboard_module AS whiteboardModule,
record_module AS recordModule,
video_module AS videoModule,
userList_module AS userListModule,
chat_module AS chatModule,
cycle,
repeatmode,
endmode,
finalenddate,
endcount,
repeatday,
repeatweek,
repeatmonthday,
repeatmonthweekweek,
repeatmonthweekday,
frequency,
month_type AS monthType,
inviter_radio AS inviterRadio,
ahead_time AS aheadTime,
chat_interval AS chatInterval,
h5_Module AS h5Module
FROM
3m_meeting AS 3m_meeting
WHERE
3m_meeting.site_id = 'networkschool'
ORDER BY
3m_meeting.create_time DESC
LIMIT 0,
4;`
let meetingbody = ctx.request.body;
if(!meetingbody.siteId){
return status.paramError('siteId');
}
let page = ctx.header.page ? Number(ctx.header.page):ctx.header.page;
let pageno = ctx.header.pageno ? Number(ctx.header.pageno):ctx.header.pageno;
var meetingData = await meetingService.getMeeting(meetingbody,page,pageno);
return meetingData;
} catch (error) {
throw error;
}
}
meetingController.prototype.delMeeting = async(ctx,next) =>{
try {
const meetingId = ctx.params.meetingId;
let delMeetingData = await meetingService.delMeeting(meetingId);
return delMeetingData
} catch (error) {
throw error;
}
}
meetingController.prototype.updateMeeting = async(ctx,next) =>{
try {
let params = ctx.request.body;
const meetingId = ctx.params.meetingId;
let updateMeeting = meetingService.updateMeeting(params,meetingId)
return updateMeeting;
} catch (error) {
console.log(error)
throw error
}
}
module.exports = new meetingController()