feat: ai完成stock模块搭建

This commit is contained in:
橙子
2025-03-08 22:14:26 +08:00
parent 337088c908
commit 82865631fc
26 changed files with 1044 additions and 294 deletions

View File

@@ -12,6 +12,7 @@ using Yi.Framework.Stock.Application.Contracts.IServices;
using Yi.Framework.Stock.Domain.Entities;
using Yi.Framework.SqlSugarCore.Abstractions;
using Yi.Framework.Stock.Domain.Managers;
using Mapster;
namespace Yi.Framework.Stock.Application.Services
{
@@ -34,6 +35,23 @@ namespace Yi.Framework.Stock.Application.Services
_stockMarketManager = stockMarketManager;
}
/// <summary>
/// 创建股市
/// </summary>
[HttpPost("stock/markets")]
[Authorize]
public async Task<StockMarketDto> CreateStockMarketAsync(CreateStockMarketInputDto input)
{
// 使用映射将输入DTO转换为实体
var stockMarket = input.Adapt<StockMarketAggregateRoot>();
// 保存到数据库
var result = await _stockMarketRepository.InsertReturnEntityAsync(stockMarket);
// 使用映射将实体转换为返回DTO
return result.Adapt<StockMarketDto>();
}
/// <summary>
/// 获取股市列表
/// </summary>
@@ -87,6 +105,7 @@ namespace Yi.Framework.Stock.Application.Services
Id = p.Id,
StockId = p.StockId,
CreationTime = p.CreationTime,
RecordTime = p.RecordTime,
CurrentPrice = p.CurrentPrice,
Volume = p.Volume,
Turnover = p.Turnover,
@@ -132,5 +151,16 @@ namespace Yi.Framework.Stock.Application.Services
input.Quantity
);
}
/// <summary>
/// 生成最新股票记录
/// </summary>
[HttpPost("stock/generate")]
[Authorize]
public async Task GenerateStocksAsync()
{
await _stockMarketManager.GenerateStocksAsync();
}
}
}