From 4b1c0e012d798d280a6172d92979710b557933fb Mon Sep 17 00:00:00 2001 From: kkkkkyh Date: Sun, 2 Jun 2024 20:49:24 +0800 Subject: [PATCH] =?UTF-8?q?feat(test):=20=E6=8E=A5=E5=8F=A3=E6=B5=8B?= =?UTF-8?q?=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bin/www | 2 +- model/kys.js | 7 ++++++- routes/kys.js | 18 ++++++++++++++++++ 3 files changed, 25 insertions(+), 2 deletions(-) diff --git a/bin/www b/bin/www index 81cb39b..8e8187c 100755 --- a/bin/www +++ b/bin/www @@ -12,7 +12,7 @@ var http = require('http'); * Get port from environment and store in Express. */ -var port = normalizePort(process.env.PORT || '3000'); +var port = normalizePort(process.env.PORT || '3088'); app.set('port', port); /** diff --git a/model/kys.js b/model/kys.js index c5c5150..25a6ccb 100644 --- a/model/kys.js +++ b/model/kys.js @@ -19,8 +19,13 @@ const menuSchema = new Schema({ }] }) +const testSchema = new Schema({ + name:String +}) + let menuModel = mongoose.model('menu', menuSchema,'menu') +let testModel = mongoose.model('test', testSchema,'test') module.exports={ - menuModel + menuModel,testModel } \ No newline at end of file diff --git a/routes/kys.js b/routes/kys.js index 9264798..290e455 100644 --- a/routes/kys.js +++ b/routes/kys.js @@ -1,6 +1,24 @@ var express = require('express'); var router = express.Router(); +var {menuModel,testModel} =require('../model/kys') +router.post('/add',(req,res)=>{ + testModel.create(req.body) + res.send({ + code:200, + msg:'添加成功' + }) +}) +router.get('/list',async(req,res)=>{ + console.log(req.query,'ttt'); +let {name}=req.query +let data=await testModel.find({name}) +res.send({ + status:0, + message:'添加成功', + data +}) +}) module.exports = router; -- Gitee