Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update packages #31

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

<ItemGroup>
<PackageReference Include="EasyMicroservices.Configuration" Version="0.0.0.3" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="7.0.14" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="7.0.15" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace EasyMicroservices.StorageMicroservice.Contracts.Requests
{
public class GetByKeyRequestContract : GetUniqueIdentityRequestContract
public class GetByKeyRequestContract : GetByUniqueIdentityRequestContract
{
public string Key { get; set; }
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Http.Features" Version="5.0.17" />
<PackageReference Include="EasyMicroservices.Cores.AspEntityFrameworkCoreApi" Version="0.0.0.64" />
<PackageReference Include="EasyMicroservices.Cores.AspEntityFrameworkCoreApi" Version="0.0.1.43" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
using EasyMicroservices.Cores.Relational.EntityFrameworkCore.Intrerfaces;
using EasyMicroservices.Cores.Relational.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Configuration;

namespace EasyMicroservices.StorageMicroservice
{
public class DatabaseBuilder : IEntityFrameworkCoreDatabaseBuilder
public class DatabaseBuilder : EntityFrameworkCoreDatabaseBuilder
{
public DatabaseBuilder(IConfiguration configuration)
public DatabaseBuilder(IConfiguration configuration) : base(configuration)
{
_config = configuration;
}

readonly IConfiguration _config;

public void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
public override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
optionsBuilder.UseInMemoryDatabase("Storage");
//optionsBuilder.UseSqlServer(_config.GetConnectionString("local"));
var entity = GetEntity();
if (entity.IsSqlServer())
optionsBuilder.UseSqlServer(entity.ConnectionString);
else if (entity.IsInMemory())
optionsBuilder.UseInMemoryDatabase("Storage");
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

<ItemGroup>
<PackageReference Include="EasyMicroservices.FileManager" Version="0.0.0.3" />
<PackageReference Include="Microsoft.EntityFrameworkCore.InMemory" Version="7.0.14" />
<PackageReference Include="Microsoft.EntityFrameworkCore.InMemory" Version="7.0.15" />
<PackageReference Include="Microsoft.Extensions.Configuration" Version="7.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="7.0.0" />
</ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ public async Task<MessageContract<FileContract>> UploadOrReplaceFile([FromForm]
[HttpDelete]
public async Task<MessageContract> DeleteFileByPassword(long fileId, string password)
{
var find = await GetById(new Cores.Contracts.Requests.GetIdRequestContract<long>()
var find = await GetById(new Cores.Contracts.Requests.GetByIdRequestContract<long>()
{
Id = fileId
});
Expand Down Expand Up @@ -152,10 +152,11 @@ private static string GenerateDownloadLink(HttpContext httpContext, long fileId,
}

[HttpGet]
[AllowAnonymous]
[ProducesResponseType(typeof(FileContentResult), 200)]
public async Task<FileContentResult> DownloadFileAsync([FromQuery] long id, [FromQuery] string password)
{
var file = await GetById(new Cores.Contracts.Requests.GetIdRequestContract<long>()
var file = await GetById(new Cores.Contracts.Requests.GetByIdRequestContract<long>()
{
Id = id
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="EasyMicroservices.Cores.AspCoreApi" Version="0.0.0.64" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="7.0.14">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
Expand All @@ -17,5 +16,12 @@
<ItemGroup>
<ProjectReference Include="..\EasyMicroservices.StorageMicroservice.StartUp\EasyMicroservices.StorageMicroservice.StartUp.csproj" />
</ItemGroup>


<ItemGroup>
<Content Update="web.config" CopyToPublishDirectory="Never" />
<Content Update="appsettings.json" CopyToPublishDirectory="Never" />
<Content Update="appsettings.*.json" CopyToPublishDirectory="Never" />
<Content Update="appsettings.$(MSBuildThisFileName).json" CopyToPublishDirectory="PreserveNewest" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -14,25 +14,27 @@ public class Program
public static async Task Main(string[] args)
{
var app = CreateBuilder(args);
var build = await app.Build<StorageContext>(true);
var build = await app.BuildWithUseCors<StorageContext>(null, true);
build.MapControllers();
var filesPath = build.Configuration.GetValue<string>("DiskFilesPath");
if (filesPath != ".")
WebRootPath = filesPath;
await build.RunAsync();
}
static string WebRootPath = Directory.GetCurrentDirectory();

static WebApplicationBuilder CreateBuilder(string[] args)
{
var app = StartUpExtensions.Create<StorageContext>(args);
app.Services.Builder<StorageContext>().UseDefaultSwaggerOptions();
app.Services.Builder<StorageContext>("Storage")
.UseDefaultSwaggerOptions();
app.Services.AddTransient(serviceProvider => new StorageContext(serviceProvider.GetService<IEntityFrameworkCoreDatabaseBuilder>()));
app.Services.AddTransient<IEntityFrameworkCoreDatabaseBuilder, DatabaseBuilder>();
app.Services.AddTransient<IAppUnitOfWork>(serviceProvider => new AppUnitOfWork(serviceProvider));

string webRootPath = Directory.GetCurrentDirectory();
app.Services.AddScoped<IPathProvider>(serviceProvider => new SystemPathProvider());
app.Services.AddScoped<IDirectoryManagerProvider>(serviceProvider => new DiskDirectoryProvider(webRootPath));
app.Services.AddTransient<IFileManagerProvider>(serviceProvider => new DiskFileProvider(new DiskDirectoryProvider(webRootPath)));
StartUpExtensions.AddWhiteLabel("Storage", "RootAddresses:WhiteLabel");
StartUpExtensions.AddAuthentication("RootAddresses:Authentication");
app.Services.AddScoped<IDirectoryManagerProvider>(serviceProvider => new DiskDirectoryProvider(WebRootPath));
app.Services.AddTransient<IFileManagerProvider>(serviceProvider => new DiskFileProvider(new DiskDirectoryProvider(WebRootPath)));
return app;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,35 @@
}
},
"AllowedHosts": "*",
"ConnectionStrings": {
"local": "Server=.;Database=Storage;TrustServerCertificate=True;"
},
"RootAddresses": {
"WhiteLabel": "http://localhost:1041"
"Databases": [
{
"Name": "Entity",
"ProviderName": "InMemory",
"ConnectionString": "Server=.;Database=Storage;Integrated Security=True;Trusted_Connection=True;TrustServerCertificate=True"
}
],
"ServiceAddresses": [
{
"Name": "Authentication",
"Address": "http://localhost:1044",
"Databases": null
},
{
"Name": "WhiteLabel",
"Address": "http://localhost:1041",
"Databases": null
}
],
"Authorization": {
"Use": true,
"JWT": {
"Key": "key",
"Issuer": "https://github.com/easymicroservices",
"Audience": "easymicroservices",

"TokenExpireTimeInSeconds": 86400
},
"FullAccessPAT": "ownerpat"
},
"Urls": "http://*:1043"
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,42 @@
}
},
"AllowedHosts": "*",
"ConnectionStrings": {
"local": "Server=.;Database=Storage;TrustServerCertificate=True;"
"Databases": [
{
"Name": "Entity",
"ProviderName": "InMemory",
"ConnectionString": "Server=.;Database=Storage;Integrated Security=True;Trusted_Connection=True;TrustServerCertificate=True"
}
],
"ServiceAddresses": [
{
"Name": "Authentication",
"Address": "http://localhost:1044",
"Databases": null
},
{
"Name": "WhiteLabel",
"Address": "http://localhost:1041",
"Databases": null
}
],
"Authorization": {
"Use": true,
"JWT": {
"Key": "key",
"Issuer": "https://github.com/easymicroservices",
"Audience": "easymicroservices",

"TokenExpireTimeInSeconds": 86400
},
"FullAccessPAT": "ownerpat"
},
"RootAddresses": {
"WhiteLabel": "http://localhost:1041"
"Swagger": {
"IsUse": true,
"SwaggerUI": {
"Endpoints": []
}
},
"DiskFilesPath": ".",
"Urls": "http://*:1043"
}
Loading