fix: 添加 /api/v1/portfolio/transactions 路由支持 query parameter
前端请求格式: /api/v1/portfolio/transactions?portfolioId=xxx
后端原有路由: /api/v1/portfolio/{id}/transactions
添加 [HttpGet("transactions")] 支持 query parameter 方式
This commit is contained in:
parent
781f707419
commit
7db098b5f9
@ -98,6 +98,50 @@ public class PortfolioController : ControllerBase
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取交易记录(通过 query parameter)
|
||||||
|
/// </summary>
|
||||||
|
[HttpGet("transactions")]
|
||||||
|
public async Task<ActionResult<ApiResponse<GetTransactionsResponse>>> 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<GetTransactionsResponse>
|
||||||
|
{
|
||||||
|
code = Models.StatusCodes.Success,
|
||||||
|
data = new GetTransactionsResponse
|
||||||
|
{
|
||||||
|
Items = transactions,
|
||||||
|
Total = transactions.Count
|
||||||
|
},
|
||||||
|
message = "success"
|
||||||
|
});
|
||||||
|
}
|
||||||
|
catch (UnauthorizedAccessException)
|
||||||
|
{
|
||||||
|
return NotFound(new ApiResponse<GetTransactionsResponse>
|
||||||
|
{
|
||||||
|
code = Models.StatusCodes.NotFound,
|
||||||
|
data = null,
|
||||||
|
message = "组合不存在"
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 获取投资组合详情
|
/// 获取投资组合详情
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user