最近2018中文字幕在日韩欧美国产成人片_国产日韩精品一区二区在线_在线观看成年美女黄网色视频_国产精品一区三区五区_国产精彩刺激乱对白_看黄色黄大色黄片免费_人人超碰自拍cao_国产高清av在线_亚洲精品电影av_日韩美女尤物视频网站

RELATEED CONSULTING
相關(guān)咨詢
選擇下列產(chǎn)品馬上在線溝通
服務(wù)時(shí)間:8:30-17:00
你可能遇到了下面的問題
關(guān)閉右側(cè)工具欄

新聞中心

這里有您想知道的互聯(lián)網(wǎng)營(yíng)銷解決方案
前端項(xiàng)目:基于Nodejs+vue開發(fā)實(shí)現(xiàn)酒店管理系統(tǒng)-創(chuàng)新互聯(lián)

作者主頁:編程指南針

創(chuàng)新互聯(lián)不只是一家網(wǎng)站建設(shè)的網(wǎng)絡(luò)公司;我們對(duì)營(yíng)銷、技術(shù)、服務(wù)都有自己獨(dú)特見解,公司采取“創(chuàng)意+綜合+營(yíng)銷”一體化的方式為您提供更專業(yè)的服務(wù)!我們經(jīng)歷的每一步也許不一定是最完美的,但每一步都有值得深思的意義。我們珍視每一份信任,關(guān)注我們的成都網(wǎng)站設(shè)計(jì)、網(wǎng)站制作質(zhì)量和服務(wù)品質(zhì),在得到用戶滿意的同時(shí),也能得到同行業(yè)的專業(yè)認(rèn)可,能夠?yàn)樾袠I(yè)創(chuàng)新發(fā)展助力。未來將繼續(xù)專注于技術(shù)創(chuàng)新,服務(wù)升級(jí),滿足企業(yè)一站式營(yíng)銷型網(wǎng)站建設(shè)需求,讓再小的品牌網(wǎng)站建設(shè)也能產(chǎn)生價(jià)值!

作者簡(jiǎn)介:Java領(lǐng)域優(yōu)質(zhì)創(chuàng)作者、博客專家 、掘金特邀作者、多年架構(gòu)師設(shè)計(jì)經(jīng)驗(yàn)、騰訊課堂常駐講師

主要內(nèi)容:Java項(xiàng)目、畢業(yè)設(shè)計(jì)、簡(jiǎn)歷模板、學(xué)習(xí)資料、面試題庫、技術(shù)互助

文末獲取源碼?

項(xiàng)目編號(hào):BS-QD-KS-002

一,項(xiàng)目簡(jiǎn)介

本項(xiàng)目使用純前端技術(shù)開發(fā)實(shí)現(xiàn)一個(gè)酒店管理系統(tǒng),前端采用VUE開發(fā)實(shí)現(xiàn),后臺(tái)通過NODEJS作為服務(wù)器開發(fā)實(shí)現(xiàn),主要實(shí)現(xiàn)了酒店管理系統(tǒng)中的:房型管理、房間管理、顧客管理、訂單管理等,用戶可以注冊(cè)并登陸后進(jìn)行相應(yīng)的管理操作。主要說明

  1. 前后端分離技術(shù)
  2. 前端使用vuejs,ElementUI,axios前后端通信,圖標(biāo)使用了ElementUI自帶的圖標(biāo)還有font-awesome.css的圖標(biāo)庫, 阿里的iconfont圖標(biāo)庫也不錯(cuò),這里沒用。
  3. 后端使用了nodejs,nodejs采用了Express框架,orm采用的是Sequelize操作數(shù)據(jù)庫(效率極高),restful風(fēng)格的Api, 跨域是由后端解決的,采用的是nodejs的cors模塊(比較方便)。
  4. 數(shù)據(jù)庫采用了mysql5.2(建議大家換成最新的mysql版本)
  5. 使用jsonwebtoken驗(yàn)證用戶調(diào)用api的權(quán)限,增加接口的安全性,防止惡意攻擊接口,串改數(shù)據(jù)。
  6. 主要界面里面的圖片主要使用的是網(wǎng)上的圖片,免費(fèi)而且美觀。
