meetingService.js
1.9 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
var meetingModel = require('../model/meetingModel');
var status = require('../util/resTemplate');
var saitMd5 = require('../util/saltMD5');
var sequelize = require('../config');
var tokenUtil = require('../util/tokenUtil');
var co = require('co');
function meetingService(){
}
meetingService.prototype.createMeeting = async(meetingInfo) =>{
try {
let backMeeting = await meetingModel.create(meetingInfo);
return backMeeting
} catch (error) {
throw error
}
}
meetingService.prototype.getMeeting = async(queryData,page = 1,pageno =12) =>{
try {
console.log(queryData)
console.log(pageno,page,(page-1)*pageno)
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};
} catch (error) {
console.error(error)
throw error;
}
}
meetingService.prototype.delMeeting = async(meetingId) =>{
try {
let Meeting = await meetingModel.findOne({where:{id:meetingId}});
if(!Meeting){
return {code:11,msg:'课堂不存在'}
}
let backMeeting = await meetingModel.destroy({where:{id:meetingId}});
return backMeeting
} catch (error) {
throw error;
}
}
meetingService.prototype.updateMeeting = async(params,meetingId) =>{
try {
let Meeting = await meetingModel.findOne({where:{id:meetingId}});
if(!Meeting){
return {code:11,msg:'课堂不存在'}
}
let backMeeting = await meetingModel.update({where:{id:meetingId}});
return backMeeting
} catch (error) {
console.error(error);
throw error
}
}
module.exports = new meetingService();