diff --git a/Binance.TradeRobot.API/Controllers/OrderController.cs b/Binance.TradeRobot.API/Controllers/OrderController.cs new file mode 100644 index 0000000..8f52fd5 --- /dev/null +++ b/Binance.TradeRobot.API/Controllers/OrderController.cs @@ -0,0 +1,41 @@ +using Binance.TradeRobot.Business; +using Binance.TradeRobot.Model.Dto; +using Microsoft.AspNetCore.Authentication.JwtBearer; +using Microsoft.AspNetCore.Authorization; +using Microsoft.AspNetCore.Mvc; +using System.Collections.Generic; + +namespace Binance.TradeRobot.API.Controllers +{ + [Authorize(AuthenticationSchemes = JwtBearerDefaults.AuthenticationScheme)] + public class OrderController : BaseApiController + { + private OrderBusiness orderBusiness; + public OrderController(OrderBusiness orderBusiness) + { + this.orderBusiness = orderBusiness; + } + + /// + /// 获取现货/逐仓杠杆订单记录 + /// + /// + /// + [HttpGet("{robotId}")] + public IList GetSpotOrderList([FromRoute] long robotId) + { + return orderBusiness.GetSpotOrderList(robotId); + } + + /// + /// 获取执行日志记录 + /// + /// + /// + [HttpGet("{robotId}")] + public IList GetExecutionLogList([FromRoute] long robotId) + { + return orderBusiness.GetExecutionLogList(robotId); + } + } +} diff --git a/Binance.TradeRobot.Business/Business/OrderBusiness.cs b/Binance.TradeRobot.Business/Business/OrderBusiness.cs new file mode 100644 index 0000000..bcc6dfc --- /dev/null +++ b/Binance.TradeRobot.Business/Business/OrderBusiness.cs @@ -0,0 +1,29 @@ +using Binance.TradeRobot.Common.DI; +using Binance.TradeRobot.Model.Db; +using Binance.TradeRobot.Model.Dto; +using Microsoft.Extensions.Caching.Memory; +using Microsoft.Extensions.DependencyInjection; +using System.Collections.Generic; +using Yitter.IdGenerator; + +namespace Binance.TradeRobot.Business +{ + [BatchRegistration(ServiceLifetime.Singleton, RegistrationType.Self)] + public class OrderBusiness : BaseBusiness + { + public OrderBusiness(IFreeSql fsql, NLogManager logManager, IIdGenerator idGenerator, IMemoryCache memoryCache) : base(fsql, logManager, idGenerator, memoryCache) + { + + } + + public IList GetSpotOrderList(long robotId) + { + return fsql.Select().Where(o => o.RobotId == robotId).OrderByDescending(o => o.CreateTime).Page(1, 20).ToList(); + } + + public IList GetExecutionLogList(long robotId) + { + return fsql.Select().Where(l => l.RobotId == robotId).OrderByDescending(l => l.CreateTime).Page(1, 50).ToList(); + } + } +} diff --git a/Binance.TradeRobot.Model/Base/MappingProfiles.cs b/Binance.TradeRobot.Model/Base/MappingProfiles.cs index 684e838..036b463 100644 --- a/Binance.TradeRobot.Model/Base/MappingProfiles.cs +++ b/Binance.TradeRobot.Model/Base/MappingProfiles.cs @@ -27,10 +27,10 @@ namespace Binance.TradeRobot.Model.Base .ForPath(t => t.ExchangeAPIKey.AccountId, opt => opt.MapFrom(f => f.ExchangeAccountId)) .ForPath(t => t.ExchangeAPIKey.APIKey, opt => opt.MapFrom(f => f.ExchangeAPIKey)) .ForPath(t => t.ExchangeAPIKey.SecretKey, opt => opt.MapFrom(f => f.ExchangeSecretKey)); - //.ForPath(t => t.SymbolInfo.Id, opt => opt.MapFrom(f => f.SymbolId)) - //.ForPath(t => t.SymbolInfo.Symbol, opt => opt.MapFrom(f => f.Symbol)) - //.ForPath(t => t.SymbolInfo.SaleQuantityAccuracy, opt => opt.MapFrom(f => f.SymbolSaleQuantityAccuracy)) - //.ForPath(t => t.SymbolInfo.ExchangeId, opt => opt.MapFrom(f => f.ExchangeId)); + //.ForPath(t => t.SymbolInfo.Id, opt => opt.MapFrom(f => f.SymbolId)) + //.ForPath(t => t.SymbolInfo.Symbol, opt => opt.MapFrom(f => f.Symbol)) + //.ForPath(t => t.SymbolInfo.SaleQuantityAccuracy, opt => opt.MapFrom(f => f.SymbolSaleQuantityAccuracy)) + //.ForPath(t => t.SymbolInfo.ExchangeId, opt => opt.MapFrom(f => f.ExchangeId)); CreateMap().IncludeBase() .ForPath(t => t.D21Policy.Id, opt => opt.MapFrom(f => f.D21PolicyId)) .ForPath(t => t.D21Policy.RobotId, opt => opt.MapFrom(f => f.Id)) @@ -51,6 +51,7 @@ namespace Binance.TradeRobot.Model.Base CreateMap(); CreateMap(); + //CreateMap(); } } } diff --git a/Binance.TradeRobot.Model/Dto/Response/Order/ExecutionLogResponse.cs b/Binance.TradeRobot.Model/Dto/Response/Order/ExecutionLogResponse.cs new file mode 100644 index 0000000..badcb45 --- /dev/null +++ b/Binance.TradeRobot.Model/Dto/Response/Order/ExecutionLogResponse.cs @@ -0,0 +1,8 @@ +using Binance.TradeRobot.Model.Db; + +namespace Binance.TradeRobot.Model.Dto +{ + public class ExecutionLogResponse : ExecutionLog + { + } +} diff --git a/Binance.TradeRobot.Model/Dto/Response/Order/SpotOrderResponse.cs b/Binance.TradeRobot.Model/Dto/Response/Order/SpotOrderResponse.cs new file mode 100644 index 0000000..5872c88 --- /dev/null +++ b/Binance.TradeRobot.Model/Dto/Response/Order/SpotOrderResponse.cs @@ -0,0 +1,9 @@ +using Binance.TradeRobot.Model.Db; + +namespace Binance.TradeRobot.Model.Dto +{ + public class SpotOrderResponse : SpotOrder + { + + } +}