From 7db098b5f97d8678154b8b4b8e356531b610cdcb Mon Sep 17 00:00:00 2001 From: OpenClaw Agent Date: Sun, 15 Mar 2026 14:20:11 +0000 Subject: [PATCH] =?UTF-8?q?fix:=20=E6=B7=BB=E5=8A=A0=20/api/v1/portfolio/t?= =?UTF-8?q?ransactions=20=E8=B7=AF=E7=94=B1=E6=94=AF=E6=8C=81=20query=20pa?= =?UTF-8?q?rameter?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 前端请求格式: /api/v1/portfolio/transactions?portfolioId=xxx 后端原有路由: /api/v1/portfolio/{id}/transactions 添加 [HttpGet("transactions")] 支持 query parameter 方式 --- .../Controllers/PortfolioController.cs | 44 +++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/AssetManager.API/Controllers/PortfolioController.cs b/AssetManager.API/Controllers/PortfolioController.cs index 5126e6b..5cb7c31 100755 --- a/AssetManager.API/Controllers/PortfolioController.cs +++ b/AssetManager.API/Controllers/PortfolioController.cs @@ -98,6 +98,50 @@ public class PortfolioController : ControllerBase }); } + /// + /// 获取交易记录(通过 query parameter) + /// + [HttpGet("transactions")] + public async Task>> GetTransactionsByQuery( + [FromQuery] string portfolioId, + [FromQuery] int limit = 20, + [FromQuery] int offset = 0) + { + var userId = GetCurrentUserId(); + + try + { + var request = new GetTransactionsRequest + { + PortfolioId = portfolioId, + Limit = limit, + Offset = offset + }; + + var transactions = await _portfolioFacade.GetTransactionsAsync(portfolioId, request, userId); + + return Ok(new ApiResponse + { + code = Models.StatusCodes.Success, + data = new GetTransactionsResponse + { + Items = transactions, + Total = transactions.Count + }, + message = "success" + }); + } + catch (UnauthorizedAccessException) + { + return NotFound(new ApiResponse + { + code = Models.StatusCodes.NotFound, + data = null, + message = "组合不存在" + }); + } + } + /// /// 获取投资组合详情 ///