From 9b84bee71d1f284651d428cfbc3e7ce5a14e5d63 Mon Sep 17 00:00:00 2001 From: miaoyurun <2965589761@qq.com> Date: Wed, 27 Nov 2024 11:45:34 +0800 Subject: [PATCH] =?UTF-8?q?add:=E7=AC=AC=E4=B8=80=E6=AC=A1=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0=E5=90=8E=E7=AB=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- webserve/app.js | 2 + webserve/model/db.js | 2 +- webserve/model/model.js | 63 ++++++++++++++++++++ webserve/routes/myr.js | 127 ++++++++++++++++++++++++++++++++++++++++ 4 files changed, 193 insertions(+), 1 deletion(-) create mode 100644 webserve/routes/myr.js diff --git a/webserve/app.js b/webserve/app.js index c8d9d0d..24193be 100644 --- a/webserve/app.js +++ b/webserve/app.js @@ -6,6 +6,7 @@ var logger = require('morgan'); var cors = require('cors') var indexRouter = require('./routes/index'); var usersRouter = require('./routes/users'); +var myrRouter=require('./routes/myr') var app = express(); @@ -21,6 +22,7 @@ app.use(express.static(path.join(__dirname, 'public'))); app.use('/', indexRouter); app.use('/users', usersRouter); +app.use('/myr', myrRouter); // catch 404 and forward to error handler app.use(function(req, res, next) { diff --git a/webserve/model/db.js b/webserve/model/db.js index 5d6c9ca..de4cb60 100644 --- a/webserve/model/db.js +++ b/webserve/model/db.js @@ -1,5 +1,5 @@ const mongoose = require("mongoose") -mongoose.connect("mongodb://127.0.0.1:27017/库名").then(() => { +mongoose.connect("mongodb+srv://2968289424:Mf6aDRKrXDBc1m5p@cluster0.3o4hkpp.mongodb.net/zhihui_three").then(() => { console.log("mongodb connect ok!"); }).catch((err) => { console.log("err: ", err) diff --git a/webserve/model/model.js b/webserve/model/model.js index f6f5199..6533087 100644 --- a/webserve/model/model.js +++ b/webserve/model/model.js @@ -1 +1,64 @@ const mongoose = require('./db') + +const xicheCate = new mongoose.Schema({ + cate: String +}) + +const XiHeSchema = new mongoose.Schema({ + name: String, //司机名称 + tel: String,//手机号码 + start: String,//开始时间 + end: String, //结束时间 + carid: { + type: mongoose.Schema.Types.ObjectId, + ref: 'xichetype' + }, + // 预约编号 + yuey: Boolean,// 预约类型 + beizhu: String, //备注信息 + nums: Number //盒子数量 +}) + + +const XihedengjiSchema = new mongoose.Schema({ + djbianh: String, //登记编号 + carsnum: String, //车牌号码 + cartype: String, //车辆类型 + sjname: String, //司机姓名 + tel: String, //手机号码 + starts: String, //登记时间 + nums: Number, //盒子数量 + qj: String, //清洁情况 + memy: Number, //缴费金额 + beizhu: String //备注 +}) +const XiheSchema=new mongoose.Schema({ + myrbianh: String, //登记编号 + myrcarhao: String,//车牌号码 + cartype: String,//车辆类型 + name: String,//司机姓名 + tel: String,//手机号码 + myrstart: String,//登记时间 + nums:Number,//盒子数量 + myrend:String,//洗盒时间 + qingkuang:Boolean,//清洁情况 + memy:Number,//缴费金额 + beizhu: String//备注 +}) +const xihebaobiaoSchema=new mongoose.Schema({ + myrbianh: String,//登记编号 + myrcarhao: String,//车牌号码 + nums:Number,//盒子数量 + myrstart: String,//登记时间 + myrend:String,//洗盒时间 + gan:Number,//干净 + chong:Number,//虫卵 + chan:Number,//残渣 + qita:Number//其他数量 +}) +const Xiche = mongoose.model('xiche', XiHeSchema, 'xiche') //洗盒登记 +const Xichetype = mongoose.model('xichetype', xicheCate, 'xichetype') // 洗盒类型 +const Xichedengji = mongoose.model(' Xihedengji', XihedengjiSchema, ' Xihedengji') //洗盒记录 +const Xihejilu=mongoose.model('XiheSchema',XiheSchema,'XiheSchema') +const xihebaobiao=mongoose.model('xihebaobiaoSchema',xihebaobiaoSchema,'xihebaobiaoSchema') +module.exports = { Xiche, Xichetype,Xichedengji,Xihejilu,xihebaobiao} \ No newline at end of file diff --git a/webserve/routes/myr.js b/webserve/routes/myr.js new file mode 100644 index 0000000..0cea669 --- /dev/null +++ b/webserve/routes/myr.js @@ -0,0 +1,127 @@ +var express = require('express'); +var router = express.Router(); +let {Xiche,Xichetype,Xichedengji,Xihejilu,xihebaobiao} =require('../model/model') + +/* GET home page. */ +// 添加洗盒登记 +router.post('/xicheadd',(req,res)=>{ + Xiche.create(req.body) + res.send({ + code:'200', + }) +}) +// 添加车辆编号 +router.post('/xichetypeadd',(req,res)=>{ + Xichetype.create(req.body) + res.send({ + code:'200' + }) +}) + +// 洗车登记数据 +router.get('/getdengji',async(req,res)=>{ + let {page}=req.query; + let datas=await Xiche.find({yuey:false}).populate('carid').skip((page-1)*10).limit(10) + let total=(await Xiche.find()).length + let tylist=await Xichetype.find() + res.send({ + code:'200', + list:datas, + total, + tylist + }) +}) + +router.get('/getdengjitow',async(req,res)=>{ + let {page}=req.query; + let datas=await Xiche.find({yuey:true}).populate('carid').skip((page-1)*10).limit(10) + let total=(await Xiche.find()).length + res.send({ + code:'200', + list:datas, + total + }) +}) + +router.post('/addXichedengji',(req,res)=>{ + Xichedengji.create(req.body) + res.send({ + code:'200', + }) +}) +router.get('/xihelogin',async(req,res)=>{ + let {_id,sjname,start,end}=req.query + let add=[{}] + if(sjname){ + add.push({sjname:new RegExp(sjname)}) + } + if(_id){ + add.push({_id:_id}) + } + let datas=await Xichedengji.find({$and:add}) + let total=datas.length + res.send({ + code:'200', + list:datas, + total + }) +}) + +router.post('/upyuyue',async(req,res)=>{ + let {id}=req.body + let oo=await Xiche.find({_id:id}) + await Xiche.updateOne({_id:id},{yuey:!oo[0]['yuey']}) + + res.send({ + code:'200', + }) +}) + +router.post('/delsome',async(req,res)=>{ + let {ids}=req.body + await Xiche.deleteOne({_id:ids}) + res.send({ + code:'200' + }) +}) + +router.post('/addXihejilu',(req,res)=>{ + Xihejilu.create(req.body) + res.send({ + code:'200', + }) +}) + +router.get('/getXihejilu',async(req,res)=>{ + let {name}=req.query + let ass=[{}] + if(name){ + ass.push({name:new RegExp(name)}) + } + let datas=await Xihejilu.find({$and:ass}) + let total=datas.length + res.send({ + code:'200', + list:datas, + total + }) +}) + +router.post('/xihebaobiao',(req,res)=>{ + xihebaobiao.create(req.body) + res.send({ + code:'200', + }) +}) + +router.get('/xihelist',async(req,res)=>{ + let {page}=req.query + let datas=await xihebaobiao.find().skip((page-1)*10).limit(10) + let total=(await xihebaobiao.find()).length + res.send({ + code:'200', + list:datas, + total + }) +}) +module.exports = router; \ No newline at end of file -- Gitee