mirror of
https://github.com/DrMboga/WotBlitzStatisticsBlazor.git
synced 2026-10-21 10:27:18 +02:00
CLeanup and restructurisation
This commit is contained in:
1 parent
bfb9f11035
commit
8faccd45c9
104 files changed
+124
-2056
No files matched your search
@@ -0,0 +1,30 @@
|
||||
using System.Threading.Tasks;
|
||||
using WotBlitzStatisticsPro.Common.Model;
|
||||
using WotBlitzStatisticsPro.Logic;
|
||||
|
||||
namespace WotBlitzStatisticsPro.GraphQl.Mutation
|
||||
{
|
||||
/// <summary>
|
||||
/// WotBlitzStatistics Mutations
|
||||
/// </summary>
|
||||
public class WotBlitzStatisticsMutation
|
||||
{
|
||||
private readonly IWargamingDictionaries _wargamingDictionaries;
|
||||
|
||||
public WotBlitzStatisticsMutation(IWargamingDictionaries wargamingDictionaries)
|
||||
{
|
||||
_wargamingDictionaries = wargamingDictionaries;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Updates the necessary dictionaries in database.
|
||||
/// </summary>
|
||||
/// <param name="updateDictionariesRequest">Determines what dictionaries should be updated.</param>
|
||||
/// <returns>Information about what was updated.</returns>
|
||||
public Task<UpdateDictionariesResponseItem[]> UpdateDictionaries(
|
||||
UpdateDictionariesRequest updateDictionariesRequest)
|
||||
{
|
||||
return _wargamingDictionaries.UpdateDictionaries(updateDictionariesRequest);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
using HotChocolate.Types;
|
||||
using WotBlitzStatisticsPro.Common.Model;
|
||||
|
||||
namespace WotBlitzStatisticsPro.GraphQl.ObjectTypes
|
||||
{
|
||||
public class AccountsSearchItemObjectType: ObjectType<AccountsSearchResponseItem>
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
using HotChocolate.Types;
|
||||
using WotBlitzStatisticsPro.Common.Model;
|
||||
|
||||
namespace WotBlitzStatisticsPro.GraphQl.ObjectTypes
|
||||
{
|
||||
public class AccountsSearchObjectType: ObjectType<AccountsSearchResponse>
|
||||
{
|
||||
// ToDo: This is just for history. We don't need to paginate this because each page request does the request to API.
|
||||
// The database driver can optimize this and will request data page by page
|
||||
|
||||
//protected override void Configure(IObjectTypeDescriptor<AccountsSearchResponse> descriptor)
|
||||
//{
|
||||
// descriptor.Field(r => r.Accounts)
|
||||
// .UsePaging<AccountsSearchItemObjectType>();
|
||||
//}
|
||||
|
||||
/*
|
||||
Paging request example
|
||||
query($accountSearchNick: String!) {
|
||||
findAccounts(accountNick: $accountSearchNick) {
|
||||
accounts(first: 5, after: "eyJfX3RvdGFsQ291bnQiOjc0LCJfX3Bvc2l0aW9uIjo5fQ==") {
|
||||
pageInfo {
|
||||
hasNextPage
|
||||
hasPreviousPage
|
||||
startCursor
|
||||
endCursor
|
||||
}
|
||||
totalCount
|
||||
nodes {
|
||||
accountId
|
||||
nickname
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
|
||||
namespace WotBlitzStatisticsPro.GraphQl
|
||||
{
|
||||
public class Program
|
||||
{
|
||||
public static void Main(string[] args)
|
||||
{
|
||||
CreateHostBuilder(args).Build().Run();
|
||||
}
|
||||
|
||||
public static IHostBuilder CreateHostBuilder(string[] args) =>
|
||||
Host.CreateDefaultBuilder(args)
|
||||
.ConfigureWebHostDefaults(webBuilder =>
|
||||
{
|
||||
webBuilder.UseStartup<Startup>();
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
{
|
||||
"$schema": "http://json.schemastore.org/launchsettings.json",
|
||||
"iisSettings": {
|
||||
"windowsAuthentication": false,
|
||||
"anonymousAuthentication": true,
|
||||
"iisExpress": {
|
||||
"applicationUrl": "http://localhost:63522",
|
||||
"sslPort": 44333
|
||||
}
|
||||
},
|
||||
"profiles": {
|
||||
"IIS Express": {
|
||||
"commandName": "IISExpress",
|
||||
"launchBrowser": true,
|
||||
"launchUrl": "graphql/playground",
|
||||
"environmentVariables": {
|
||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||
}
|
||||
},
|
||||
"WotBlitzStatistics.GraphQl": {
|
||||
"commandName": "Project",
|
||||
"launchBrowser": true,
|
||||
"launchUrl": "graphql/playground",
|
||||
"applicationUrl": "https://localhost:5001;http://localhost:5000",
|
||||
"environmentVariables": {
|
||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
using System.Threading.Tasks;
|
||||
using WotBlitzStatisticsPro.Common.Model;
|
||||
using WotBlitzStatisticsPro.Logic;
|
||||
|
||||
namespace WotBlitzStatisticsPro.GraphQl.Query
|
||||
{
|
||||
public class WotBlitzStatisticsQuery
|
||||
{
|
||||
// 571050560 - mboga Eu
|
||||
// 90277267 - Mboga Ru
|
||||
|
||||
private readonly IWargamingSearch _wargamingSearcher;
|
||||
|
||||
public WotBlitzStatisticsQuery(IWargamingSearch wargamingSearcher)
|
||||
{
|
||||
_wargamingSearcher = wargamingSearcher;
|
||||
}
|
||||
|
||||
//public Task<AccountInfo> GetPlayerInfo(long accountId)
|
||||
//{
|
||||
// return _wargamingSearcher.GetPlayerAccountInfo(accountId);
|
||||
//}
|
||||
|
||||
/// <summary>
|
||||
/// Finds Wargaming accounts by nick
|
||||
/// </summary>
|
||||
/// <param name="accountNick">Search string.</param>
|
||||
/// <param name="realmType">Wargaming Realm.</param>
|
||||
/// <param name="language">Language for the output data.</param>
|
||||
/// <returns></returns>
|
||||
public Task<AccountsSearchResponse> FindAccounts(
|
||||
string accountNick,
|
||||
RealmType? realmType,
|
||||
RequestLanguage? language)
|
||||
{
|
||||
return _wargamingSearcher.FindAccounts(accountNick, realmType ?? RealmType.Ru, language ?? RequestLanguage.En);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Finds clans by search string
|
||||
/// </summary>
|
||||
/// <param name="searchString">Search string.</param>
|
||||
/// <param name="realmType">Wargaming Realm.</param>
|
||||
/// <param name="language">Language for the output data.</param>
|
||||
/// <returns></returns>
|
||||
public Task<ClanSearchResponse> FindClans(
|
||||
string searchString,
|
||||
RealmType? realmType,
|
||||
RequestLanguage? language)
|
||||
{
|
||||
return _wargamingSearcher.FindClans(searchString, realmType ?? RealmType.Ru, language ?? RequestLanguage.En);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,70 @@
|
||||
using HotChocolate;
|
||||
using HotChocolate.AspNetCore;
|
||||
using HotChocolate.AspNetCore.Voyager;
|
||||
using Microsoft.AspNetCore.Builder;
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using WotBlitzStatisticsPro.Common;
|
||||
using WotBlitzStatisticsPro.Common.Model;
|
||||
using WotBlitzStatisticsPro.GraphQl.Mutation;
|
||||
using WotBlitzStatisticsPro.GraphQl.ObjectTypes;
|
||||
using WotBlitzStatisticsPro.GraphQl.Query;
|
||||
using WotBlitzStatisticsPro.Logic;
|
||||
|
||||
namespace WotBlitzStatisticsPro.GraphQl
|
||||
{
|
||||
public class Startup
|
||||
{
|
||||
|
||||
public Startup(IConfiguration configuration)
|
||||
{
|
||||
Configuration = configuration;
|
||||
}
|
||||
|
||||
public IConfiguration Configuration { get; }
|
||||
|
||||
public void ConfigureServices(IServiceCollection services)
|
||||
{
|
||||
var wgApiConfig = new WargamingApiSettings();
|
||||
Configuration.GetSection("WargamingApi").Bind(wgApiConfig);
|
||||
|
||||
services.AddSingleton<IWargamingApiSettings>(wgApiConfig);
|
||||
WotBlitzStatisticsLogicInstaller.ConfigureServices(services);
|
||||
|
||||
// Global data loader - caches data between requests
|
||||
// ToDo: cause nullreference exception
|
||||
//services.AddSingleton<IDataLoaderRegistry, DataLoaderRegistry>();
|
||||
|
||||
// this enables you to use DataLoader in your resolvers.
|
||||
services.AddDataLoaderRegistry();
|
||||
|
||||
// Add GraphQL Services
|
||||
services.AddGraphQL(sp => SchemaBuilder.New()
|
||||
.AddServices(sp)
|
||||
|
||||
// Adds the authorize directive and
|
||||
// enable the authorization middleware.
|
||||
.AddAuthorizeDirectiveType()
|
||||
|
||||
.AddQueryType<WotBlitzStatisticsQuery>()
|
||||
.AddMutationType<WotBlitzStatisticsMutation>()
|
||||
//.AddSubscriptionType<SubscriptionType>()
|
||||
.AddType<AccountsSearchItemObjectType>()
|
||||
.AddType<AccountsSearchObjectType>()
|
||||
.AddEnumType<MarkOfMastery>()
|
||||
.AddEnumType<RealmType>()
|
||||
.AddEnumType<RequestLanguage>()
|
||||
.Create());
|
||||
}
|
||||
|
||||
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
|
||||
{
|
||||
app
|
||||
.UseGraphQL("/graphql")
|
||||
.UsePlayground("/graphql")
|
||||
.UseVoyager("/graphql")
|
||||
;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
using WotBlitzStatisticsPro.Common;
|
||||
|
||||
namespace WotBlitzStatisticsPro.GraphQl
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public class WargamingApiSettings : IWargamingApiSettings
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public string ApplicationId { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>netcoreapp3.1</TargetFramework>
|
||||
<GenerateDocumentationFile>true</GenerateDocumentationFile>
|
||||
<NoWarn>$(NoWarn);1591</NoWarn>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="HotChocolate.AspNetCore" Version="10.3.6" />
|
||||
<PackageReference Include="HotChocolate.AspNetCore.Abstractions" Version="10.3.6" />
|
||||
<PackageReference Include="HotChocolate.AspNetCore.Authorization" Version="10.3.6" />
|
||||
<PackageReference Include="HotChocolate.AspNetCore.Playground" Version="10.3.6" />
|
||||
<PackageReference Include="HotChocolate.AspNetCore.Voyager" Version="10.3.6" />
|
||||
<PackageReference Include="HotChocolate.Types.Filters" Version="10.3.6" />
|
||||
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\WotBlitzStatisticsPro.Common\WotBlitzStatisticsPro.Common.csproj" />
|
||||
<ProjectReference Include="..\WotBlitzStatisticsPro.Logic\WotBlitzStatisticsPro.Logic.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Folder Include="DataLoaders\" />
|
||||
<Folder Include="Resolvers\" />
|
||||
</ItemGroup>
|
||||
|
||||
|
||||
</Project>
|
||||
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"Logging": {
|
||||
"LogLevel": {
|
||||
"Default": "Information",
|
||||
"Microsoft": "Warning",
|
||||
"Microsoft.Hosting.Lifetime": "Information"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
{
|
||||
"Logging": {
|
||||
"LogLevel": {
|
||||
"Default": "Information",
|
||||
"Microsoft": "Warning",
|
||||
"Microsoft.Hosting.Lifetime": "Information"
|
||||
}
|
||||
},
|
||||
"AllowedHosts": "*",
|
||||
"WargamingApi": {
|
||||
"ApplicationId": "e6bb7a6cd1b7da3ca5697f97072d2176"
|
||||
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user