|
@@ -145,12 +145,63 @@ class UserService extends CrudService {
|
|
|
}
|
|
|
|
|
|
async findByAppOpenid(appopenid) {
|
|
|
+ console.log(appopenid);
|
|
|
|
|
|
if (!appopenid) {
|
|
|
console.error('没有appopenid');
|
|
|
return;
|
|
|
}
|
|
|
- const user = await this.model.findOne({ appopenid });
|
|
|
+ let user = await this.model.findOne({ appopenid }).populate({
|
|
|
+ path: 'uid',
|
|
|
+ model: 'Student',
|
|
|
+ select: 'classid bedroomid',
|
|
|
+ populate: [
|
|
|
+ {
|
|
|
+ path: 'classid',
|
|
|
+ model: 'Class',
|
|
|
+ select: 'jslocationid',
|
|
|
+ populate: {
|
|
|
+ path: 'jslocationid',
|
|
|
+ model: 'Location',
|
|
|
+ select: 'name ibeacon',
|
|
|
+ },
|
|
|
+ },
|
|
|
+ {
|
|
|
+ path: 'bedroomid',
|
|
|
+ model: 'Bedroom',
|
|
|
+ select: 'code ibeacon',
|
|
|
+ },
|
|
|
+ ],
|
|
|
+ });
|
|
|
+
|
|
|
+ if (user) {
|
|
|
+ user = JSON.parse(JSON.stringify(user));
|
|
|
+
|
|
|
+ const { uid } = user;
|
|
|
+ if (uid) {
|
|
|
+ const { _id, classid, bedroomid } = uid;
|
|
|
+
|
|
|
+ if (classid) {
|
|
|
+ const { jslocationid } = classid;
|
|
|
+ if (jslocationid) {
|
|
|
+ const { name, ibeacon } = jslocationid;
|
|
|
+ if (name && ibeacon) {
|
|
|
+ user.jsname = name;
|
|
|
+ user.jsibeacon = ibeacon;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if (bedroomid) {
|
|
|
+ const { code, ibeacon } = bedroomid;
|
|
|
+ if (code && ibeacon) {
|
|
|
+ user.bedroomname = code;
|
|
|
+ user.bedroomibeacon = ibeacon;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ user.uid = _id;
|
|
|
+ }
|
|
|
+ }
|
|
|
return user;
|
|
|
}
|
|
|
|