二,環(huán)境介紹

語言環(huán)境:nodejs

數(shù)據(jù)庫: mysql5.7

應(yīng)用服務(wù)器:nodejs

開發(fā)工具:IDEA或vscode

開發(fā)技術(shù):nodejs+vue+elementUI

三,系統(tǒng)展示

用戶注冊(cè)

用戶登陸

房間管理

房型管理

訂單管理

訂單管理

四,核心代碼展示
const { Op } = require('sequelize')//nodejs的sequelize模塊
const express = require('express')//express框架
const admin = require('../crud/table/admin.js')//引入管理員信息表
const token = require('../comment/token.js')//引入token模塊
const adminRouter = express.Router()//express路由

adminRouter.post('/register',(req,res) =>{//管理員注冊(cè)
    const { adminId, adminName, adminPassword } = req.body;
    admin.findOne({
        where:{
            adminId:adminId
        }
    })
    .then(data =>{
        if(data){
            res.status(200).json({
                msg:'該用戶已經(jīng)注冊(cè)',
                success:false
            })
            return new Promise(() =>{})
        }else{
            return admin.create({
                adminId, adminName, adminPassword
            })
        }
    })
    .then(data =>{
        res.status(200).json({
            success:true,
            msg:'管理員注冊(cè)成功!',
            admin:data.get()
        })
    })
    .catch(err =>{
        res.status(200).json({
            success:false,
            msg:'內(nèi)部服務(wù)器錯(cuò)誤!'
        })
    })

})

adminRouter.get('/login',(req,res) =>{//登錄
    const { adminId, adminPassword } = req.query;
    let adminInfo;
    admin.findOne({
        where:{
            adminId
        }
    })
    .then(data =>{
        if(data){
            if(data.get().adminPassword==adminPassword){
                adminInfo = data.get();
                return token.setToken(data.get())
            }else{
                res.status(200).json({
                    success:false,
                    msg:'用戶密碼錯(cuò)誤!'
                });  
                return new Promise(() =>{})
            }
        }else{
           res.status(200).json({
               success:false,
               msg:'該用戶還未注冊(cè)!'
           })
           return new Promise(() =>{})
        }
    })
    .then(data =>{
        res.status(200).json({
            success:true,
            admin:adminInfo,
            token:data,
            msg:'登錄成功!'
        })
    })
    .catch(err =>{
        res.status(200).json({
            success:false,
            msg:'內(nèi)部服務(wù)器出錯(cuò)!'
        })
    })
})

adminRouter.put('/update',(req,res) =>{//修改管理員信息
    const { adminId, adminName, adminPassword, adminSex, adminAge } = req.body;
    admin.findOne({
        where:{
            adminId,adminPassword
        }
    })
    .then(data =>{
        if(data){
           return admin.update({
                    adminName,adminSex,adminAge
                },{
                    where:{
                        adminId,adminPassword
                    }
                })
        }else{
            res.status(200).json({
                success:false,
                msg:'管理員賬號(hào)或者密碼錯(cuò)誤!'
            })
            return new Promise(() =>{})
        }
    })
    .then(data =>{
        return admin.findOne({
            where:{
                adminId,adminPassword
            }
        })
    })
    .then(data =>{
        res.status(200).json({
            success:true,
            msg:'管理員信息修改成功!',
            admin:data.get()
        })
    })
    .catch(err =>{
        res.status(200).json({
            success:false,
            msg:'服務(wù)器內(nèi)部錯(cuò)誤!'
        })
    })
})

