lrf 2 anos atrás
pai
commit
ee721b0690
1 arquivos alterados com 2 adições e 0 exclusões
  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);