meetingService.js 5.3 KB
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 {
        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[0],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();