|
@@ -11,6 +11,23 @@ class LevelService extends CrudService {
|
|
|
constructor(ctx) {
|
|
|
super(ctx, 'news');
|
|
|
this.model = this.ctx.model.Level;
|
|
|
+ this.dmodel = this.ctx.model.Department;
|
|
|
+ }
|
|
|
+
|
|
|
+ async query({ skip, limit, ...info }) {
|
|
|
+ const total = await (await this.model.find(info)).length;
|
|
|
+ const levels = await this.model
|
|
|
+ .find(info)
|
|
|
+ .skip(Number(skip))
|
|
|
+ .limit(Number(limit));
|
|
|
+ const newdatas = [];
|
|
|
+ for (let level of levels) {
|
|
|
+ level = JSON.parse(JSON.stringify(level));
|
|
|
+ const dept = await this.dmodel.findById(level.dept_id);
|
|
|
+ level.dept_name = dept.name;
|
|
|
+ newdatas.push(level);
|
|
|
+ }
|
|
|
+ return { data: newdatas, total };
|
|
|
}
|
|
|
|
|
|
}
|