分类没有用未知替代

This commit is contained in:
HelloWorld 2020-04-23 08:48:34 +08:00
parent a3b179a4e7
commit 18bab95327
1 changed files with 10 additions and 0 deletions

View File

@ -538,6 +538,11 @@ module.exports = class extends Base {
// 如果是第0页而且是个人定制的把 最近点击 与 最近新增 的返回去。
let data = {};
data = await this.model('hot_bookmarks').order('id DESC').page(page || 1, pageSize).countSelect();
for (let bookmark of data.data) {
if (!bookmark.tagName) {
bookmark.tagName = "未知";
}
}
this.json({ code: 0, data });
} catch (error) {
this.json({ code: 1, msg: error.toString() });
@ -549,6 +554,11 @@ module.exports = class extends Base {
try {
let sql = `SELECT * FROM hot_bookmarks ORDER BY RAND() LIMIT 50;`;
let data = await this.model('hot_bookmarks').query(sql);
for (let bookmark of data) {
if (!bookmark.tagName) {
bookmark.tagName = "未知";
}
}
this.json({ code: 0, data });
} catch (error) {
this.json({ code: 1, msg: error.toString() });