|
@@ -35,6 +35,29 @@ class UserService extends CrudService {
|
|
|
return res;
|
|
|
}
|
|
|
|
|
|
+ async update({ id }, { name, mobile, passwd, openid }) {
|
|
|
+ assert(id, '缺少部分信息项');
|
|
|
+ const user = await this.model.findById(id);
|
|
|
+ if (!user) {
|
|
|
+ throw new BusinessError(ErrorCode.DATA_NOT_EXIST, '用户信息不存在');
|
|
|
+ }
|
|
|
+ if (passwd) {
|
|
|
+ user.passwd = { secret: passwd };
|
|
|
+ }
|
|
|
+ if (name) {
|
|
|
+ user.name = name;
|
|
|
+ }
|
|
|
+ if (mobile) {
|
|
|
+ user.mobile = mobile;
|
|
|
+ }
|
|
|
+ if (openid) {
|
|
|
+ user.openid = openid;
|
|
|
+ }
|
|
|
+ await user.save();
|
|
|
+
|
|
|
+ return user;
|
|
|
+ }
|
|
|
+
|
|
|
// 学校注册
|
|
|
async register(data) {
|
|
|
const { code, mobile, passwd, name } = data;
|