Web: Merge to one project, implement config GET/POST

This commit is contained in:
genteure 2022-04-03 14:47:54 +08:00
parent abd62dc378
commit f045ed4784
30 changed files with 238 additions and 193 deletions

View File

@ -1,22 +0,0 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="GraphQL.Server.Core" Version="5.0.2" />
<PackageReference Include="GraphQL.Server.Transports.AspNetCore.SystemTextJson" Version="5.0.2" />
<PackageReference Include="GraphQL.Server.Transports.Subscriptions.WebSockets" Version="5.0.2" />
<PackageReference Include="GraphQL.Server.Ui.Altair" Version="5.0.2" />
<PackageReference Include="GraphQL.Server.Ui.GraphiQL" Version="5.0.2" />
<PackageReference Include="GraphQL.Server.Ui.Playground" Version="5.0.2" />
<PackageReference Include="GraphQL.Server.Ui.Voyager" Version="5.0.2" />
<PackageReference Include="GraphQL.SystemReactive" Version="4.5.0" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\BililiveRecorder.Core\BililiveRecorder.Core.csproj" />
</ItemGroup>
</Project>

View File

@ -3,7 +3,7 @@ using AutoMapper;
using BililiveRecorder.Core; using BililiveRecorder.Core;
using BililiveRecorder.Core.Config.V2; using BililiveRecorder.Core.Config.V2;
using BililiveRecorder.Web.Models; using BililiveRecorder.Web.Models;
using BililiveRecorder.Web.Schemas.Types; using BililiveRecorder.Web.Models.Rest;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
namespace BililiveRecorder.Web.Api namespace BililiveRecorder.Web.Api

View File

@ -2,6 +2,7 @@ using AutoMapper;
using BililiveRecorder.Core; using BililiveRecorder.Core;
using BililiveRecorder.Core.Config.V2; using BililiveRecorder.Core.Config.V2;
using BililiveRecorder.Web.Models; using BililiveRecorder.Web.Models;
using BililiveRecorder.Web.Models.Rest;
namespace BililiveRecorder.Web.Api namespace BililiveRecorder.Web.Api
{ {

View File

@ -4,7 +4,7 @@ using System.Threading.Tasks;
using AutoMapper; using AutoMapper;
using BililiveRecorder.Core; using BililiveRecorder.Core;
using BililiveRecorder.Web.Models; using BililiveRecorder.Web.Models;
using BililiveRecorder.Web.Schemas.Types; using BililiveRecorder.Web.Models.Rest;
using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;

View File

@ -1,3 +1,4 @@
using BililiveRecorder.Web.Models;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
namespace BililiveRecorder.Web.Api namespace BililiveRecorder.Web.Api
@ -10,6 +11,6 @@ namespace BililiveRecorder.Web.Api
/// </summary> /// </summary>
/// <returns></returns> /// <returns></returns>
[HttpGet] [HttpGet]
public Schemas.Types.RecorderVersion GetVersion() => Schemas.Types.RecorderVersion.Instance; public RecorderVersion GetVersion() => RecorderVersion.Instance;
} }
} }

View File

@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk.Web"> <Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup> <PropertyGroup>
<TargetFramework>net5.0</TargetFramework> <TargetFramework>net6.0</TargetFramework>
<GenerateDocumentationFile>True</GenerateDocumentationFile> <GenerateDocumentationFile>True</GenerateDocumentationFile>
<NoWarn>1701;1702;1591</NoWarn> <NoWarn>1701;1702;1591</NoWarn>
</PropertyGroup> </PropertyGroup>
@ -9,12 +9,20 @@
<ItemGroup> <ItemGroup>
<PackageReference Include="AutoMapper" Version="11.0.1" /> <PackageReference Include="AutoMapper" Version="11.0.1" />
<PackageReference Include="AutoMapper.Extensions.Microsoft.DependencyInjection" Version="11.0.0" /> <PackageReference Include="AutoMapper.Extensions.Microsoft.DependencyInjection" Version="11.0.0" />
<PackageReference Include="GraphQL.Server.Core" Version="5.0.2" />
<PackageReference Include="GraphQL.Server.Transports.AspNetCore.NewtonsoftJson" Version="5.0.2" /> <PackageReference Include="GraphQL.Server.Transports.AspNetCore.NewtonsoftJson" Version="5.0.2" />
<PackageReference Include="GraphQL.Server.Transports.Subscriptions.WebSockets" Version="5.0.2" />
<PackageReference Include="GraphQL.Server.Ui.Altair" Version="5.0.2" />
<PackageReference Include="GraphQL.Server.Ui.GraphiQL" Version="5.0.2" />
<PackageReference Include="GraphQL.Server.Ui.Playground" Version="5.0.2" />
<PackageReference Include="GraphQL.Server.Ui.Voyager" Version="5.0.2" />
<PackageReference Include="GraphQL.SystemReactive" Version="4.5.0" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="6.0.3" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.3.0" /> <PackageReference Include="Swashbuckle.AspNetCore" Version="6.3.0" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\BililiveRecorder.Web.Schemas\BililiveRecorder.Web.Schemas.csproj" /> <ProjectReference Include="..\BililiveRecorder.Core\BililiveRecorder.Core.csproj" />
</ItemGroup> </ItemGroup>
</Project> </Project>

