|
@@ -6,30 +6,33 @@ class ExportsService extends Service {
|
|
|
async exportsuser({ filter, skip, ids, _this }) {
|
|
|
const key = Object.keys(filter);
|
|
|
if (key.length > 0) return await _this.ctx.model.User.find({ ...filter }).skip(skip * 10).limit(10);
|
|
|
- let list = await Promise.all(
|
|
|
- ids.map(async e => {
|
|
|
- const res = await _this.ctx.model.User.findOne({ _id: e });
|
|
|
- if (res) return res;
|
|
|
- })
|
|
|
- );
|
|
|
- list = list.filter(e => e !== undefined);
|
|
|
- return list;
|
|
|
+ if (ids) {
|
|
|
+ let list = await Promise.all(
|
|
|
+ ids.map(async e => {
|
|
|
+ const res = await _this.ctx.model.User.findOne({ _id: e });
|
|
|
+ if (res) return res;
|
|
|
+ })
|
|
|
+ );
|
|
|
+ list = list.filter(e => e !== undefined);
|
|
|
+ return list;
|
|
|
+ }
|
|
|
+ return await _this.ctx.model.User.find().skip(skip * 10).limit(10);
|
|
|
}
|
|
|
// vip导出
|
|
|
async exportsvip({ filter, skip, ids, _this }) {
|
|
|
const key = Object.keys(filter);
|
|
|
if (key.length > 0) return await _this.ctx.model.Vip.find({ ...filter }).skip(skip * 10).limit(10);
|
|
|
- let list = await Promise.all(
|
|
|
- ids.map(async e => {
|
|
|
- const res = await _this.ctx.model.Vip.findOne({ _id: e });
|
|
|
- if (res) {
|
|
|
- const data = await this.convert({ data: res });
|
|
|
- return data;
|
|
|
- }
|
|
|
- })
|
|
|
- );
|
|
|
- list = list.filter(e => e !== undefined);
|
|
|
- return list;
|
|
|
+ if (ids) {
|
|
|
+ let list = await Promise.all(
|
|
|
+ ids.map(async e => {
|
|
|
+ const res = await _this.ctx.model.User.findOne({ _id: e });
|
|
|
+ if (res) return res;
|
|
|
+ })
|
|
|
+ );
|
|
|
+ list = list.filter(e => e !== undefined);
|
|
|
+ return list;
|
|
|
+ }
|
|
|
+ return await _this.ctx.model.User.find().skip(skip * 10).limit(10);
|
|
|
}
|
|
|
// 数据转换函数
|
|
|
async convert({ data }) {
|