lrf 2 年之前
父节点
当前提交
ee721b0690
共有 1 个文件被更改,包括 2 次插入0 次删除
  1. 2 0
      app/service/user/user.js

+ 2 - 0
app/service/user/user.js

@@ -113,6 +113,8 @@ class UserService extends CrudService {
    * @param body.phone 用户要绑定的手机
    */
   async toBindPhone({ id, phone }) {
+    const num = await this.model.count({ phone });
+    if (num > 0) throw new BusinessError(ErrorCode.DATA_EXISTED, '手机号已被绑定');
     const code = _.random(100000, 999999);
     const value = `${phone}${this.conenctCode}${code}`;
     await this.redis.set(`${this.bindPhoneKey}${id}`, value, 'EX', 300);