mirror of
https://gitee.com/ccnetcore/Yi
synced 2026-04-14 05:06:37 +08:00
feat: 新增ai-stock模块
This commit is contained in:
@@ -0,0 +1,95 @@
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using SqlSugar;
|
||||
using Volo.Abp.Application.Dtos;
|
||||
using Volo.Abp.Application.Services;
|
||||
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;
|
||||
|
||||
namespace Yi.Framework.Stock.Application.Services
|
||||
{
|
||||
/// <summary>
|
||||
/// 股市服务实现
|
||||
/// </summary>
|
||||
public class StockMarketService : ApplicationService, IStockMarketService
|
||||
{
|
||||
private readonly ISqlSugarRepository<StockMarketAggregateRoot> _stockMarketRepository;
|
||||
private readonly ISqlSugarRepository<StockPriceRecordEntity> _stockPriceRecordRepository;
|
||||
|
||||
public StockMarketService(
|
||||
ISqlSugarRepository<StockMarketAggregateRoot> stockMarketRepository,
|
||||
ISqlSugarRepository<StockPriceRecordEntity> stockPriceRecordRepository)
|
||||
{
|
||||
_stockMarketRepository = stockMarketRepository;
|
||||
_stockPriceRecordRepository = stockPriceRecordRepository;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取股市列表
|
||||
/// </summary>
|
||||
[HttpGet("stock/markets")]
|
||||
public async Task<PagedResultDto<StockMarketDto>> GetStockMarketListAsync(StockMarketGetListInputDto input)
|
||||
{
|
||||
RefAsync<int> total = 0;
|
||||
|
||||
var query = _stockMarketRepository._DbQueryable
|
||||
.WhereIF(!string.IsNullOrEmpty(input.MarketCode), m => m.MarketCode.Contains(input.MarketCode))
|
||||
.WhereIF(!string.IsNullOrEmpty(input.MarketName), m => m.MarketName.Contains(input.MarketName))
|
||||
.WhereIF(input.State.HasValue, m => m.State == input.State.Value)
|
||||
.OrderByIF(!string.IsNullOrEmpty(input.Sorting),input.Sorting)
|
||||
.OrderByIF(string.IsNullOrEmpty(input.Sorting),m=>m.OrderNum,OrderByType.Asc)
|
||||
.OrderByIF(string.IsNullOrEmpty(input.Sorting),m=>m.CreationTime,OrderByType.Desc);
|
||||
|
||||
var list = await query
|
||||
.Select(m => new StockMarketDto
|
||||
{
|
||||
Id = m.Id,
|
||||
MarketCode = m.MarketCode,
|
||||
MarketName = m.MarketName,
|
||||
Description = m.Description,
|
||||
State = m.State,
|
||||
CreationTime = m.CreationTime
|
||||
})
|
||||
.ToPageListAsync(input.SkipCount, input.MaxResultCount, total);
|
||||
|
||||
return new PagedResultDto<StockMarketDto>(total, list);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取股市价格记录看板
|
||||
/// </summary>
|
||||
[HttpGet("stock/price-records")]
|
||||
public async Task<PagedResultDto<StockPriceRecordDto>> GetStockPriceRecordListAsync(StockPriceRecordGetListInputDto input)
|
||||
{
|
||||
RefAsync<int> total = 0;
|
||||
|
||||
var query = _stockPriceRecordRepository._DbQueryable
|
||||
.WhereIF(input.StockId.HasValue, p => p.StockId == input.StockId.Value)
|
||||
.WhereIF(input.StartTime.HasValue, p => p.CreationTime >= input.StartTime.Value)
|
||||
.WhereIF(input.EndTime.HasValue, p => p.CreationTime <= input.EndTime.Value)
|
||||
.WhereIF(input.PeriodType.HasValue, p => p.PeriodType == input.PeriodType.Value)
|
||||
.OrderByIF(!string.IsNullOrEmpty(input.Sorting),input.Sorting)
|
||||
.OrderByIF(string.IsNullOrEmpty(input.Sorting),p=>p.CreationTime,OrderByType.Desc);
|
||||
|
||||
var list = await query
|
||||
.Select(p => new StockPriceRecordDto
|
||||
{
|
||||
Id = p.Id,
|
||||
StockId = p.StockId,
|
||||
CreationTime = p.CreationTime,
|
||||
CurrentPrice = p.CurrentPrice,
|
||||
Volume = p.Volume,
|
||||
Turnover = p.Turnover,
|
||||
PeriodType = p.PeriodType
|
||||
})
|
||||
.ToPageListAsync(input.SkipCount, input.MaxResultCount, total);
|
||||
|
||||
return new PagedResultDto<StockPriceRecordDto>(total, list);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user