|
@@ -18,6 +18,24 @@ class BedroomService extends CrudService {
|
|
|
|
|
|
}
|
|
|
|
|
|
+ // 根据班级id查找班级下所有寝室列表并查询出寝室下学生信息
|
|
|
+ async roomstu({ id }) {
|
|
|
+ // 通过班级id查询学生表信息
|
|
|
+ const students = await this.smodel.find({ classid: id });
|
|
|
+ const _bedrooms = _.map(students, 'bedroom');
|
|
|
+ // 取得无重复的寝室号
|
|
|
+ const bedrooms = _.uniq(_bedrooms);
|
|
|
+ console.log(bedrooms);
|
|
|
+ const data = [];
|
|
|
+ // 根据寝室号 取得相应的学生信息
|
|
|
+ for (const elm of bedrooms) {
|
|
|
+ const stus = students.filter(item => item.bedroom === elm);
|
|
|
+ const newdata = { bedroom: elm, stus };
|
|
|
+ data.push(newdata);
|
|
|
+ }
|
|
|
+ return data;
|
|
|
+ }
|
|
|
+
|
|
|
async ibeacon(data) {
|
|
|
assert(data.openid, '用户信息不能为空');
|
|
|
// 通过openid取得学生信息
|