diff --git a/db.sql b/db.sql index 71cf829..76dff0d 100644 --- a/db.sql +++ b/db.sql @@ -43,6 +43,8 @@ where cover is null; create table comment ( id int(10) PRIMARY KEY AUTO_INCREMENT, + nickname varchar(20) null, + email varchar(50) null, article_id int(10) not null, content varchar(500) not null, publish_time datetime not null, diff --git a/modules/comment.js b/modules/comment.js index 14721ad..5a6ac97 100644 --- a/modules/comment.js +++ b/modules/comment.js @@ -6,7 +6,8 @@ const router = require('express').Router(); router.all('/web/query', async (req, res) => { let id = req.query['id']; // 获取要查询文章的编号 if (!id || id < 1) { - res.send({ status: false, message: "参数不对" }) + // 参数不正确 直接返回空数组 + res.send([]) } else { const list = await db.query('select * from comment where article_id =?', [id]); res.send(list) diff --git a/public/detail.html b/public/detail.html index 35ff3f0..403e420 100644 --- a/public/detail.html +++ b/public/detail.html @@ -36,14 +36,16 @@