|
@@ -60,34 +60,36 @@ class UserService extends CrudService {
|
|
|
return res;
|
|
|
}
|
|
|
|
|
|
- async update({ id }, { name, mobile, passwd, openid, status, type }) {
|
|
|
+ async update({ id }, body) {
|
|
|
+ const { name, mobile, passwd, openid, status, type } = body;
|
|
|
assert(id, '缺少部分信息项');
|
|
|
const user = await this.model.findById(id);
|
|
|
if (!user) {
|
|
|
throw new BusinessError(ErrorCode.DATA_NOT_EXIST, '用户信息不存在');
|
|
|
}
|
|
|
if (passwd) {
|
|
|
- user.passwd = { secret: passwd };
|
|
|
+ body.passwd = { secret: passwd };
|
|
|
}
|
|
|
- if (name) {
|
|
|
- user.name = name;
|
|
|
- }
|
|
|
- if (mobile) {
|
|
|
- user.mobile = mobile;
|
|
|
- }
|
|
|
- if (openid) {
|
|
|
- user.openid = openid;
|
|
|
- }
|
|
|
- if (status) {
|
|
|
- user.status = status;
|
|
|
- } else {
|
|
|
- user.status = '1';
|
|
|
- }
|
|
|
- if (type) {
|
|
|
- user.type = type;
|
|
|
- }
|
|
|
- await user.save();
|
|
|
- return user;
|
|
|
+ return await this.model.updateOne({ _id: id }, body);
|
|
|
+ // if (name) {
|
|
|
+ // user.name = name;
|
|
|
+ // }
|
|
|
+ // if (mobile) {
|
|
|
+ // user.mobile = mobile;
|
|
|
+ // }
|
|
|
+ // if (openid) {
|
|
|
+ // user.openid = openid;
|
|
|
+ // }
|
|
|
+ // if (status) {
|
|
|
+ // user.status = status;
|
|
|
+ // } else {
|
|
|
+ // user.status = '1';
|
|
|
+ // }
|
|
|
+ // if (type) {
|
|
|
+ // user.type = type;
|
|
|
+ // }
|
|
|
+ // await user.save();
|
|
|
+ // return user;
|
|
|
}
|
|
|
|
|
|
// 学校注册
|