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