diff --git a/app.js b/app.js index 718b534..2a37ff6 100644 --- a/app.js +++ b/app.js @@ -35,9 +35,7 @@ app.use(koaBody({ multipart: true })); // middlewares app.use(cors()); -app.use(bodyparser({ - enableTypes:['json', 'form', 'text'] -})) + app.use(json()) app.use(logger()) app.use(require('koa-static')(__dirname + '/public')) diff --git a/controller/meetingController.js b/controller/meetingController.js index 9885eb1..a596a90 100644 --- a/controller/meetingController.js +++ b/controller/meetingController.js @@ -51,7 +51,7 @@ meetingController.prototype.createMeeting = async(ctx,next)=>{ 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:876, + hostPwd:meetingbody.hostPwd, //repeatmode:meetingbody.repeatmode, //是否重复周期 meetingType:meetingbody.meetingType, //课堂类型 h5Module:Number( meetingbody.h5Module), // 是否支持H5 @@ -94,13 +94,83 @@ meetingController.prototype.createMeeting = async(ctx,next)=>{ 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; - let meetingData = await meetingService.getMeeting(meetingbody,page,pageno); + var meetingData = await meetingService.getMeeting(meetingbody,page,pageno); + console.log(meetingData.meetingInfo) return meetingData; } catch (error) { throw error; diff --git a/package.json b/package.json index f41c65d..60cb808 100644 --- a/package.json +++ b/package.json @@ -10,6 +10,7 @@ }, "dependencies": { "debug": "^2.6.3", + "filepreview": "^1.0.14", "koa": "^2.2.0", "koa-better-body": "^3.0.4", "koa-body": "^2.3.0", diff --git a/services/meetingService.js b/services/meetingService.js index c51c700..78d92f2 100644 --- a/services/meetingService.js +++ b/services/meetingService.js @@ -19,9 +19,86 @@ meetingService.prototype.createMeeting = async(meetingInfo) =>{ } meetingService.prototype.getMeeting = async(queryData,page = 1,pageno =12) =>{ try { - let backMeeting = await meetingModel.findAll({where:queryData,order:[['createTime', 'DESC']], offset: (page-1)*pageno, limit: pageno}); + let 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, + ( + SELECT + COUNT(*) + FROM + 3m_student_meeting + WHERE + 3m_student_meeting.meeting_id = 3m_meeting.id + ) reservationNumber + FROM + 3m_meeting AS 3m_meeting + WHERE 3m_meeting.site_id = '` +queryData.siteId+"'"; + if(queryData.create_user){ + sql += " and 3m_meeting.create_user = '" + queryData.create_user+"'"; + } + sql += ' ORDER BY 3m_meeting.create_time DESC LIMIT '+(page-1)*pageno+' , ' +pageno + let backMeeting = await sequelize.query(sql); + //let backMeeting = await meetingModel.findAll({where:queryData,order:[['createTime', 'DESC']], offset: (page-1)*pageno, limit: pageno}); let count = await meetingModel.count({where:queryData}) - return {meetingInfo:backMeeting,count:count,page:page,pageno:pageno}; + return {meetingInfo:backMeeting[0],count:count,page:page,pageno:pageno}; } catch (error) { console.error(error) throw error;