|
@@ -10,6 +10,15 @@ class UserService extends CrudService {
|
|
|
super(ctx, 'user');
|
|
|
this.model = this.ctx.model.User.User;
|
|
|
}
|
|
|
+ async beforeCreate(data) {
|
|
|
+ const phone = _.get(data, 'phone');
|
|
|
+ if (phone) {
|
|
|
+ const num = await this.model.count({ phone });
|
|
|
+ if (num > 0) throw new BusinessError(ErrorCode.DATA_EXISTED, '该手机号已注册');
|
|
|
+ }
|
|
|
+ return data;
|
|
|
+ }
|
|
|
+
|
|
|
async resetPwd({ id }, { password }) {
|
|
|
const data = await this.model.findById(id);
|
|
|
if (!data) throw new BusinessError(ErrorCode.USER_NOT_EXIST);
|