From 0d90e20ec20f0aeee642756a7ebf9e8514174124 Mon Sep 17 00:00:00 2001
From: wangrong <wangrong@shsening.com>
Date: 星期一, 26 十月 2026 21:15:20 +0800
Subject: [PATCH] 微信小程序插件支持
---
src/modules/user/service/info.ts | 29 +++++++++++++++++++++++------
1 files changed, 23 insertions(+), 6 deletions(-)
diff --git a/src/modules/user/service/info.ts b/src/modules/user/service/info.ts
index c918e6f..73f26c9 100644
--- a/src/modules/user/service/info.ts
+++ b/src/modules/user/service/info.ts
@@ -50,8 +50,17 @@
* @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;
}
@@ -60,8 +69,12 @@
* @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: "",
@@ -92,7 +105,7 @@
}
} catch (err) { }
try {
- return await this.userInfoEntity.update({ id }, param);
+ return await this.userInfoEntity.update({ id: info.id }, param);
} catch (err) {
throw new CoolCommException('鏇存柊澶辫触锛屽弬鏁伴敊璇垨鑰呮墜鏈哄彿宸插瓨鍦�');
}
@@ -116,7 +129,7 @@
throw new CoolCommException('楠岃瘉鐮侀敊璇�');
}
- await this.userInfoEntity.update(user.unionid, {
+ await this.userInfoEntity.update(user.id, {
password: md5(password),
});
}
@@ -132,7 +145,11 @@
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 });
}
/**
--
Gitblit v1.9.1