View File

@ -1,11 +1,12 @@
using System; using System;
using System.Linq; using System.Linq;
using BililiveRecorder.Core; using BililiveRecorder.Core;
using BililiveRecorder.Web.Schemas.Types; using BililiveRecorder.Web.Models;
using BililiveRecorder.Web.Models.Graphql;
using GraphQL; using GraphQL;
using GraphQL.Types; using GraphQL.Types;
namespace BililiveRecorder.Web.Schemas namespace BililiveRecorder.Web.Graphql
{ {
internal class RecorderMutation : ObjectGraphType internal class RecorderMutation : ObjectGraphType
{ {
@ -50,9 +51,7 @@ namespace BililiveRecorder.Web.Schemas
return null; return null;
} }
else else
{
return this.recorder.AddRoom(roomid, enabled); return this.recorder.AddRoom(roomid, enabled);
}
}); });
this.Field<RoomType>("removeRoom", this.Field<RoomType>("removeRoom",

View File

@ -2,11 +2,12 @@ using System;
using System.Linq; using System.Linq;
using BililiveRecorder.Core; using BililiveRecorder.Core;
using BililiveRecorder.Core.Config.V2; using BililiveRecorder.Core.Config.V2;
using BililiveRecorder.Web.Schemas.Types; using BililiveRecorder.Web.Models;
using BililiveRecorder.Web.Models.Graphql;
using GraphQL; using GraphQL;
using GraphQL.Types; using GraphQL.Types;
namespace BililiveRecorder.Web.Schemas namespace BililiveRecorder.Web.Graphql
{ {
internal class RecorderQuery : ObjectGraphType internal class RecorderQuery : ObjectGraphType
{ {

View File

@ -2,7 +2,7 @@ using System;
using BililiveRecorder.Core; using BililiveRecorder.Core;
using GraphQL.Types; using GraphQL.Types;
namespace BililiveRecorder.Web.Schemas namespace BililiveRecorder.Web.Graphql
{ {
public class RecorderSchema : Schema public class RecorderSchema : Schema
{ {

View File

@ -1,6 +1,6 @@
using GraphQL.Types; using GraphQL.Types;
namespace BililiveRecorder.Web.Schemas namespace BililiveRecorder.Web.Graphql
{ {
internal class RecorderSubscription : ObjectGraphType internal class RecorderSubscription : ObjectGraphType
{ {

View File

@ -7,7 +7,135 @@ using BililiveRecorder.Core.Config.V2;
using GraphQL.Types; using GraphQL.Types;
using HierarchicalPropertyDefault; using HierarchicalPropertyDefault;
#nullable enable #nullable enable
namespace BililiveRecorder.Web.Schemas.Types namespace BililiveRecorder.Web.Models
{
public class SetRoomConfig
{
public bool? AutoRecord { get; set; }
public Optional<RecordMode>? OptionalRecordMode { get; set; }
public Optional<CuttingMode>? OptionalCuttingMode { get; set; }
public Optional<uint>? OptionalCuttingNumber { get; set; }
public Optional<bool>? OptionalRecordDanmaku { get; set; }
public Optional<bool>? OptionalRecordDanmakuRaw { get; set; }
public Optional<bool>? OptionalRecordDanmakuSuperChat { get; set; }
public Optional<bool>? OptionalRecordDanmakuGift { get; set; }
public Optional<bool>? OptionalRecordDanmakuGuard { get; set; }
public Optional<string?>? OptionalRecordingQuality { get; set; }
public void ApplyTo(RoomConfig config)
{
if (this.AutoRecord.HasValue) config.AutoRecord = this.AutoRecord.Value;
if (this.OptionalRecordMode.HasValue) config.OptionalRecordMode = this.OptionalRecordMode.Value;
if (this.OptionalCuttingMode.HasValue) config.OptionalCuttingMode = this.OptionalCuttingMode.Value;
if (this.OptionalCuttingNumber.HasValue) config.OptionalCuttingNumber = this.OptionalCuttingNumber.Value;
if (this.OptionalRecordDanmaku.HasValue) config.OptionalRecordDanmaku = this.OptionalRecordDanmaku.Value;
if (this.OptionalRecordDanmakuRaw.HasValue) config.OptionalRecordDanmakuRaw = this.OptionalRecordDanmakuRaw.Value;
if (this.OptionalRecordDanmakuSuperChat.HasValue) config.OptionalRecordDanmakuSuperChat = this.OptionalRecordDanmakuSuperChat.Value;
if (this.OptionalRecordDanmakuGift.HasValue) config.OptionalRecordDanmakuGift = this.OptionalRecordDanmakuGift.Value;
if (this.OptionalRecordDanmakuGuard.HasValue) config.OptionalRecordDanmakuGuard = this.OptionalRecordDanmakuGuard.Value;
if (this.OptionalRecordingQuality.HasValue) config.OptionalRecordingQuality = this.OptionalRecordingQuality.Value;
}
}
public class SetGlobalConfig
{
public Optional<RecordMode>? OptionalRecordMode { get; set; }
public Optional<CuttingMode>? OptionalCuttingMode { get; set; }
public Optional<uint>? OptionalCuttingNumber { get; set; }
public Optional<bool>? OptionalRecordDanmaku { get; set; }
public Optional<bool>? OptionalRecordDanmakuRaw { get; set; }
public Optional<bool>? OptionalRecordDanmakuSuperChat { get; set; }
public Optional<bool>? OptionalRecordDanmakuGift { get; set; }
public Optional<bool>? OptionalRecordDanmakuGuard { get; set; }
public Optional<string?>? OptionalRecordingQuality { get; set; }
public Optional<string?>? OptionalRecordFilenameFormat { get; set; }
public Optional<string?>? OptionalWebHookUrls { get; set; }
public Optional<string?>? OptionalWebHookUrlsV2 { get; set; }
public Optional<bool>? OptionalWpfShowTitleAndArea { get; set; }
public Optional<string?>? OptionalCookie { get; set; }
public Optional<string?>? OptionalLiveApiHost { get; set; }
public Optional<uint>? OptionalTimingCheckInterval { get; set; }
public Optional<uint>? OptionalTimingStreamRetry { get; set; }
public Optional<uint>? OptionalTimingStreamRetryNoQn { get; set; }
public Optional<uint>? OptionalTimingStreamConnect { get; set; }
public Optional<uint>? OptionalTimingDanmakuRetry { get; set; }
public Optional<uint>? OptionalTimingWatchdogTimeout { get; set; }
public Optional<uint>? OptionalRecordDanmakuFlushInterval { get; set; }
public void ApplyTo(GlobalConfig config)
{
if (this.OptionalRecordMode.HasValue) config.OptionalRecordMode = this.OptionalRecordMode.Value;
if (this.OptionalCuttingMode.HasValue) config.OptionalCuttingMode = this.OptionalCuttingMode.Value;
if (this.OptionalCuttingNumber.HasValue) config.OptionalCuttingNumber = this.OptionalCuttingNumber.Value;
if (this.OptionalRecordDanmaku.HasValue) config.OptionalRecordDanmaku = this.OptionalRecordDanmaku.Value;
if (this.OptionalRecordDanmakuRaw.HasValue) config.OptionalRecordDanmakuRaw = this.OptionalRecordDanmakuRaw.Value;
if (this.OptionalRecordDanmakuSuperChat.HasValue) config.OptionalRecordDanmakuSuperChat = this.OptionalRecordDanmakuSuperChat.Value;
if (this.OptionalRecordDanmakuGift.HasValue) config.OptionalRecordDanmakuGift = this.OptionalRecordDanmakuGift.Value;
if (this.OptionalRecordDanmakuGuard.HasValue) config.OptionalRecordDanmakuGuard = this.OptionalRecordDanmakuGuard.Value;
if (this.OptionalRecordingQuality.HasValue) config.OptionalRecordingQuality = this.OptionalRecordingQuality.Value;
if (this.OptionalRecordFilenameFormat.HasValue) config.OptionalRecordFilenameFormat = this.OptionalRecordFilenameFormat.Value;
if (this.OptionalWebHookUrls.HasValue) config.OptionalWebHookUrls = this.OptionalWebHookUrls.Value;
if (this.OptionalWebHookUrlsV2.HasValue) config.OptionalWebHookUrlsV2 = this.OptionalWebHookUrlsV2.Value;
if (this.OptionalWpfShowTitleAndArea.HasValue) config.OptionalWpfShowTitleAndArea = this.OptionalWpfShowTitleAndArea.Value;
if (this.OptionalCookie.HasValue) config.OptionalCookie = this.OptionalCookie.Value;
if (this.OptionalLiveApiHost.HasValue) config.OptionalLiveApiHost = this.OptionalLiveApiHost.Value;
if (this.OptionalTimingCheckInterval.HasValue) config.OptionalTimingCheckInterval = this.OptionalTimingCheckInterval.Value;
if (this.OptionalTimingStreamRetry.HasValue) config.OptionalTimingStreamRetry = this.OptionalTimingStreamRetry.Value;
if (this.OptionalTimingStreamRetryNoQn.HasValue) config.OptionalTimingStreamRetryNoQn = this.OptionalTimingStreamRetryNoQn.Value;
if (this.OptionalTimingStreamConnect.HasValue) config.OptionalTimingStreamConnect = this.OptionalTimingStreamConnect.Value;
if (this.OptionalTimingDanmakuRetry.HasValue) config.OptionalTimingDanmakuRetry = this.OptionalTimingDanmakuRetry.Value;
if (this.OptionalTimingWatchdogTimeout.HasValue) config.OptionalTimingWatchdogTimeout = this.OptionalTimingWatchdogTimeout.Value;
if (this.OptionalRecordDanmakuFlushInterval.HasValue) config.OptionalRecordDanmakuFlushInterval = this.OptionalRecordDanmakuFlushInterval.Value;
}
}
}
namespace BililiveRecorder.Web.Models.Rest
{
public class RoomConfigDto
{
public bool AutoRecord { get; set; }
public Optional<RecordMode> OptionalRecordMode { get; set; }
public Optional<CuttingMode> OptionalCuttingMode { get; set; }
public Optional<uint> OptionalCuttingNumber { get; set; }
public Optional<bool> OptionalRecordDanmaku { get; set; }
public Optional<bool> OptionalRecordDanmakuRaw { get; set; }
public Optional<bool> OptionalRecordDanmakuSuperChat { get; set; }
public Optional<bool> OptionalRecordDanmakuGift { get; set; }
public Optional<bool> OptionalRecordDanmakuGuard { get; set; }
public Optional<string?> OptionalRecordingQuality { get; set; }
}
public class GlobalConfigDto
{
public Optional<RecordMode> OptionalRecordMode { get; set; }
public Optional<CuttingMode> OptionalCuttingMode { get; set; }
public Optional<uint> OptionalCuttingNumber { get; set; }
public Optional<bool> OptionalRecordDanmaku { get; set; }
public Optional<bool> OptionalRecordDanmakuRaw { get; set; }
public Optional<bool> OptionalRecordDanmakuSuperChat { get; set; }
public Optional<bool> OptionalRecordDanmakuGift { get; set; }
public Optional<bool> OptionalRecordDanmakuGuard { get; set; }
public Optional<string?> OptionalRecordingQuality { get; set; }
public Optional<string?> OptionalRecordFilenameFormat { get; set; }
public Optional<string?> OptionalWebHookUrls { get; set; }
public Optional<string?> OptionalWebHookUrlsV2 { get; set; }
public Optional<bool> OptionalWpfShowTitleAndArea { get; set; }
public Optional<string?> OptionalCookie { get; set; }
public Optional<string?> OptionalLiveApiHost { get; set; }
public Optional<uint> OptionalTimingCheckInterval { get; set; }
public Optional<uint> OptionalTimingStreamRetry { get; set; }
public Optional<uint> OptionalTimingStreamRetryNoQn { get; set; }
public Optional<uint> OptionalTimingStreamConnect { get; set; }
public Optional<uint> OptionalTimingDanmakuRetry { get; set; }
public Optional<uint> OptionalTimingWatchdogTimeout { get; set; }
public Optional<uint> OptionalRecordDanmakuFlushInterval { get; set; }
}
}
namespace BililiveRecorder.Web.Models.Graphql
{ {
internal class RoomConfigType : ObjectGraphType<RoomConfig> internal class RoomConfigType : ObjectGraphType<RoomConfig>
{ {
@ -85,34 +213,6 @@ namespace BililiveRecorder.Web.Schemas.Types
} }
} }
public class SetRoomConfig // TODO MOVE THIS TYPE
{
public bool? AutoRecord { get; set; }
public Optional<RecordMode>? OptionalRecordMode { get; set; }
public Optional<CuttingMode>? OptionalCuttingMode { get; set; }
public Optional<uint>? OptionalCuttingNumber { get; set; }
public Optional<bool>? OptionalRecordDanmaku { get; set; }
public Optional<bool>? OptionalRecordDanmakuRaw { get; set; }
public Optional<bool>? OptionalRecordDanmakuSuperChat { get; set; }
public Optional<bool>? OptionalRecordDanmakuGift { get; set; }
public Optional<bool>? OptionalRecordDanmakuGuard { get; set; }
public Optional<string?>? OptionalRecordingQuality { get; set; }
public void ApplyTo(RoomConfig config)
{
if (this.AutoRecord.HasValue) config.AutoRecord = this.AutoRecord.Value;
if (this.OptionalRecordMode.HasValue) config.OptionalRecordMode = this.OptionalRecordMode.Value;
if (this.OptionalCuttingMode.HasValue) config.OptionalCuttingMode = this.OptionalCuttingMode.Value;
if (this.OptionalCuttingNumber.HasValue) config.OptionalCuttingNumber = this.OptionalCuttingNumber.Value;
if (this.OptionalRecordDanmaku.HasValue) config.OptionalRecordDanmaku = this.OptionalRecordDanmaku.Value;
if (this.OptionalRecordDanmakuRaw.HasValue) config.OptionalRecordDanmakuRaw = this.OptionalRecordDanmakuRaw.Value;
if (this.OptionalRecordDanmakuSuperChat.HasValue) config.OptionalRecordDanmakuSuperChat = this.OptionalRecordDanmakuSuperChat.Value;
if (this.OptionalRecordDanmakuGift.HasValue) config.OptionalRecordDanmakuGift = this.OptionalRecordDanmakuGift.Value;
if (this.OptionalRecordDanmakuGuard.HasValue) config.OptionalRecordDanmakuGuard = this.OptionalRecordDanmakuGuard.Value;
if (this.OptionalRecordingQuality.HasValue) config.OptionalRecordingQuality = this.OptionalRecordingQuality.Value;
}
}
internal class SetRoomConfigType : InputObjectGraphType<SetRoomConfig> internal class SetRoomConfigType : InputObjectGraphType<SetRoomConfig>
{ {
public SetRoomConfigType() public SetRoomConfigType()
@ -130,58 +230,6 @@ namespace BililiveRecorder.Web.Schemas.Types
} }
} }
public class SetGlobalConfig // TODO MOVE THIS TYPE
{
public Optional<RecordMode>? OptionalRecordMode { get; set; }
public Optional<CuttingMode>? OptionalCuttingMode { get; set; }
public Optional<uint>? OptionalCuttingNumber { get; set; }
public Optional<bool>? OptionalRecordDanmaku { get; set; }
public Optional<bool>? OptionalRecordDanmakuRaw { get; set; }
public Optional<bool>? OptionalRecordDanmakuSuperChat { get; set; }
public Optional<bool>? OptionalRecordDanmakuGift { get; set; }
public Optional<bool>? OptionalRecordDanmakuGuard { get; set; }
public Optional<string?>? OptionalRecordingQuality { get; set; }
public Optional<string?>? OptionalRecordFilenameFormat { get; set; }
public Optional<string?>? OptionalWebHookUrls { get; set; }
public Optional<string?>? OptionalWebHookUrlsV2 { get; set; }
public Optional<bool>? OptionalWpfShowTitleAndArea { get; set; }
public Optional<string?>? OptionalCookie { get; set; }
public Optional<string?>? OptionalLiveApiHost { get; set; }
public Optional<uint>? OptionalTimingCheckInterval { get; set; }
public Optional<uint>? OptionalTimingStreamRetry { get; set; }
public Optional<uint>? OptionalTimingStreamRetryNoQn { get; set; }
public Optional<uint>? OptionalTimingStreamConnect { get; set; }
public Optional<uint>? OptionalTimingDanmakuRetry { get; set; }
public Optional<uint>? OptionalTimingWatchdogTimeout { get; set; }
public Optional<uint>? OptionalRecordDanmakuFlushInterval { get; set; }
public void ApplyTo(GlobalConfig config)
{
if (this.OptionalRecordMode.HasValue) config.OptionalRecordMode = this.OptionalRecordMode.Value;
if (this.OptionalCuttingMode.HasValue) config.OptionalCuttingMode = this.OptionalCuttingMode.Value;
if (this.OptionalCuttingNumber.HasValue) config.OptionalCuttingNumber = this.OptionalCuttingNumber.Value;
if (this.OptionalRecordDanmaku.HasValue) config.OptionalRecordDanmaku = this.OptionalRecordDanmaku.Value;
if (this.OptionalRecordDanmakuRaw.HasValue) config.OptionalRecordDanmakuRaw = this.OptionalRecordDanmakuRaw.Value;
if (this.OptionalRecordDanmakuSuperChat.HasValue) config.OptionalRecordDanmakuSuperChat = this.OptionalRecordDanmakuSuperChat.Value;
if (this.OptionalRecordDanmakuGift.HasValue) config.OptionalRecordDanmakuGift = this.OptionalRecordDanmakuGift.Value;
if (this.OptionalRecordDanmakuGuard.HasValue) config.OptionalRecordDanmakuGuard = this.OptionalRecordDanmakuGuard.Value;
if (this.OptionalRecordingQuality.HasValue) config.OptionalRecordingQuality = this.OptionalRecordingQuality.Value;
if (this.OptionalRecordFilenameFormat.HasValue) config.OptionalRecordFilenameFormat = this.OptionalRecordFilenameFormat.Value;
if (this.OptionalWebHookUrls.HasValue) config.OptionalWebHookUrls = this.OptionalWebHookUrls.Value;
if (this.OptionalWebHookUrlsV2.HasValue) config.OptionalWebHookUrlsV2 = this.OptionalWebHookUrlsV2.Value;
if (this.OptionalWpfShowTitleAndArea.HasValue) config.OptionalWpfShowTitleAndArea = this.OptionalWpfShowTitleAndArea.Value;
if (this.OptionalCookie.HasValue) config.OptionalCookie = this.OptionalCookie.Value;
if (this.OptionalLiveApiHost.HasValue) config.OptionalLiveApiHost = this.OptionalLiveApiHost.Value;
if (this.OptionalTimingCheckInterval.HasValue) config.OptionalTimingCheckInterval = this.OptionalTimingCheckInterval.Value;
if (this.OptionalTimingStreamRetry.HasValue) config.OptionalTimingStreamRetry = this.OptionalTimingStreamRetry.Value;
if (this.OptionalTimingStreamRetryNoQn.HasValue) config.OptionalTimingStreamRetryNoQn = this.OptionalTimingStreamRetryNoQn.Value;
if (this.OptionalTimingStreamConnect.HasValue) config.OptionalTimingStreamConnect = this.OptionalTimingStreamConnect.Value;
if (this.OptionalTimingDanmakuRetry.HasValue) config.OptionalTimingDanmakuRetry = this.OptionalTimingDanmakuRetry.Value;
if (this.OptionalTimingWatchdogTimeout.HasValue) config.OptionalTimingWatchdogTimeout = this.OptionalTimingWatchdogTimeout.Value;
if (this.OptionalRecordDanmakuFlushInterval.HasValue) config.OptionalRecordDanmakuFlushInterval = this.OptionalRecordDanmakuFlushInterval.Value;
}
}
internal class SetGlobalConfigType : InputObjectGraphType<SetGlobalConfig> internal class SetGlobalConfigType : InputObjectGraphType<SetGlobalConfig>
{ {
public SetGlobalConfigType() public SetGlobalConfigType()

View File

@ -1,13 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BililiveRecorder.Web.Models
{
public class GlobalConfigDto
{
}
}

View File

@ -1,7 +1,7 @@
using BililiveRecorder.Core.Config.V2; using BililiveRecorder.Core.Config.V2;
using GraphQL.Types; using GraphQL.Types;
namespace BililiveRecorder.Web.Schemas.Types namespace BililiveRecorder.Web.Models.Graphql
{ {
public class CuttingModeEnum : EnumerationGraphType<CuttingMode> public class CuttingModeEnum : EnumerationGraphType<CuttingMode>
{ {

View File

@ -1,7 +1,7 @@
using GraphQL.Types; using GraphQL.Types;
using HierarchicalPropertyDefault; using HierarchicalPropertyDefault;
namespace BililiveRecorder.Web.Schemas.Types namespace BililiveRecorder.Web.Models.Graphql
{ {
public class HierarchicalOptionalInputType<TValue> : InputObjectGraphType<Optional<TValue>> public class HierarchicalOptionalInputType<TValue> : InputObjectGraphType<Optional<TValue>>
{ {

View File

@ -1,7 +1,7 @@
using GraphQL.Types; using GraphQL.Types;
using HierarchicalPropertyDefault; using HierarchicalPropertyDefault;
namespace BililiveRecorder.Web.Schemas.Types namespace BililiveRecorder.Web.Models.Graphql
{ {
public class HierarchicalOptionalType<TValue> : ObjectGraphType<Optional<TValue>> public class HierarchicalOptionalType<TValue> : ObjectGraphType<Optional<TValue>>
{ {

View File

@ -1,7 +1,7 @@
using BililiveRecorder.Core.Config.V2; using BililiveRecorder.Core.Config.V2;
using GraphQL.Types; using GraphQL.Types;
namespace BililiveRecorder.Web.Schemas.Types namespace BililiveRecorder.Web.Models.Graphql
{ {
public class RecordModeEnum : EnumerationGraphType<RecordMode> public class RecordModeEnum : EnumerationGraphType<RecordMode>
{ {

View File

@ -1,6 +1,6 @@
using GraphQL.Types; using GraphQL.Types;
namespace BililiveRecorder.Web.Schemas.Types namespace BililiveRecorder.Web.Models.Graphql
{ {
public class RecorderVersionType : ObjectGraphType<RecorderVersion> public class RecorderVersionType : ObjectGraphType<RecorderVersion>
{ {

View File

@ -1,7 +1,7 @@
using BililiveRecorder.Core; using BililiveRecorder.Core;
using GraphQL.Types; using GraphQL.Types;
namespace BililiveRecorder.Web.Schemas.Types namespace BililiveRecorder.Web.Models.Graphql
{ {
public class RecordingStatsType : ObjectGraphType<RecordingStats> public class RecordingStatsType : ObjectGraphType<RecordingStats>
{ {

View File

@ -1,7 +1,7 @@
using BililiveRecorder.Core; using BililiveRecorder.Core;
using GraphQL.Types; using GraphQL.Types;
namespace BililiveRecorder.Web.Schemas.Types namespace BililiveRecorder.Web.Models.Graphql
{ {
internal class RoomType : ObjectGraphType<IRoom> internal class RoomType : ObjectGraphType<IRoom>
{ {

View File

@ -1,4 +1,4 @@
namespace BililiveRecorder.Web.Schemas.Types namespace BililiveRecorder.Web.Models
{ {
public class RecorderVersion public class RecorderVersion
{ {

View File

@ -1,4 +1,4 @@
namespace BililiveRecorder.Web.Models namespace BililiveRecorder.Web.Models.Rest
{ {
public class CreateRoomDto public class CreateRoomDto
{ {

View File

@ -1,4 +1,4 @@
namespace BililiveRecorder.Web.Models namespace BililiveRecorder.Web.Models.Rest
{ {
public class RestApiError public class RestApiError
{ {

View File

@ -1,6 +1,6 @@
using System.Text.Json.Serialization; using System.Text.Json.Serialization;
namespace BililiveRecorder.Web.Models namespace BililiveRecorder.Web.Models.Rest
{ {
[JsonConverter(typeof(JsonStringEnumConverter))] [JsonConverter(typeof(JsonStringEnumConverter))]
public enum RestApiErrorCode public enum RestApiErrorCode

View File

@ -1,6 +1,6 @@
using System; using System;
namespace BililiveRecorder.Web.Models namespace BililiveRecorder.Web.Models.Rest
{ {
public class RoomDto public class RoomDto
{ {

View File

@ -1,6 +1,6 @@
using System; using System;
namespace BililiveRecorder.Web.Models namespace BililiveRecorder.Web.Models.Rest
{ {
public class RoomStatsDto public class RoomStatsDto
{ {

View File

@ -1,7 +0,0 @@
namespace BililiveRecorder.Web.Models
{
public class RoomConfigDto
{
// TODO auto generate this
}
}

View File

@ -3,7 +3,7 @@ using System.Diagnostics;
using System.IO; using System.IO;
using BililiveRecorder.Core; using BililiveRecorder.Core;
using BililiveRecorder.Web.Api; using BililiveRecorder.Web.Api;
using BililiveRecorder.Web.Schemas; using BililiveRecorder.Web.Graphql;
using GraphQL; using GraphQL;
using GraphQL.Server; using GraphQL.Server;
using GraphQL.Types; using GraphQL.Types;
@ -89,7 +89,8 @@ namespace BililiveRecorder.Web
{ {
}) })
.AddApiExplorer(); .AddApiExplorer()
.AddNewtonsoftJson();
} }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.

View File

@ -29,9 +29,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BililiveRecorder.ToolBox",
EndProject EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BililiveRecorder.Flv.Tests", "test\BililiveRecorder.Flv.Tests\BililiveRecorder.Flv.Tests.csproj", "{32E554B1-0ECC-4145-85B8-3FC128FEBEA1}" Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BililiveRecorder.Flv.Tests", "test\BililiveRecorder.Flv.Tests\BililiveRecorder.Flv.Tests.csproj", "{32E554B1-0ECC-4145-85B8-3FC128FEBEA1}"
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BililiveRecorder.Web", "BililiveRecorder.Web\BililiveRecorder.Web.csproj", "{263EC584-AFD5-45C9-8347-127016B3B8F5}" Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BililiveRecorder.Web", "BililiveRecorder.Web\BililiveRecorder.Web.csproj", "{263EC584-AFD5-45C9-8347-127016B3B8F5}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BililiveRecorder.Web.Schemas", "BililiveRecorder.Web.Schemas\BililiveRecorder.Web.Schemas.csproj", "{4E72646D-8E25-49E5-B72C-E9749141DBF4}"
EndProject EndProject
Global Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution GlobalSection(SolutionConfigurationPlatforms) = preSolution
@ -71,10 +69,6 @@ Global
{263EC584-AFD5-45C9-8347-127016B3B8F5}.Debug|Any CPU.Build.0 = Debug|Any CPU {263EC584-AFD5-45C9-8347-127016B3B8F5}.Debug|Any CPU.Build.0 = Debug|Any CPU
{263EC584-AFD5-45C9-8347-127016B3B8F5}.Release|Any CPU.ActiveCfg = Release|Any CPU {263EC584-AFD5-45C9-8347-127016B3B8F5}.Release|Any CPU.ActiveCfg = Release|Any CPU
{263EC584-AFD5-45C9-8347-127016B3B8F5}.Release|Any CPU.Build.0 = Release|Any CPU {263EC584-AFD5-45C9-8347-127016B3B8F5}.Release|Any CPU.Build.0 = Release|Any CPU
{4E72646D-8E25-49E5-B72C-E9749141DBF4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{4E72646D-8E25-49E5-B72C-E9749141DBF4}.Debug|Any CPU.Build.0 = Debug|Any CPU
{4E72646D-8E25-49E5-B72C-E9749141DBF4}.Release|Any CPU.ActiveCfg = Release|Any CPU
{4E72646D-8E25-49E5-B72C-E9749141DBF4}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection EndGlobalSection
GlobalSection(SolutionProperties) = preSolution GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE HideSolutionNode = FALSE
@ -88,13 +82,12 @@ Global
{4FAAE8E7-AC4E-4E99-A7D1-53D20AD8A200} = {2D44A59D-E437-4FEE-8A2E-3FF00D53A64D} {4FAAE8E7-AC4E-4E99-A7D1-53D20AD8A200} = {2D44A59D-E437-4FEE-8A2E-3FF00D53A64D}
{32E554B1-0ECC-4145-85B8-3FC128FEBEA1} = {623A2ACC-DAC6-4E6F-9242-B4B54381AAE1} {32E554B1-0ECC-4145-85B8-3FC128FEBEA1} = {623A2ACC-DAC6-4E6F-9242-B4B54381AAE1}
{263EC584-AFD5-45C9-8347-127016B3B8F5} = {2D44A59D-E437-4FEE-8A2E-3FF00D53A64D} {263EC584-AFD5-45C9-8347-127016B3B8F5} = {2D44A59D-E437-4FEE-8A2E-3FF00D53A64D}
{4E72646D-8E25-49E5-B72C-E9749141DBF4} = {2D44A59D-E437-4FEE-8A2E-3FF00D53A64D}
EndGlobalSection EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution GlobalSection(ExtensibilityGlobals) = postSolution
RESX_ShowErrorsInErrorList = False
RESX_SaveFilesImmediatelyUponChange = True
RESX_NeutralResourcesLanguage = zh-Hans
SolutionGuid = {F3CB8B14-077A-458F-BD8E-1747ED0F5170}
RESX_SortFileContentOnSave = True RESX_SortFileContentOnSave = True
SolutionGuid = {F3CB8B14-077A-458F-BD8E-1747ED0F5170}
RESX_NeutralResourcesLanguage = zh-Hans
RESX_SaveFilesImmediatelyUponChange = True
RESX_ShowErrorsInErrorList = False
EndGlobalSection EndGlobalSection
EndGlobal EndGlobal

View File

@ -34,7 +34,7 @@ const map: SectionInfoMap = {
build: builderCli build: builderCli
}, },
web: { web: {
path: './BililiveRecorder.Web.Schemas/Types/Config.gen.cs', path: './BililiveRecorder.Web/Models/Config.gen.cs',
format: true, format: true,
header: true, header: true,
build: builderWeb build: builderWeb

View File

@ -6,8 +6,6 @@ export default function (data: ConfigEntry[]): string {
using GraphQL.Types; using GraphQL.Types;
using HierarchicalPropertyDefault; using HierarchicalPropertyDefault;
#nullable enable #nullable enable
namespace BililiveRecorder.Web.Schemas.Types
{
`; `;
function write_query_graphType_property(r: ConfigEntry) { function write_query_graphType_property(r: ConfigEntry) {
if (r.configType == "roomOnly") { if (r.configType == "roomOnly") {
@ -17,6 +15,14 @@ namespace BililiveRecorder.Web.Schemas.Types
} }
} }
function write_rest_dto_property(r: ConfigEntry) {
if (r.configType == "roomOnly") {
result += `public ${r.type} ${r.name} { get; set; }\n`;
} else {
result += `public Optional<${r.type}> Optional${r.name} { get; set; }\n`;
}
}
function write_mutation_graphType_property(r: ConfigEntry) { function write_mutation_graphType_property(r: ConfigEntry) {
if (r.configType == "roomOnly") { if (r.configType == "roomOnly") {
result += `this.Field(x => x.${r.name}, nullable: true);\n`; result += `this.Field(x => x.${r.name}, nullable: true);\n`;
@ -41,6 +47,62 @@ namespace BililiveRecorder.Web.Schemas.Types
} }
} }
// +++++++++++++++++ Shared +++++++++++++++++
result += 'namespace BililiveRecorder.Web.Models\n{\n'
{ // ====== SetRoomConfig ======
result += "public class SetRoomConfig\n{\n"
data.filter(x => x.configType != "globalOnly" && !x.webReadonly)
.forEach(r => write_mutation_dataType_property(r));
result += "\npublic void ApplyTo(RoomConfig config)\n{\n";
data.filter(x => x.configType != "globalOnly" && !x.webReadonly)
.forEach(r => write_mutation_apply_method(r));
result += "}\n}\n\n";
}
{ // ====== SetGlobalConfig ======
result += "public class SetGlobalConfig\n{\n"
data.filter(r => r.configType != "roomOnly" && !r.webReadonly)
.forEach(r => write_mutation_dataType_property(r));
result += "\npublic void ApplyTo(GlobalConfig config)\n{\n";
data.filter(r => r.configType != "roomOnly" && !r.webReadonly)
.forEach(r => write_mutation_apply_method(r));
result += "}\n}\n\n";
}
// +++++++++++++++++ REST +++++++++++++++++
result += '}\n\nnamespace BililiveRecorder.Web.Models.Rest\n{\n'
{ // ====== RoomConfigDto ======
result += "public class RoomConfigDto\n{\n"
data.filter(x => x.configType != "globalOnly" && !x.webReadonly)
.forEach(r => write_rest_dto_property(r));
result += "}\n\n";
}
{ // ====== GlobalConfigDto ======
result += "public class GlobalConfigDto\n{\n"
data.filter(r => r.configType != "roomOnly" && !r.webReadonly)
.forEach(r => write_rest_dto_property(r));
result += "}\n\n";
}
// +++++++++++++++++ Graphql +++++++++++++++++
result += '}\n\nnamespace BililiveRecorder.Web.Models.Graphql\n{\n'
{ // ====== RoomConfigType ====== { // ====== RoomConfigType ======
result += "internal class RoomConfigType : ObjectGraphType<RoomConfig>\n{\n"; result += "internal class RoomConfigType : ObjectGraphType<RoomConfig>\n{\n";
result += "public RoomConfigType()\n{\n" result += "public RoomConfigType()\n{\n"
@ -72,20 +134,6 @@ namespace BililiveRecorder.Web.Schemas.Types
result += "}\n}\n\n"; result += "}\n}\n\n";
} }
{ // ====== SetRoomConfig ======
result += "internal class SetRoomConfig\n{\n"
data.filter(x => x.configType != "globalOnly" && !x.webReadonly)
.forEach(r => write_mutation_dataType_property(r));
result += "\npublic void ApplyTo(RoomConfig config)\n{\n";
data.filter(x => x.configType != "globalOnly" && !x.webReadonly)
.forEach(r => write_mutation_apply_method(r));
result += "}\n}\n\n";
}
{ // ====== SetRoomConfigType ====== { // ====== SetRoomConfigType ======
result += "internal class SetRoomConfigType : InputObjectGraphType<SetRoomConfig>\n{\n" result += "internal class SetRoomConfigType : InputObjectGraphType<SetRoomConfig>\n{\n"
result += "public SetRoomConfigType()\n{\n"; result += "public SetRoomConfigType()\n{\n";
@ -96,19 +144,6 @@ namespace BililiveRecorder.Web.Schemas.Types
result += "}\n}\n\n"; result += "}\n}\n\n";
} }
{ // ====== SetGlobalConfig ======
result += "internal class SetGlobalConfig\n{\n"
data.filter(r => r.configType != "roomOnly" && !r.webReadonly)
.forEach(r => write_mutation_dataType_property(r));
result += "\npublic void ApplyTo(GlobalConfig config)\n{\n";
data.filter(r => r.configType != "roomOnly" && !r.webReadonly)
.forEach(r => write_mutation_apply_method(r));
result += "}\n}\n\n";
}
{ // ====== SetGlobalConfigType ====== { // ====== SetGlobalConfigType ======
result += "internal class SetGlobalConfigType : InputObjectGraphType<SetGlobalConfig>\n{\n" result += "internal class SetGlobalConfigType : InputObjectGraphType<SetGlobalConfig>\n{\n"