adminRouter.delete('/del',(req,res) =>{
    const { adminId } = req.body || req.query;
    admin.destroy({
        where:{
            adminId
        }
    })
    .then(data =>{
        res.status(200).json({
            success:true,
            msg:'刪除成功!'
        })
    })
    .catch(err =>{
        res.status(200).json({
            success:false,
            msg:'刪除失敗!'
        })
    })
})

module.exports = adminRouter;

const { Op } = require('sequelize')//nodejs的sequelize模塊
const express = require('express')//express框架
const customer = require('../crud/table/customer.js')//引入用戶表

const customerRouter = express.Router()//express路由

customerRouter.post('/add',(req,res) =>{//用戶注冊(cè)
    const { customerIdCard, customerName, customerSex, customerPhoneNumber } = req.body;
    customer.findOne({
        where:{
            customerIdCard
        }
    })
    .then(data =>{
        if(data){
            res.status(200).json({
                success:false,
                msg:'該用戶已經(jīng)注冊(cè)!'
            })
            return new Promise(() =>{})
        }else{
            return customer.create({
                customerIdCard, customerName, customerSex, customerPhoneNumber
            })
        }
    })
    .then(data =>{
        res.status(200).json({
            success:true,
            msg:'用戶信息錄入成功!',
            customer:data.get()
        })
    })
    .catch(err =>{
        res.status(200).json({
            success:false,
            msg:'內(nèi)部服務(wù)器錯(cuò)誤!'
        })
    })
})

// customerRouter.get('/login',(req,res) =>{//用戶登錄
//     const { customerIdCard, cust}
// })

customerRouter.put('/update',(req,res) =>{//用戶基本信息修改
    const { customerIdCard, customerName, customerSex, customerPhoneNumber } = req.body;
    customer.findOne({
        where:{
            customerIdCard:{
                [Op.eq]:customerIdCard
            }
        }
    })
    .then(data =>{
        if(data){
            return customer.update({
                customerName, customerSex, customerPhoneNumber
            },{
               where:{
                    customerIdCard:{
                        [Op.eq]:customerIdCard
                    }
               }
            })
        }else{
            res.status(200).json({
                success:false,
                msg:'該用戶還未注冊(cè)!'
            })
            return new Promise(() =>{})
        }
    })
    .then(data =>{
        res.status(200).json({
            success:true,
            msg:'用戶信息修改成功!',
            customer:data.get()
        })
    })
    .catch(err =>{
        res.status(200).json({
            success:false,
            msg:'服務(wù)器出錯(cuò)!'
        })
    }) 
}) 

customerRouter.delete('/del',(req,res) =>{//刪除用戶
    const { customerIdCard } = req.body;
    customer.destroy({
        where:{
            customerIdCard
        }
    })
    .then(data =>{
        res.status(200).json({
            success:true,
            msg:'用戶刪除成功!'
        })
    })
    .catch(err =>{
        res.status(200).json({
            success:false,
            msg:'服務(wù)器內(nèi)部錯(cuò)誤!'
        })
    })
})

customerRouter.put('/updatevip',(req,res) =>{//購買會(huì)員
    const { customerIdCard, level } = req.body;
    customer.findOne({
        where:{
            customerIdCard
        }
    })
    .then(data =>{
        if(data){
            return customer.update({
                level
            },{
                where:{
                    customerIdCard
                }
            })
        }else{
            res.status(200).json({
                success:false,
                msg:'該用戶未注冊(cè)!'
            })
            return new Promise(() =>{})
        }
    })
    .then(data =>{
        return customer.findOne({
            where:{
                customerIdCard
            }
        })
    })
    .then(data =>{
        res.status(200).json({
            success:true,
            msg:'vip更改成功!',
            customer:data.get()
        })
    })
    .catch(err =>{
        res.status(200).json({
            success:false,
            msg:'服務(wù)器內(nèi)部錯(cuò)誤!'
        })
    })

})


