书签存在如果重复添加则更新添加日期
This commit is contained in:
parent
f6fd7bda23
commit
f2797f4bbf
|
|
@ -211,6 +211,18 @@ module.exports = class extends Base {
|
||||||
let bookmark = this.post();
|
let bookmark = this.post();
|
||||||
bookmark.userId = this.ctx.state.user.id;
|
bookmark.userId = this.ctx.state.user.id;
|
||||||
try {
|
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) {
|
if (!bookmark.tagId) {
|
||||||
const name = "未分类";
|
const name = "未分类";
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue