From f2797f4bbf6985a3ee0e5081a483f19ee36aab25 Mon Sep 17 00:00:00 2001 From: lovej Date: Wed, 4 Aug 2021 09:24:22 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B9=A6=E7=AD=BE=E5=AD=98=E5=9C=A8=E5=A6=82?= =?UTF-8?q?=E6=9E=9C=E9=87=8D=E5=A4=8D=E6=B7=BB=E5=8A=A0=E5=88=99=E6=9B=B4?= =?UTF-8?q?=E6=96=B0=E6=B7=BB=E5=8A=A0=E6=97=A5=E6=9C=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/controller/api.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/controller/api.js b/src/controller/api.js index ee87989..e06a9bd 100644 --- a/src/controller/api.js +++ b/src/controller/api.js @@ -211,6 +211,18 @@ module.exports = class extends Base { let bookmark = this.post(); bookmark.userId = this.ctx.state.user.id; try { + let bookmarkFind = await this.model('bookmarks').where({ userId: this.ctx.state.user.id, url: bookmark.url }).find(); + console.log("bookmarkFind", bookmarkFind, bookmark) + if (!think.isEmpty(bookmarkFind)) { + await this.model('bookmarks').where({ + userId: this.ctx.state.user.id, + id: bookmarkFind.id + }).update({ + createdAt: ['exp', 'NOW()'] + }); + this.json({ code: 0, data: bookmarkFind, msg: `书签 ${bookmark.title} 已存在,更新创建日期!` }); + return + } // 没有分类的直接放未分类里面 if (!bookmark.tagId) { const name = "未分类";