customerRouter.put('/updatemoney',(req,res) =>{//修改用戶總消費(fèi)金額
    const { customerIdCard, money} = req.body;
    customer.findOne({
        where:{
            customerIdCard
        }
    })
    .then(data =>{
        if(data){
            let oldMoney = data.get().totalAmount;
            let newMoney = oldMoney + money;
            return customer.update({
                totalAmount: newMoney
            },{
                where:{
                    customerIdCard
                }
            })
        }else{
            res.status(200).json({
                success:false,
                msg:'該用戶為注冊(cè)!'
            })
        }
    })
    .then(data =>{
        return customer.findOne({
            where:{
                customerIdCard
            }
        })
    })
    .then(data =>{
        res.status(200).json({
            success:true,
            msg:'用戶消費(fèi)金額修改成功!'
        })
    })
    .catch(err =>{
        res.status(200).json({
            success:false,
            msg:'服務(wù)器內(nèi)部錯(cuò)誤!'
        })
    })

})

customerRouter.get('/getAllCustomer',(req,res) =>{//查詢所有顧客
    customer.findAndCountAll()
    .then(data =>{
        res.status(200).json({
            success:true,
            msg:'顧客信息查詢成功!',
            customerList:data.rows.map(item =>{
                return item.get()
            }),
            count:data.count
        })
    })
    .catch(err =>{
        res.status(200).json({
            success:false,
            msg:'服務(wù)器出錯(cuò)!'
        })
    })
})

customerRouter.get('/queryCustomer',(req,res) =>{//模糊查詢顧客信息
    const { queryName } = req.query;
    customer.findAndCountAll({
        where:{
            customerName:{
                [Op.like]:'%'+queryName+'%'
            }
        }
    })
    .then(data =>{
        res.status(200).json({
            success:true,
            msg:'顧客信息查詢成功!',
            customerList:data.rows.map(item =>{
                return item.get()
            }),
            count:data.count
        })
    })
    .then(err =>{
        res.status(200).json({
            success:false,
            msg:'服務(wù)器出錯(cuò)!'
        })
    })
})

module.exports = customerRouter;
const express = require('express')//express框架
const { Op } = require('sequelize')//nodejs的sequelize模塊
const order = require('../crud/table/myorder.js')//引入訂單信息表
const customer = require('../crud/table/customer.js')//引入顧客信息表
const room = require('../crud/table/room.js')//引入房間信息表

order.hasOne(customer,{ sourceKey:'customerIdCard', foreignKey:'customerIdCard' })
order.hasOne(room,{ sourceKey:'roomNumber', foreignKey:'roomNumber' })

const orderRouter = express.Router()

orderRouter.post('/add',(req,res) =>{//創(chuàng)建訂單
    console.log(req.body)
    const { orderNumber, orderStatus,customerIdCard,roomNumber,
            checkInTime,checkOutTime,totalMoney,remarks
        } = req.body;
    order.findOne({
        where:{
            orderNumber
        }
    })
    .then(data =>{
        if(data){
            res.status(200).json({
                success:false,
                msg:'該訂單已經(jīng)存在!'
            })
            return new Promise(() =>{})
        }else{
            return customer.findOne({
                where:{
                    customerIdCard
                }
            })
        }
    })
    .then(data =>{
        if(data){
            return room.update({
                    roomStatus:'已入住'
            },{
                where:{
                        roomNumber
                }
            })
        }else{
            res.status(200).json({
                success:false,
                msg:'該用戶還未注冊(cè)!'
            });
            return new Promise(() =>{});
        }
       
    })
    .then(data =>{
        return order.create({
            orderNumber, orderStatus,customerIdCard,roomNumber,
            checkInTime,checkOutTime,totalMoney,remarks
        })
    })
    .then(data =>{
        res.status(200).json({
            success:'true',
            msg:'訂單創(chuàng)建成功!'
        })
    })
    .catch(err =>{
        res.status(200).json({
            success:false,
            msg:'內(nèi)部服務(wù)器出錯(cuò)!'
        })
    })
})

