Browse Source

mssql改mysql

master
shanji 3 years ago
parent
commit
7af0ba22af
  1. 1
      Binance.TradeRobot.API/Binance.TradeRobot.API.csproj
  2. 2
      Binance.TradeRobot.API/Startup.cs
  3. 3
      Binance.TradeRobot.API/appsettings.json
  4. 1
      Binance.TradeRobot.Business/Binance.TradeRobot.Business.csproj
  5. 1
      Binance.TradeRobot.Business/Business/ExchangeBusiness.cs
  6. 8
      Binance.TradeRobot.Model/Db/Exchange/ExchangeAPIKey.cs
  7. 10
      Binance.TradeRobot.Model/Db/Exchange/ExchangeAccount.cs
  8. 32
      Binance.TradeRobot.Model/Db/代码生成/Exchangeaccount.cs
  9. 35
      Binance.TradeRobot.Model/Db/代码生成/Exchangeapikey.cs
  10. 2
      Binance.TradeRobot.Model/Db/代码生成/__重新生成.bat

1
Binance.TradeRobot.API/Binance.TradeRobot.API.csproj

@ -12,6 +12,7 @@
<ItemGroup>
<PackageReference Include="FreeSql" Version="3.0.100" />
<PackageReference Include="FreeSql.Provider.MySql" Version="3.0.100" />
<PackageReference Include="FreeSql.Provider.SqlServer" Version="3.0.100" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="3.1.22" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="3.1.22" />

2
Binance.TradeRobot.API/Startup.cs

@ -34,7 +34,7 @@ namespace Binance.TradeRobot.API
services.AddSingleton<NLogManager>();
services.AddSingleton<RestApiService>();
var fsql = new FreeSql.FreeSqlBuilder().UseConnectionString(FreeSql.DataType.SqlServer, Configuration.GetConnectionString("DB")).Build();
var fsql = new FreeSql.FreeSqlBuilder().UseConnectionString(FreeSql.DataType.MySql, Configuration.GetConnectionString("DB")).Build();
services.AddSingleton(typeof(IFreeSql), fsql);
var idOption = new IdGeneratorOptions(1);

3
Binance.TradeRobot.API/appsettings.json

