|
@@ -39,6 +39,35 @@ class SchoolService extends CrudService {
|
|
|
return res;
|
|
|
}
|
|
|
|
|
|
+ async query({ name, ...data }, { skip, limit }) {
|
|
|
+ const query = { ...data };
|
|
|
+ if (name) {
|
|
|
+ query.name = { $regex: name };
|
|
|
+ }
|
|
|
+ let res = await this.model.find(query).skip(parseInt(skip)).limit(parseInt(limit));
|
|
|
+ if (res && res.length > 0) {
|
|
|
+ res = JSON.parse(JSON.stringify(res));
|
|
|
+ const ids = res.map(i => i._id);
|
|
|
+ const users = await this.umodel.find({ uid: { $in: ids } }, '+passwd');
|
|
|
+ for (const tea of res) {
|
|
|
+ const r = users.find(f => f.uid === tea._id);
|
|
|
+ if (r) {
|
|
|
+ const passwd = _.get(r.passwd, 'secret');
|
|
|
+ if (passwd) tea.passwd = passwd;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return res;
|
|
|
+ }
|
|
|
+
|
|
|
+ async count({ name, ...data }) {
|
|
|
+ const query = { ...data };
|
|
|
+ if (name) {
|
|
|
+ query.name = { $regex: name };
|
|
|
+ }
|
|
|
+ return await this.model.count(query);
|
|
|
+ }
|
|
|
+
|
|
|
async stuimport(data) {
|
|
|
const { filepath, termid, schid, type, batchid } = data;
|
|
|
assert(filepath, 'filepath不能为空');
|