orderRouter.delete('/del',(req,res) =>{//刪除訂單
    const { orderNumber } = req.body;
    order.findOne({
        where:{
            orderNumber
        }
    })
    .then(data =>{
        if(data){
            return order.destroy({
                where:{
                    orderNumber
                }
            })
        }else{
            res.status(200).json({
                success:false,
                msg:'該訂單不存在!'
            })
            return new Promise(() =>{})
        }
    })
    .then(data =>{
        res.status(200).json({
            success:true,
            msg:'刪除成功!'
        })
    })
    .catch(err =>{
        res.status(200).json({
            success:false,
            msg:'服務(wù)器內(nèi)部錯(cuò)誤!'
        })
    })
})

orderRouter.put('/update',(req,res) =>{//修改訂單狀態(tài)
    const { orderStatus, orderNumber,totalMoney,roomNumber } = req.body;
    order.findOne({
        where:{
            orderNumber
        }
    })
    .then(data =>{
        if(data){
            return room.update({
                roomStatus:'未入住'
            },{
                where:{
                    roomNumber
                }
            })
        }else{
            res.status(200).json({
                success:false,
                msg:'該訂單不存在!'                
            })
            return new Promise(() =>{})
        }
    })
    .then(data =>{
        return order.update({
            orderStatus,totalMoney
        },{
            where:{
                orderNumber
            }
        })
       
    })
    .then(data =>{
        return order.findOne({
            where:{
                orderNumber
            }
        })
    })
    .then(data =>{
        res.status(200).json({
            success:true,
            msg:'訂單修改成功!',
            order:data.get()
        })
    })
    .catch(err =>{
        res.status(200).json({
            success:false,
            msg:'服務(wù)器內(nèi)部錯(cuò)誤!'
        })
    })

})

orderRouter.get('/getAllOrder',(req,res) =>{//查詢所有訂單
    const { pageSize, offset } = req.query;
    order.findAndCountAll({
        limit:pageSize,
        offset:offset,
        include:[
            {
                model:customer,
                foreignKey:'customerIdCard',
                attributes:['customerName','customerSex','customerVipLevel','customerPhoneNumber','totalAmount']
            },
            {
                model:room,
                foreignKey:'roomNumber',
                attributes:['type','remarks']
            }
        ]
    })
    .then(data =>{
        res.status(200).json({
            success:true,
            msg:'所有訂單查詢成功!',
            orderList:data.rows.map(item =>{
                return item.get()
            }),
            count:data.count
        })
    })
    .catch(err =>{
        res.status(200).json({
            success:false,
            msg:'服務(wù)器內(nèi)部錯(cuò)誤!'
        })
    })
})

orderRouter.get('/getAllNotPayOrder',(req,res) =>{//查詢所有未支付的訂單
    const { pageSize, offset } = req.query;
    order.findAndCountAll({
        limit:pageSize,
        offset:offset,
        where:{
            orderStatus:{
                [Op.eq]:'未支付'
            }
        },
        include:[
            {
                model:customer,
                foreignKey:'customerIdCard',
                attributes:['customerName','customerSex','customerVipLevel','customerPhoneNumber','totalAmount']
            },
            {
                model:room,
                foreignKey:'roomNumber',
                attributes:['type']
            }
        ]
    })
    .then(data  =>{
        res.status(200).json({
            success:true,
            msg:'未支付訂單查詢成功!',
            orderList:data.rows.map(item =>{
                return item.get()
            }),
            count:data.count,
            pageSize:pageSize,
            offset:offset
        })
    })
    .catch(err =>{
        res.status(200).json({
            success:false,
            msg:'服務(wù)器內(nèi)部錯(cuò)誤!'
        })
    })
})

