Skip to content

Commit f5b1cae

Browse files
authored
Merge pull request #6 from pk9r/dev
Add Redis and PostgreSQL support, new Discord entity
2 parents 7eb0142 + db8dea9 commit f5b1cae

16 files changed

Lines changed: 283 additions & 56 deletions

Directory.Packages.props

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
</PropertyGroup>
55
<ItemGroup>
66
<PackageVersion Include="Aspire.Hosting.AppHost" Version="9.4.0" />
7+
<PackageVersion Include="Aspire.Hosting.PostgreSQL" Version="9.4.0" />
8+
<PackageVersion Include="Aspire.Hosting.Redis" Version="9.4.0" />
79
<PackageVersion Include="Aspire.Npgsql.EntityFrameworkCore.PostgreSQL" Version="9.4.0" />
810
<PackageVersion Include="Aspire.StackExchange.Redis.DistributedCaching" Version="9.4.0" />
911
<PackageVersion Include="Microsoft.EntityFrameworkCore.Design" Version="9.0.8" />

GitcgNetCord.sln.DotSettings

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
22
<s:Boolean x:Key="/Default/UserDictionary/Words/=genshin/@EntryIndexedValue">True</s:Boolean>
3+
<s:Boolean x:Key="/Default/UserDictionary/Words/=genshincards/@EntryIndexedValue">True</s:Boolean>
34
<s:Boolean x:Key="/Default/UserDictionary/Words/=gitcg/@EntryIndexedValue">True</s:Boolean>
45
<s:Boolean x:Key="/Default/UserDictionary/Words/=gitcgvn/@EntryIndexedValue">True</s:Boolean>
56
<s:Boolean x:Key="/Default/UserDictionary/Words/=hoyolab/@EntryIndexedValue">True</s:Boolean></wpf:ResourceDictionary>

GitcgNetCord.sln.DotSettings.user

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
11
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
2-
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AEmojiProperties_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003FAppData_003FRoaming_003FJetBrains_003FRider2025_002E1_003Fresharper_002Dhost_003FSourcesCache_003F6ab3be37dec913ef7d649338adbdc7ba6ecf9e17ad69af5d293b71d60e4be5a_003FEmojiProperties_002Ecs/@EntryIndexedValue">ForceIncluded</s:String></wpf:ResourceDictionary>
2+
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AEmojiProperties_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003FAppData_003FRoaming_003FJetBrains_003FRider2025_002E1_003Fresharper_002Dhost_003FSourcesCache_003F6ab3be37dec913ef7d649338adbdc7ba6ecf9e17ad69af5d293b71d60e4be5a_003FEmojiProperties_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
3+
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AReactionEmojiProperties_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003FAppData_003FRoaming_003FJetBrains_003FRider2025_002E1_003Fresharper_002Dhost_003FSourcesCache_003Ffa944ea7b9c605f0445098be8ca0ce31dd212e446a97d32b344db96e36aa95_003FReactionEmojiProperties_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
4+
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003ASlashCommandChoiceAttribute_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003FAppData_003FRoaming_003FJetBrains_003FRider2025_002E1_003Fresharper_002Dhost_003FSourcesCache_003F70977d8e8e415d5c5286c84b973d39d27dd1744ed6edc99adee5b82899ff31_003FSlashCommandChoiceAttribute_002Ecs/@EntryIndexedValue">ForceIncluded</s:String></wpf:ResourceDictionary>

script.sql

Lines changed: 0 additions & 40 deletions
This file was deleted.

src/AppHost/AppHost.cs

Lines changed: 37 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,42 @@
1-
using Aspire.Hosting;
1+
using Microsoft.Extensions.Configuration;
22
using Projects;
33

44
var builder = DistributedApplication.CreateBuilder(args);
55

6-
builder.AddProject<GitcgNetCord_MainApp>("main");
6+
var redis = builder.AddRedis("redis")
7+
.WithDataVolume();
78

8-
builder.Build().Run();
9+
var main = builder.AddProject<GitcgNetCord_MainApp>("main");
10+
11+
main.WithReference(redis).WaitFor(redis);
12+
13+
var useRemotePostgres = builder.Configuration
14+
.GetValue<bool>("AppBuilderOptions:UseRemotePostgres");
15+
16+
if (useRemotePostgres)
17+
{
18+
var postgresConnectionString = builder
19+
.AddConnectionString("gitcgnetcorddb");
20+
21+
main.WithReference(postgresConnectionString);
22+
}
23+
else
24+
{
25+
var postgresPassword = builder.AddParameter(
26+
name: "postgresql-password",
27+
value: "PGPASSWORD"
28+
);
29+
30+
var postgres = builder.AddPostgres(
31+
name: "postgresql",
32+
password: postgresPassword
33+
);
34+
35+
postgres
36+
.WithDataVolume()
37+
.WithPgAdmin();
38+
39+
main.WithReference(postgres).WaitFor(postgres);
40+
}
41+
42+
builder.Build().Run();

src/AppHost/AppHost.csproj

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212

1313
<ItemGroup>
1414
<PackageReference Include="Aspire.Hosting.AppHost" />
15+
<PackageReference Include="Aspire.Hosting.PostgreSQL" />
16+
<PackageReference Include="Aspire.Hosting.Redis" />
1517
</ItemGroup>
1618

1719
<ItemGroup>

src/AppHost/appsettings.Development.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
{
2+
"AppBuilderOptions": {
3+
"UseRemotePostgres": false
4+
},
25
"Logging": {
36
"LogLevel": {
47
"Default": "Information",
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
namespace GitcgNetCord.MainApp.Entities;
2+
3+
public class DiscordCardCodeChannel
4+
{
5+
public ulong Id { get; set; }
6+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
using GitcgNetCord.MainApp.Infrastructure;
2+
3+
namespace GitcgNetCord.MainApp.Entities.Repositories;
4+
5+
public class DiscordCardCodeChannelService(
6+
AppDbContext dbContext
7+
)
8+
{
9+
public async ValueTask<DiscordCardCodeChannel?> FindAsync(ulong channelId)
10+
{
11+
return await dbContext
12+
.DiscordCardCodeChannels
13+
.FindAsync(channelId);
14+
}
15+
}

src/GitcgNetCord.MainApp/Enums/SharingDecodeType.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ public enum SharingDecodeType
1919

2020
public static class SharingDecodeTypeExtensions
2121
{
22-
private static readonly IEnumerable<SharingDecodeType> _createImageTypes =
22+
private static readonly IEnumerable<SharingDecodeType> CreateImageTypes =
2323
[
2424
SharingDecodeType.ImageSimplest,
2525
SharingDecodeType.ImageGameBackground,
@@ -28,7 +28,7 @@ public static class SharingDecodeTypeExtensions
2828

2929
public static bool IsCreateImageType(this SharingDecodeType type)
3030
{
31-
return _createImageTypes.Contains(type);
31+
return CreateImageTypes.Contains(type);
3232
}
3333
}
3434

0 commit comments

Comments
 (0)