@ -9,7 +9,8 @@
"AllowedHosts": "*",
"ConnectionStrings": {
//"DB": "Data Source=192.168.201.44;Initial Catalog=HY.TradingRobot.DB;User ID=sa;Pwd=kaicn1132+-;"
"DB": "Data Source=.;Initial Catalog=Binance.TradeRobot.DB;User ID=sa;Pwd=pc911103;Encrypt=True; TrustServerCertificate=True;"
//"DB": "Data Source=.;Initial Catalog=Binance.TradeRobot.DB;User ID=sa;Pwd=pc911103;Encrypt=True; TrustServerCertificate=True;"
"DB": "data source=47.245.58.112;port=3306;user id=sa;password=rYn6re2AKhcDWcBi;initial catalog=tradedb;charset=utf8;sslmode=none;"
},
"JwtConfig": {
"Secret": "heyitraderobot11",

1
Binance.TradeRobot.Business/Binance.TradeRobot.Business.csproj

@ -9,6 +9,7 @@
<ItemGroup>
<PackageReference Include="FreeSql" Version="3.0.100" />
<PackageReference Include="FreeSql.Provider.MySql" Version="3.0.100" />
<PackageReference Include="FreeSql.Provider.SqlServer" Version="3.0.100" />
<PackageReference Include="Microsoft.Extensions.Caching.Abstractions" Version="3.1.22" />
<PackageReference Include="NLog" Version="4.7.13" />

1
Binance.TradeRobot.Business/Business/ExchangeBusiness.cs

@ -34,7 +34,6 @@ namespace Binance.TradeRobot.Business.Exchange
var exchangeAccount = addExchangeAccountRequest.Map<ExchangeAccount>();
exchangeAccount.BusinessType = addExchangeAccountRequest.TradePolicy.GetBusinessType();
var exchangeAPIKey = new ExchangeAPIKey()
{
Id = idGenerator.NewLong(),

8
Binance.TradeRobot.Model/Db/Exchange/ExchangeAPIKey.cs

@ -4,24 +4,26 @@ using System;
namespace Binance.TradeRobot.Model.Db
{
[Table(DisableSyncStructure = true)]
[Table(DisableSyncStructure = true, Name = "exchangeapikey")]
public partial class ExchangeAPIKey
{
[Column(IsPrimary = true)]
[Column(IsPrimary = true, DbType = "bigint")]
public long Id { get; set; }
/// <summary>
/// 交易所账号Id
/// </summary>
[Column(DbType = "bigint")]
public long AccountId { get; set; }
[Column(StringLength = 100, IsNullable = false)]
public string APIKey { get; set; }
[Column(InsertValueSql = "getdate()")]
[Column(DbType = "datetime")]
public DateTime CreateTime { get; set; }
[Column(DbType = "bigint")]
public long? RobotId { get; set; }
[Column(StringLength = 100, IsNullable = false)]

10
Binance.TradeRobot.Model/Db/Exchange/ExchangeAccount.cs

@ -5,11 +5,15 @@ using System;
namespace Binance.TradeRobot.Model.Db
{
[Table(DisableSyncStructure = true)]
[Table(DisableSyncStructure = true, Name = "exchangeaccount")]
public partial class ExchangeAccount
{
public ExchangeAccount()
{
CreateTime = DateTime.Now;
}
[Column(IsPrimary = true)]
[Column(DbType = "bigint", IsPrimary = true)]
public long Id { get; set; }
/// <summary>
@ -18,7 +22,7 @@ namespace Binance.TradeRobot.Model.Db
[Column(MapType = typeof(int))]
public Enums.BusinessType BusinessType { get; set; }
[Column(InsertValueSql = "getdate()")]
[Column(DbType = "datetime")]
public DateTime CreateTime { get; set; }
/// <summary>

32
Binance.TradeRobot.Model/Db/代码生成/Exchangeaccount.cs

@ -0,0 +1,32 @@
using FreeSql.DatabaseModel;using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Threading.Tasks;
using Newtonsoft.Json;
using FreeSql.DataAnnotations;
namespace Binance.TradeRobot.Model.Db {
[JsonObject(MemberSerialization.OptIn), Table(Name = "exchangeaccount", DisableSyncStructure = true)]
public partial class Exchangeaccount {
[JsonProperty, Column(DbType = "bigint", IsPrimary = true)]
public long Id { get; set; }
[JsonProperty, Column(DbType = "int")]
public int? BusinessType { get; set; }
[JsonProperty, Column(DbType = "datetime")]
public DateTime? CreateTime { get; set; }
[JsonProperty, Column(StringLength = 50)]
public string LoginName { get; set; }
[JsonProperty, Column(DbType = "int")]
public int? TradePolicy { get; set; }
}
}

35
Binance.TradeRobot.Model/Db/代码生成/Exchangeapikey.cs

@ -0,0 +1,35 @@
using FreeSql.DatabaseModel;using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Threading.Tasks;
using Newtonsoft.Json;
using FreeSql.DataAnnotations;
namespace Binance.TradeRobot.Model.Db {
[JsonObject(MemberSerialization.OptIn), Table(Name = "exchangeapikey", DisableSyncStructure = true)]
public partial class Exchangeapikey {
[JsonProperty, Column(DbType = "bigint", IsPrimary = true)]
public long Id { get; set; }
[JsonProperty, Column(DbType = "bigint")]
public long AccountId { get; set; }
[JsonProperty, Column(StringLength = 100, IsNullable = false)]
public string APIKey { get; set; }
[JsonProperty, Column(DbType = "datetime")]
public DateTime CreateTime { get; set; }
[JsonProperty, Column(DbType = "bigint")]
public long? RobotId { get; set; }
[JsonProperty, Column(StringLength = 100, IsNullable = false)]
public string SecretKey { get; set; }
}
}

2
Binance.TradeRobot.Model/Db/代码生成/__重新生成.bat

@ -1 +1 @@
FreeSql.Generator -Razor 1 -NameOptions 1,0,0,0 -NameSpace Binance.TradeRobot.Model.Db -DB "SqlServer,data source=18.179.56.42;initial catalog=Binance.TradeRobot.DB;User Id=sa;Password=kaicn1132+-;TrustServerCertificate=true;pooling=true;max pool size=2" -FileName "{name}.cs"
FreeSql.Generator -Razor 1 -NameOptions 1,0,0,0 -NameSpace Binance.TradeRobot.Model.Db -DB "MySql,data source=47.245.58.112;port=3306;user id=sa;password=rYn6re2AKhcDWcBi;initial catalog=tradedb;charset=utf8;sslmode=none;max pool size=2" -FileName "{name}.cs"

Loading…
Cancel
Save