From 6adde41763df6e00dca6088f78834451dc9a1bd0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=A7=A6=E6=B1=89?= <5725748+qin_and_han_dynasties@user.noreply.gitee.com> Date: Wed, 29 Apr 2026 21:57:58 +0800 Subject: [PATCH] =?UTF-8?q?=E5=95=86=E5=BA=97=E6=95=B0=E6=8D=AE=E7=94=A8?= =?UTF-8?q?=E7=9A=84=E6=98=AF=E8=B4=A6=E5=8F=B7id=E7=9A=84bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Build_God_Api/Controllers/ShopController.cs | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/Build_God_Api/Build_God_Api/Controllers/ShopController.cs b/Build_God_Api/Build_God_Api/Controllers/ShopController.cs index 6311d8f..fd63c57 100644 --- a/Build_God_Api/Build_God_Api/Controllers/ShopController.cs +++ b/Build_God_Api/Build_God_Api/Controllers/ShopController.cs @@ -9,10 +9,12 @@ namespace Build_God_Api.Controllers [Route("api/god/[controller]")] public class ShopController( IShopService service, + ICharacterService characterService, ICurrentUserService currentUserService ) : ControllerBase { private readonly IShopService service = service; + private readonly ICharacterService characterService = characterService; private readonly ICurrentUserService currentUserService = currentUserService; // ============ 商店物品配置管理(后台) ============ @@ -59,7 +61,12 @@ namespace Build_God_Api.Controllers [Authorize] public async Task> GetCharacterShop() { - var characterList = await service.GetCharacterShop(currentUserService.UserId); + var character = await characterService.GetCharacterByAccountId(currentUserService.UserId); + if (character == null) + { + return NotFound(); + } + var characterList = await service.GetCharacterShop(character.Id); return characterList; } @@ -67,7 +74,12 @@ namespace Build_God_Api.Controllers [Authorize] public async Task> BuyItem([FromBody] ShopBuyDto dto) { - return await service.BuyItem(currentUserService.UserId, dto.ShopItemId); + var character = await characterService.GetCharacterByAccountId(currentUserService.UserId); + if (character == null) + { + return NotFound(); + } + return await service.BuyItem(character.Id, dto.ShopItemId); } }