feat: 完成ai生成
This commit is contained in:
@@ -5,11 +5,13 @@ using Microsoft.AspNetCore.Mvc;
|
||||
using SqlSugar;
|
||||
using Volo.Abp.Application.Dtos;
|
||||
using Volo.Abp.Application.Services;
|
||||
using Volo.Abp.Users;
|
||||
using Yi.Framework.Stock.Application.Contracts.Dtos.StockMarket;
|
||||
using Yi.Framework.Stock.Application.Contracts.Dtos.StockPrice;
|
||||
using Yi.Framework.Stock.Application.Contracts.IServices;
|
||||
using Yi.Framework.Stock.Domain.Entities;
|
||||
using Yi.Framework.SqlSugarCore.Abstractions;
|
||||
using Yi.Framework.Stock.Domain.Managers;
|
||||
|
||||
namespace Yi.Framework.Stock.Application.Services
|
||||
{
|
||||
@@ -20,13 +22,16 @@ namespace Yi.Framework.Stock.Application.Services
|
||||
{
|
||||
private readonly ISqlSugarRepository<StockMarketAggregateRoot> _stockMarketRepository;
|
||||
private readonly ISqlSugarRepository<StockPriceRecordEntity> _stockPriceRecordRepository;
|
||||
private readonly StockMarketManager _stockMarketManager;
|
||||
|
||||
public StockMarketService(
|
||||
ISqlSugarRepository<StockMarketAggregateRoot> stockMarketRepository,
|
||||
ISqlSugarRepository<StockPriceRecordEntity> stockPriceRecordRepository)
|
||||
ISqlSugarRepository<StockPriceRecordEntity> stockPriceRecordRepository,
|
||||
StockMarketManager stockMarketManager)
|
||||
{
|
||||
_stockMarketRepository = stockMarketRepository;
|
||||
_stockPriceRecordRepository = stockPriceRecordRepository;
|
||||
_stockMarketManager = stockMarketManager;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -91,5 +96,41 @@ namespace Yi.Framework.Stock.Application.Services
|
||||
|
||||
return new PagedResultDto<StockPriceRecordDto>(total, list);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 买入股票
|
||||
/// </summary>
|
||||
[HttpPost("stock/buy")]
|
||||
[Authorize]
|
||||
public async Task BuyStockAsync(BuyStockInputDto input)
|
||||
{
|
||||
// 获取当前登录用户ID
|
||||
var userId = CurrentUser.GetId();
|
||||
|
||||
// 调用领域服务进行股票购买
|
||||
await _stockMarketManager.BuyStockAsync(
|
||||
userId,
|
||||
input.StockId,
|
||||
input.Quantity
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 卖出股票
|
||||
/// </summary>
|
||||
[HttpPost("stock/sell")]
|
||||
[Authorize]
|
||||
public async Task SellStockAsync(SellStockInputDto input)
|
||||
{
|
||||
// 获取当前登录用户ID
|
||||
var userId = CurrentUser.GetId();
|
||||
|
||||
// 调用领域服务进行股票卖出
|
||||
await _stockMarketManager.SellStockAsync(
|
||||
userId,
|
||||
input.StockId,
|
||||
input.Quantity
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user