orderRouter.get('/getAllPayOrder',(req,res) =>{//查詢所有已支付的訂單
    const { pageSize, offset } = req.query;
    order.findAndCountAll({
        limit:pageSize,
        offset:offset,
        where:{
            orderStatus:{
                [Op.eq]:'已支付'
            }
        },
        include:[
            {
                model:customer,
                foreignKey:'customerIdCard',
                attributes:['customerName','customerSex','customerVipLevel','customerPhoneNumber','totalAmount']
            },
            {
                model:room,
                foreignKey:'roomNumber',
                attributes:['type']
            }
        ]
    })
    .then(data  =>{
        res.status(200).json({
            success:true,
            msg:'未支付訂單查詢成功!',
            orderList:data.rows.map(item =>{
                return item.get()
            }),
            count:data.count,
            pageSize:pageSize,
            offset:offset
        })
    })
    .catch(err =>{
        res.status(200).json({
            success:false,
            msg:'服務(wù)器內(nèi)部錯(cuò)誤!'
        })
    })
})

orderRouter.get('/getStatusOrder',(req,res) =>{//查詢所有該狀態(tài)的訂單
    const { pageSize, offset, orderStatus } = req.query;
    order.findAndCountAll({
        limit:pageSize,
        offset:offset,
        where:{
            orderStatus:{
                [Op.eq]:orderStatus
            }
        },
        include:[
            {
                model:customer,
                foreignKey:'customerIdCard',
                attributes:['customerName','customerSex','customerVipLevel','customerPhoneNumber','totalAmount']
            },
            {
                model:room,
                foreignKey:'roomNumber',
                attributes:['type']
            }
        ]
    })
    .then(data  =>{
        res.status(200).json({
            success:true,
            msg:'狀態(tài)訂單查詢成功!',
            orderList:data.rows.map(item =>{
                return item.get()
            }),
            count:data.count,
            pageSize:pageSize,
            offset:offset
        })
    })
    .catch(err =>{
        res.status(200).json({
            success:false,
            msg:'服務(wù)器內(nèi)部錯(cuò)誤!'
        })
    })
})
module.exports = orderRouter;
const express = require('express')//express框架
const { Op } = require('sequelize')//nodejs的sequelize模塊
const room = require('../crud/table/room.js')//引入放假信息表
const roomType = require('../crud/table/roomType.js')//引入所有房間類型表

room.hasOne(roomType,{ sourceKey:'type',foreignKey:'type'})//每個(gè)房間都有一個(gè)房間類型

const roomRouter = express.Router()

roomRouter.post('/add',(req,res) =>{//添加房間
    const { roomNumber, type, roomStatus, remarks } = req.body;
    room.findOne({
        where:{
            roomNumber
        }
    })
    .then(data =>{
        if(data){
            res.status(200).json({
                success:false,
                msg:'該房間已經(jīng)存在!'
            })
            return new Promise(() =>{})
        }else{
            return room.create({
                roomNumber, type, roomStatus, remarks
            })
        }
    })
    .then(data =>{
        return room.findOne({
            where:{
                roomNumber
            },
            include:[{
                model:roomType,
                foreignKey:'type',
                attributes:['price','url']
            }]
        })
    })
    .then(data =>{
        res.status(200).json({
            success:true,
            msg:'房間添加成功!',
            room:data.get()
        })
    })
    .catch(err =>{
        res.status(200).json({
            success:false,
            msg:'服務(wù)器內(nèi)部錯(cuò)誤!'
        })
    })
})

roomRouter.delete('/del',(req,res) =>{
    const { roomNumber } = req.body;
    room.findOne({
        where:{
            roomNumber
        }
    })
    .then(data =>{
        if(data){
            return room.destroy({
                where:{
                    roomNumber
                }
            })
        }else{
            res.status(200).json({
                success:false,
                msg:'房間刪除失??!'
            })
            return new Promise(() =>{})
        }
    })
    .then(data =>{
        res.status(200).json({
            success:true,
            msg:'該房間刪除成功!'
        })
    })
    .catch(err =>{
        res.status(200).json({
            success:false,
            msg:'服務(wù)器內(nèi)部錯(cuò)誤!'
        })
    })
})

