|
@@ -9,7 +9,7 @@ class ContentService extends Service {
|
|
this.model = this.ctx.model.Content;
|
|
this.model = this.ctx.model.Content;
|
|
this.menuModel = this.ctx.model.Menu;
|
|
this.menuModel = this.ctx.model.Menu;
|
|
}
|
|
}
|
|
- async create({ title, describe, source, content, bind, istop, date, thumbnail, recommend, annex, keywords, svip, isShow, status, curtTitle }) {
|
|
|
|
|
|
+ async create({ title, describe, source, content, bind, istop, date, thumbnail, recommend, annex, keywords, svip, isShow, status, curtTitle, author }) {
|
|
assert(title, '标题不存在');
|
|
assert(title, '标题不存在');
|
|
// assert(describe, '描述不存在');
|
|
// assert(describe, '描述不存在');
|
|
assert(content, '内容不存在');
|
|
assert(content, '内容不存在');
|
|
@@ -17,19 +17,19 @@ class ContentService extends Service {
|
|
try {
|
|
try {
|
|
const createAt = moment().format('x');
|
|
const createAt = moment().format('x');
|
|
const updateAt = moment().format('x');
|
|
const updateAt = moment().format('x');
|
|
- const item = await this.model.create({ title, describe, source, content, bind, istop, date, thumbnail, recommend, annex, createAt, updateAt, keywords, svip, isShow, status, curtTitle });
|
|
|
|
|
|
+ const item = await this.model.create({ title, describe, author, source, content, bind, istop, date, thumbnail, recommend, annex, createAt, updateAt, keywords, svip, isShow, status, curtTitle });
|
|
return { errcode: 0, errmsg: '', data: item };
|
|
return { errcode: 0, errmsg: '', data: item };
|
|
} catch (error) {
|
|
} catch (error) {
|
|
throw error;
|
|
throw error;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- async update({ id, title, describe, source, content, bind, istop, date, thumbnail, recommend, annex, keywords, svip, isShow, status, curtTitle }) {
|
|
|
|
|
|
+ async update({ id, title, describe, author, source, content, bind, istop, date, thumbnail, recommend, annex, keywords, svip, isShow, status, curtTitle }) {
|
|
assert(id, 'id不存在');
|
|
assert(id, 'id不存在');
|
|
try {
|
|
try {
|
|
const res = await this.model.findOne({ _id: id });
|
|
const res = await this.model.findOne({ _id: id });
|
|
if (!res) return { errcode: -1001, errmsg: '数据不存在', data: '' };
|
|
if (!res) return { errcode: -1001, errmsg: '数据不存在', data: '' };
|
|
const updateAt = moment().format('x');
|
|
const updateAt = moment().format('x');
|
|
- await this.model.updateOne({ _id: id }, { title, describe, source, content, bind, istop, date, thumbnail, recommend, annex, updateAt, keywords, svip, isShow, status, curtTitle });
|
|
|
|
|
|
+ await this.model.updateOne({ _id: id }, { title, describe, author, source, content, bind, istop, date, thumbnail, recommend, annex, updateAt, keywords, svip, isShow, status, curtTitle });
|
|
return { errcode: 0, errmsg: '', data: 'update' };
|
|
return { errcode: 0, errmsg: '', data: 'update' };
|
|
} catch (error) {
|
|
} catch (error) {
|
|
throw error;
|
|
throw error;
|
|
@@ -47,15 +47,14 @@ class ContentService extends Service {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
async query({ skip, limit, title, date, bind, keywords, svip, isShow, status, istop, parentCode }) {
|
|
async query({ skip, limit, title, date, bind, keywords, svip, isShow, status, istop, parentCode }) {
|
|
-
|
|
|
|
if (parentCode) {
|
|
if (parentCode) {
|
|
const menus = await this.service.menu.menuList({ code: parentCode });
|
|
const menus = await this.service.menu.menuList({ code: parentCode });
|
|
const filter = { bind: { $in: menus } };
|
|
const filter = { bind: { $in: menus } };
|
|
const total = await this.model.find({ ...filter }, { content: false });
|
|
const total = await this.model.find({ ...filter }, { content: false });
|
|
const res = await this.model.find({ ...filter }, { content: false })
|
|
const res = await this.model.find({ ...filter }, { content: false })
|
|
|
|
+ .sort({ istop: -1, date: -1 })
|
|
.skip(Number(skip) * Number(limit))
|
|
.skip(Number(skip) * Number(limit))
|
|
- .limit(Number(limit))
|
|
|
|
- .sort({ istop: -1, date: -1 });
|
|
|
|
|
|
+ .limit(Number(limit));
|
|
return { errcode: 0, errmsg: '', data: res, total: total.length };
|
|
return { errcode: 0, errmsg: '', data: res, total: total.length };
|
|
}
|
|
}
|
|
|
|
|