diff --git a/controller/meetingController.js b/controller/meetingController.js index 6a998fc..a02e23c 100644 --- a/controller/meetingController.js +++ b/controller/meetingController.js @@ -100,6 +100,9 @@ meetingController.prototype.getMeeting = async(ctx,next) =>{ } let page = ctx.header.page ? Number(ctx.header.page):ctx.header.page; let pageno = ctx.header.pageno; + if(ctx.header.type == 8){ + pageno = 8; + } let meetingData = await meetingService.getMeeting(meetingbody,page,pageno); return meetingData; } catch (error) { diff --git a/controller/studentMeetingController.js b/controller/studentMeetingController.js index 6b0e161..0844876 100644 --- a/controller/studentMeetingController.js +++ b/controller/studentMeetingController.js @@ -31,5 +31,18 @@ studentMeetingController.prototype.addStudentMeeting = async(ctx, next)=>{ } } +studentMeetingController.prototype.getStudentMeetingCount = async(ctx, next) =>{ + try { + let meetingId = ctx.params.meetingId; + if(!meetingId){ + return status.paramError('meetingId'); + } + let sn = await studentMeetingService.getStudentMeetingCount(meetingId); + return sn + } catch (error) { + throw error; + } +} + module.exports = new studentMeetingController(); \ No newline at end of file diff --git a/routes/studentMeeting.js b/routes/studentMeeting.js index f112b17..e732402 100644 --- a/routes/studentMeeting.js +++ b/routes/studentMeeting.js @@ -17,5 +17,18 @@ router.post('/addStudentMeeting',async (ctx, next) => { } }) + /** + * 查询课堂预约人数 + */ +router.get('/getStudentMeetingCount/:meetingId',async (ctx, next) => { + try{ + var data = await studentMeetingController.getStudentMeetingCount(ctx, next); + status.successTemp(ctx,200,data); + }catch(e){ + console.log(e) + status.catchError(ctx,400,e.message); + } +}) + module.exports = router; \ No newline at end of file diff --git a/services/studentMeetingService.js b/services/studentMeetingService.js index c961be6..0752fa4 100644 --- a/services/studentMeetingService.js +++ b/services/studentMeetingService.js @@ -19,11 +19,11 @@ sutudentMeetingService.prototype.addStudentMeeting = async(body)=>{ t.rollback(); return {code:300,msg:'课堂不存在'} } - let sm = await sutudentMeeting.create(body); - let MeetingBack = await meetingModel.update( - {reservationNumber:Meeting.reservationNumber+1}, - {where:{id:body.meetingId}}, - {transaction: t}); + let sm = await sutudentMeeting.create(body,{transaction: t}); + // let MeetingBack = await meetingModel.update( + // {reservationNumber:Meeting.reservationNumber+1}, + // {where:{id:body.meetingId}}, + // {transaction: t}); t.commit(); return sm; } catch (error) { @@ -32,4 +32,14 @@ sutudentMeetingService.prototype.addStudentMeeting = async(body)=>{ } } +sutudentMeetingService.prototype.getStudentMeetingCount = async(meetingId) =>{ + try { + let sm = await sutudentMeeting.count({where:{meetingId:meetingId}}) + return sm; + } catch (error) { + console.log(error) + throw error; + } +} + module.exports = new sutudentMeetingService(); \ No newline at end of file