From 3f08060659f3e022cf0b522ea750ce0022688bea Mon Sep 17 00:00:00 2001 From: P-Jhao <113034340+P-Jhao@users.noreply.github.com> Date: Sat, 23 Nov 2024 00:37:43 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E4=BA=86=E4=B8=8D=E8=83=BD?= =?UTF-8?q?=E5=88=A0=E9=99=A4=E8=AE=A2=E5=8D=95=E7=9A=84bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- dao/expressDao.js | 10 ++++++++++ routes/express.js | 8 +++++++- services/expressService.js | 11 ++++++++++- 3 files changed, 27 insertions(+), 2 deletions(-) diff --git a/dao/expressDao.js b/dao/expressDao.js index be01a19..5f9ea13 100644 --- a/dao/expressDao.js +++ b/dao/expressDao.js @@ -17,4 +17,14 @@ module.exports.updateExpressDao = async function (expData) { } }) return handleArrayDaoData(await expressModel.findAll()) +} + +module.exports.deleteExpressDao = async function (id) { + console.log(id, "deleteId") + await expressModel.destroy({ + where: { + id + } + }) + return handleArrayDaoData(await expressModel.findAll()) } \ No newline at end of file diff --git a/routes/express.js b/routes/express.js index 13b782f..649c6db 100644 --- a/routes/express.js +++ b/routes/express.js @@ -3,7 +3,8 @@ const router = express.Router() const { getExpressServices, addExpressServices, - updateExpressServices + updateExpressServices, + deleteExpressServices } = require("../services/expressService") const { formatResponse @@ -24,4 +25,9 @@ router.put("/", async function (req, res, next) { res.send(formatResponse(0, "", data)) }) +router.delete("/", async function (req, res, next) { + const data = await deleteExpressServices(req.body) + res.send(formatResponse(0, "", data)) +}) + module.exports = router \ No newline at end of file diff --git a/services/expressService.js b/services/expressService.js index 70db178..9df2a7f 100644 --- a/services/expressService.js +++ b/services/expressService.js @@ -1,7 +1,8 @@ const { getExpressDao, addExpressDao, - updateExpressDao + updateExpressDao, + deleteExpressDao } = require("../dao/expressDao") const { getRandomExpressId @@ -23,4 +24,12 @@ module.exports.addExpressServices = async function (expData) { module.exports.updateExpressServices = async function (expData) { //这里需要提供id return await updateExpressDao(expData) +} + +module.exports.deleteExpressServices = async function ({ + id +}) { + return await deleteExpressDao( + id + ) } \ No newline at end of file