roomRouter.put('/update',(req,res) =>{//修改房間信息
    const { roomNumber, type, roomStatus,remarks } = req.body;
    room.findOne({
        where:{
            roomNumber
        }
    })
    .then(data =>{
        if(data){
            return room.update({
                type, roomStatus,remarks
            },{
                where:{
                    roomNumber
                }
            })
        }else{
            res.status(200).json({
                success:false,
                msg:'該房間不存在!'
            })
            return new Promise(() =>{})
        }
    })
    .then(data =>{
        return room.findOne({
            where:{
                roomNumber
            }
        })
    })
    .then(data =>{
        res.status(200).json({
            success:true,
            msg:'房間信息修改成功!',
            room:data.get()
        })
    })
    .catch(err =>{
        res.status(200).json({
            success:false,
            msg:'服務(wù)器內(nèi)部錯(cuò)誤'
        })
    })
})

roomRouter.get('/getAllRoom',(req,res) =>{//獲取所有房間信息
    const { pageSize, offset } = req.query;
    room.findAndCountAll({
        limit:pageSize,
        offset:offset
    })
    .then(data =>{
        let roomList = data.rows.map(item =>{
            return item.get()
        })
        res.status(200).json({
            success:true,
            msg:'房間信息查詢成功!',
            roomList:roomList,
            count:data.count
        })
    })
    .catch(err =>{
        res.status(200).json({
            success:false,
            msg:'服務(wù)器內(nèi)部錯(cuò)誤!'
        })
    })
})

roomRouter.get('/getOneRoom',(req,res) =>{//獲取某個(gè)房間號(hào)的房間信息
    const { roomNumber } = req.query;
    room.findOne({
        where:{
            roomNumber
        }
    })
    .then(data =>{
        if(data){
            res.status(200).json({
                success:true,
                msg:'房間查詢成功!',
                room:data.get()
            })
        }else{
            res.status(200).json({
                success:false,
                msg:'未查詢到該房間信息'
            })
        }
    })
    .catch(err =>{
        res.status(200).json({
            success:false,
            msg:'服務(wù)器內(nèi)部錯(cuò)誤!'
        })
    })
})

roomRouter.get('/getNotInRoom',(req,res) =>{//獲取未入住房間信息
    const { pageSize, offset } = req.query;
    room.findAndCountAll({
        limit:pageSize,
        offset:offset,
        where:{
            roomStatus:{
                [Op.eq]:'未入住'
            }
        }
    })
    .then(data =>{
        res.status(200).json({
            success:true,
            msg:'未入住房間查詢成功!',
            roomList:data.rows.map(item =>{
                return item.get()
            }),
            count:data.count
        })
    })
    .catch(err =>{
        res.status(200).json({
            success:false,
            msg:'服務(wù)器內(nèi)部錯(cuò)誤!'
        })
    })
})

roomRouter.get('/getInRoom',(req,res) =>{//查詢已入住房間信息
    const { pageSize, offset } = req.query;
    room.findAndCountAll({
        limit:pageSize,
        offset:offset,
        where:{
            roomStatus:{
                [Op.eq]:'已入住'
            }
        }
    })
    .then(data =>{
        res.status(200).json({
            success:true,
            msg:'已入住房間查詢成功!',
            roomList:data.rows.map(item =>{
                return item.get()
            }),
            count:data.count
        })
    })
    .catch(err =>{
        res.status(200).json({
            success:false,
            msg:'服務(wù)器內(nèi)部錯(cuò)誤!'
        })
    })
})

