-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Common: EFCore追加 * Purchase: 課金額を記録する機能を追加 * コンテナ周り整備
- Loading branch information
Showing
24 changed files
with
354 additions
and
24 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
using Microsoft.EntityFrameworkCore; | ||
|
||
namespace Approvers.King.Common; | ||
|
||
public class AppService : DbContext | ||
{ | ||
public DbSet<User> Users { get; set; } | ||
|
||
public static AppService CreateSession() | ||
{ | ||
return new AppService(); | ||
} | ||
|
||
protected override void OnConfiguring(DbContextOptionsBuilder options) | ||
{ | ||
options.UseSqlite(EnvironmentManager.SqliteConnectionString); | ||
} | ||
|
||
public async Task<User> FindOrCreateUserAsync(ulong discordId) | ||
{ | ||
var user = await Users.FindAsync(discordId); | ||
if (user != null) | ||
{ | ||
return user; | ||
} | ||
|
||
user = new User { DiscordID = discordId }; | ||
Add(user); | ||
return user; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
using System.ComponentModel.DataAnnotations; | ||
using Microsoft.EntityFrameworkCore; | ||
using Microsoft.EntityFrameworkCore.Metadata.Builders; | ||
|
||
namespace Approvers.King.Common; | ||
|
||
public class User | ||
{ | ||
[Key] | ||
public ulong DiscordID { get; set; } | ||
public int MonthlyPurchase { get; set; } | ||
|
||
public void ResetMonthlyPurchase() | ||
{ | ||
MonthlyPurchase = 0; | ||
} | ||
|
||
public string? RollGachaOnce() | ||
{ | ||
MonthlyPurchase += MasterManager.SettingMaster.PricePerGachaOnce; | ||
return GachaManager.Instance.Roll(); | ||
} | ||
|
||
public string RollGachaOnceCertain() | ||
{ | ||
MonthlyPurchase += MasterManager.SettingMaster.PricePerGachaOnceCertain; | ||
return GachaManager.Instance.RollWithoutNone(); | ||
} | ||
|
||
public List<string?> RollGachaTenTimes() | ||
{ | ||
const int pickCount = 10; | ||
MonthlyPurchase += MasterManager.SettingMaster.PricePerGachaTenTimes; | ||
return Enumerable.Range(0, pickCount).Select(_ => GachaManager.Instance.Roll()).ToList(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
using Approvers.King.Common; | ||
using Microsoft.EntityFrameworkCore; | ||
|
||
namespace Approvers.King.Events; | ||
|
||
public class MonthlyResetPresenter : SchedulerJobPresenterBase | ||
{ | ||
protected override async Task MainAsync() | ||
{ | ||
await using var app = AppService.CreateSession(); | ||
|
||
// ToDo: 課金額ランキング出したい | ||
|
||
await app.Users.ForEachAsync(user => user.ResetMonthlyPurchase()); | ||
await app.SaveChangesAsync(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,16 @@ | ||
.PHONY: run | ||
.PHONY: migrate | ||
migrate: | ||
dotnet ef migrations add $(name) | ||
dotnet ef database update | ||
|
||
.PHONY: run | ||
run: | ||
dotnet run | ||
|
||
.PHONY: docker-build | ||
docker-build: | ||
docker build . -t $(app_name) | ||
|
||
.PHONY: docker-push | ||
docker-push: | ||
docker push $(app_name) |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
using Microsoft.EntityFrameworkCore.Migrations; | ||
|
||
#nullable disable | ||
|
||
namespace Approvers.King.Migrations | ||
{ | ||
/// <inheritdoc /> | ||
public partial class InitialCreate : Migration | ||
{ | ||
/// <inheritdoc /> | ||
protected override void Up(MigrationBuilder migrationBuilder) | ||
{ | ||
|
||
} | ||
|
||
/// <inheritdoc /> | ||
protected override void Down(MigrationBuilder migrationBuilder) | ||
{ | ||
|
||
} | ||
} | ||
} |
Oops, something went wrong.