|
@@ -51,15 +51,24 @@ class GoodsService extends Service {
|
|
|
const total = await this.model.find({ ...filter });
|
|
|
let res;
|
|
|
if (skip && limit) {
|
|
|
- res = await this.model.find({ ...filter }).skip(Number(skip) * Number(limit)).limit(Number(limit));
|
|
|
+ res = await this.model.find({ ...filter }, { content: false }).skip(Number(skip) * Number(limit)).limit(Number(limit));
|
|
|
} else {
|
|
|
- res = await this.model.find({ ...filter });
|
|
|
+ res = await this.model.find({ ...filter }, { content: false });
|
|
|
}
|
|
|
return { errcode: 0, errmsg: 'ok', data: res, total: total.length };
|
|
|
} catch (error) {
|
|
|
throw error;
|
|
|
}
|
|
|
}
|
|
|
+ async fetch({ id }) {
|
|
|
+ try {
|
|
|
+ const res = await this.model.findOne({ _id: id });
|
|
|
+ if (!res) return { errcode: -1001, errmsg: '数据不存在', data: '' };
|
|
|
+ return { errcode: 0, errmsg: '', data: res };
|
|
|
+ } catch (error) {
|
|
|
+ throw error;
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
module.exports = GoodsService;
|