roomRouter.get('/getAllRoomPrice',(req,res) =>{//查詢所有的房間以及價(jià)格
    const { pageSize, offset } = req.query;
    room.findAndCountAll({
        limit:pageSize,
        offset:offset,
        include:[{
            model:roomType,
            foreignKey:'type',
            attributes:['price','url']
        }]
    })
    .then(data =>{
        res.status(200).json({
            success:true,
            msg:'房間信息查詢成功!',
            roomList:data.rows.map(item =>{
                return item.get()
            }),
            count:data.count
        })
    })
    .catch(err =>{
        res.status(200).json({
            success:false,
            msg:'服務(wù)器內(nèi)部錯(cuò)誤!'
        })
    })
})

roomRouter.get('/getAllNotINRoomPrice',(req,res) =>{//獲取所有未入住的房間信息
    const { pageSize, offset } = req.query;
    room.findAndCountAll({
        limit:pageSize,
        offset:offset,
        where:{
            roomStatus:{
                [Op.eq]:'未入住'
            }
        },
        include:[{
            model:roomType,
            foreignKey:'type',
            attributes:['price','url']
        }]
    })
    .then(data =>{
       res.status(200).json({
           success:true,
           msg:'房間信息查詢成功!',
           roomList:data.rows.map(item =>{
               return item.get()
           }),
           count:data.count
       })
    })
})

roomRouter.get('/getAllINRoomPrice',(req,res) =>{//獲取所有已入住的房間信息
    const { pageSize, offset } = req.query;
    room.findAndCountAll({
        limit:pageSize,
        offset:offset,
        where:{
            roomStatus:{
                [Op.eq]:'已入住'
            }
        },
        include:[{
            model:roomType,
            foreignKey:'type',
            attributes:['price','url']
        }]
    })
    .then(data =>{
       res.status(200).json({
           success:true,
           msg:'房間信息查詢成功!',
           roomList:data.rows.map(item =>{
               return item.get()
           }),
           count:data.count
       })
    })
})

roomRouter.get('/getAllRoomTypePrice',(req,res) =>{
    const { pageSize, offset, type } = req.query;
    room.findAndCountAll({
        where:{
           type:{
               [Op.eq]:type
           }
        },
        include:[{
            model:roomType,
            foreignKey:'type',
            attributes:['price','url']
        }]
    })
    .then(data =>{
        res.status(200).json({
            success:true,
            msg:'房型查詢成功!',
            roomList:data.rows.map(item =>{
                return item.get()
            }),
            count:data.count
        })
    })
    .catch(err =>{
        res.status(200).json({
            success:false,
            msg:'服務(wù)器出錯(cuò)!'
        })
    })
})

roomRouter.get('/getAllStatusRoom',(req,res) =>{//獲取所有該狀態(tài)的房間信息
    const { pageSize, offset, roomStatus } = req.query;
    room.findAndCountAll({
        limit:pageSize,
        offset:offset,
        where:{
            roomStatus:{
                [Op.eq]:roomStatus
            }
        },
        include:[{
            model:roomType,
            foreignKey:'type',
            attributes:['price','url']
        }]
    })
    .then(data =>{
       res.status(200).json({
           success:true,
           msg:'房間信息查詢成功!',
           roomList:data.rows.map(item =>{
               return item.get()
           }),
           count:data.count
       })
    })
})


module.exports = roomRouter

五,項(xiàng)目總結(jié)

你是否還在尋找穩(wěn)定的海外服務(wù)器提供商?創(chuàng)新互聯(lián)www.cdcxhl.cn海外機(jī)房具備T級(jí)流量清洗系統(tǒng)配攻擊溯源,準(zhǔn)確流量調(diào)度確保服務(wù)器高可用性,企業(yè)級(jí)服務(wù)器適合批量采購,新人活動(dòng)首月15元起,快前往官網(wǎng)查看詳情吧


當(dāng)前文章:前端項(xiàng)目:基于Nodejs+vue開發(fā)實(shí)現(xiàn)酒店管理系統(tǒng)-創(chuàng)新互聯(lián)
地址分享:http://fisionsoft.com.cn/article/djhoji.html