|
|
@ -9,10 +9,12 @@ namespace Build_God_Api.Controllers |
|
|
[Route("api/god/[controller]")]
|
|
|
[Route("api/god/[controller]")]
|
|
|
public class ShopController( |
|
|
public class ShopController( |
|
|
IShopService service, |
|
|
IShopService service, |
|
|
|
|
|
ICharacterService characterService, |
|
|
ICurrentUserService currentUserService |
|
|
ICurrentUserService currentUserService |
|
|
) : ControllerBase |
|
|
) : ControllerBase |
|
|
{ |
|
|
{ |
|
|
private readonly IShopService service = service; |
|
|
private readonly IShopService service = service; |
|
|
|
|
|
private readonly ICharacterService characterService = characterService; |
|
|
private readonly ICurrentUserService currentUserService = currentUserService; |
|
|
private readonly ICurrentUserService currentUserService = currentUserService; |
|
|
|
|
|
|
|
|
// ============ 商店物品配置管理(后台) ============
|
|
|
// ============ 商店物品配置管理(后台) ============
|
|
|
@ -59,7 +61,12 @@ namespace Build_God_Api.Controllers |
|
|
[Authorize] |
|
|
[Authorize] |
|
|
public async Task<ActionResult<ShopDto>> GetCharacterShop() |
|
|
public async Task<ActionResult<ShopDto>> 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; |
|
|
return characterList; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@ -67,7 +74,12 @@ namespace Build_God_Api.Controllers |
|
|
[Authorize] |
|
|
[Authorize] |
|
|
public async Task<ActionResult<bool>> BuyItem([FromBody] ShopBuyDto dto) |
|
|
public async Task<ActionResult<bool>> 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); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|