| | |
| | | * @returns |
| | | */ |
| | | async person(id) { |
| | | const info = await this.userInfoEntity.findOneBy({ id: Equal(id) }); |
| | | //delete info.password; |
| | | const idText = id === undefined || id === null ? '' : String(id); |
| | | // 手机号登录签发的是 unionid(手机号),不能拿去查整型主键 |
| | | let info = null; |
| | | if (/^\d{1,10}$/.test(idText)) { |
| | | info = await this.userInfoEntity.findOneBy({ id: Equal(Number(idText)) }); |
| | | } |
| | | if (!info && idText) { |
| | | info = await this.userInfoEntity.findOneBy({ |
| | | unionid: Equal(idText), |
| | | }); |
| | | } |
| | | return info; |
| | | } |
| | | |
| | |
| | | * @param userId |
| | | */ |
| | | async logoff(userId: number) { |
| | | const info = await this.person(userId); |
| | | if (!info) { |
| | | throw new CoolCommException('用户不存在'); |
| | | } |
| | | await this.userInfoEntity.update( |
| | | { id: userId }, |
| | | { id: info.id }, |
| | | { |
| | | status: 2, |
| | | phone: "", |
| | |
| | | } |
| | | } catch (err) { } |
| | | try { |
| | | return await this.userInfoEntity.update({ id }, param); |
| | | return await this.userInfoEntity.update({ id: info.id }, param); |
| | | } catch (err) { |
| | | throw new CoolCommException('更新失败,参数错误或者手机号已存在'); |
| | | } |
| | |
| | | throw new CoolCommException('验证码错误'); |
| | | } |
| | | |
| | | await this.userInfoEntity.update(user.unionid, { |
| | | await this.userInfoEntity.update(user.id, { |
| | | password: md5(password), |
| | | }); |
| | | } |
| | |
| | | if (!check) { |
| | | throw new CoolCommException('验证码错误'); |
| | | } |
| | | await this.userInfoEntity.update({ id: userId }, { phone }); |
| | | const info = await this.person(userId); |
| | | if (!info) { |
| | | throw new CoolCommException('用户不存在'); |
| | | } |
| | | await this.userInfoEntity.update({ id: info.id }, { phone }); |
| | | } |
| | | |
| | | /** |