From 693058c65da8c304b725414f1b23d5e3fa93b2ff Mon Sep 17 00:00:00 2001 From: zpc Date: Fri, 6 Dec 2024 14:05:01 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E7=94=A8=E6=88=B7=E5=8D=8F?= =?UTF-8?q?=E8=AE=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controllers/AccountController.cs | 14 ++++++++ .../CloudGaming.Code/Account/AccountBLL.cs | 32 +++++++++++++++++-- 2 files changed, 44 insertions(+), 2 deletions(-) diff --git a/src/CloudGaming/Api/CloudGaming.Api/Controllers/AccountController.cs b/src/CloudGaming/Api/CloudGaming.Api/Controllers/AccountController.cs index e6bba4c..a847d5a 100644 --- a/src/CloudGaming/Api/CloudGaming.Api/Controllers/AccountController.cs +++ b/src/CloudGaming/Api/CloudGaming.Api/Controllers/AccountController.cs @@ -119,4 +119,18 @@ public class AccountController : CloudGamingControllerBase await account.ExitApp(); return true; } + + /// + /// 账号注销 + /// + /// + [HttpPost] + [Message("注销成功")] + public async Task AccountLogOff() + { + AccountBLL account = new AccountBLL(ServiceProvider); + await account.AccountLogOff(); + return true; + } + } diff --git a/src/CloudGaming/Code/CloudGaming.Code/Account/AccountBLL.cs b/src/CloudGaming/Code/CloudGaming.Code/Account/AccountBLL.cs index a0b5632..4cf7e2d 100644 --- a/src/CloudGaming/Code/CloudGaming.Code/Account/AccountBLL.cs +++ b/src/CloudGaming/Code/CloudGaming.Code/Account/AccountBLL.cs @@ -719,8 +719,36 @@ namespace CloudGaming.Code.Account { await userInfo.DeleteUserInfoCache(this); } - - + } + /// + /// 账号注销 + /// + /// + public async Task AccountLogOff() + { + if (_UserId == 0) + { + return; + } + //redis + //用户信息 + var user = await Dao.DaoUser.Context.T_User.FirstOrDefaultAsync(it => it.Id == _UserId); + if (user != null) + { + user.State = 1; + } + //用户手机号登录表 + var userData = await Dao.DaoUser.Context.T_User_Phone_Account.FirstOrDefaultAsync(it => it.UserId == _UserId); + if (userData != null) + { + userData.IsLogout = true; + } + await Dao.DaoUser.Context.SaveChangesAsync(); + var userInfo = await AccountExtend.GetUserInfoOrNull(_UserId, this); + if (userInfo != null) + { + await userInfo.DeleteUserInfoCache(this); + } } } }