|
@@ -78,7 +78,7 @@ class UserService extends CrudService {
|
|
|
|
|
|
// 学生绑定
|
|
// 学生绑定
|
|
async bind(data) {
|
|
async bind(data) {
|
|
- const { openid, id_number, mobile, passwd } = data;
|
|
|
|
|
|
+ const { openid, id_number, mobile, passwd, unionid } = data;
|
|
assert(openid && id_number && mobile, '缺少部分信息项');
|
|
assert(openid && id_number && mobile, '缺少部分信息项');
|
|
let user = await this.model.findOne({ mobile });
|
|
let user = await this.model.findOne({ mobile });
|
|
if (user) {
|
|
if (user) {
|
|
@@ -86,6 +86,7 @@ class UserService extends CrudService {
|
|
throw new BusinessError(ErrorCode.BAD_PASSWORD);
|
|
throw new BusinessError(ErrorCode.BAD_PASSWORD);
|
|
}
|
|
}
|
|
user.openid = openid;
|
|
user.openid = openid;
|
|
|
|
+ user.unionid = unionid;
|
|
await user.save();
|
|
await user.save();
|
|
} else {
|
|
} else {
|
|
const stud = await this.stuModel.findOne({ id_number });
|
|
const stud = await this.stuModel.findOne({ id_number });
|
|
@@ -94,7 +95,7 @@ class UserService extends CrudService {
|
|
}
|
|
}
|
|
stud.openid = openid;
|
|
stud.openid = openid;
|
|
await stud.save();
|
|
await stud.save();
|
|
- const newdata = { name: stud.name, mobile: stud.phone, type: '4', uid: stud.id, openid };
|
|
|
|
|
|
+ const newdata = { name: stud.name, mobile: stud.phone, type: '4', uid: stud.id, openid, unionid };
|
|
newdata.passwd = { secret: '12345678' };
|
|
newdata.passwd = { secret: '12345678' };
|
|
user = await this.model.create(newdata);
|
|
user = await this.model.create(newdata);
|
|
}
|
|
}
|
|
@@ -138,6 +139,13 @@ class UserService extends CrudService {
|
|
return user;
|
|
return user;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ // 通过unionid查询用户信息
|
|
|
|
+ async findByunionid(unionid) {
|
|
|
|
+ // 通过unionid查询用户信息
|
|
|
|
+ const user = await this.model.findOne({ unionid });
|
|
|
|
+ return user;
|
|
|
|
+ }
|
|
|
|
+
|
|
// 学校用户生成
|
|
// 学校用户生成
|
|
async schoolregister() {
|
|
async schoolregister() {
|
|
const schools = await this.schModel.find();
|
|
const schools = await this.schModel.find();
|