|
@@ -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);
|