mirror of
https://github.com/babalae/better-genshin-impact.git
synced 2026-05-25 10:05:49 +08:00
init sqlite
This commit is contained in:
@@ -80,6 +80,9 @@
|
||||
<PackageReference Include="WPF-UI.Violeta" Version="4.0.0" />
|
||||
<PackageReference Include="YoloV8" Version="4.1.7" />
|
||||
<PackageReference Include="gong-wpf-dragdrop" Version="3.2.1" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="8.0.3" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="8.0.3" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="8.0.3" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup Condition=" '$(Configuration)' == 'Debug'">
|
||||
|
||||
25
BetterGenshinImpact/Model/Database/ApplicationDbContext.cs
Normal file
25
BetterGenshinImpact/Model/Database/ApplicationDbContext.cs
Normal file
@@ -0,0 +1,25 @@
|
||||
using System.IO;
|
||||
using BetterGenshinImpact.Core.Config;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace BetterGenshinImpact.Model.Database
|
||||
{
|
||||
public class ApplicationDbContext : DbContext
|
||||
{
|
||||
public DbSet<TaskList> TaskLists { get; set; }
|
||||
|
||||
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
|
||||
{
|
||||
var dbPath = Path.Combine(Global.Absolute("User\\db"), "Data", "bgi_user.db");
|
||||
Directory.CreateDirectory(Path.GetDirectoryName(dbPath)!);
|
||||
optionsBuilder.UseSqlite($"Data Source={dbPath}");
|
||||
}
|
||||
|
||||
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
||||
{
|
||||
modelBuilder.Entity<TaskList>()
|
||||
.HasIndex(t => t.OrderIndex)
|
||||
.IsUnique();
|
||||
}
|
||||
}
|
||||
}
|
||||
51
BetterGenshinImpact/Model/Database/TaskList.cs
Normal file
51
BetterGenshinImpact/Model/Database/TaskList.cs
Normal file
@@ -0,0 +1,51 @@
|
||||
using System;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
namespace BetterGenshinImpact.Model.Database
|
||||
{
|
||||
[Table("task_list")]
|
||||
public class TaskList
|
||||
{
|
||||
[Key]
|
||||
[Column("id")]
|
||||
public int Id { get; set; }
|
||||
|
||||
[Column("order_index")]
|
||||
public int OrderIndex { get; set; }
|
||||
|
||||
[Column("task_name")]
|
||||
[Required]
|
||||
[MaxLength(255)]
|
||||
public string TaskName { get; set; } = string.Empty;
|
||||
|
||||
[Column("task_params")]
|
||||
public string? TaskParams { get; set; }
|
||||
|
||||
[Column("schedule_expression")]
|
||||
[MaxLength(255)]
|
||||
public string? ScheduleExpression { get; set; }
|
||||
|
||||
[Column("schedule_type")]
|
||||
[MaxLength(50)]
|
||||
public string? ScheduleType { get; set; }
|
||||
|
||||
[Column("next_run_time")]
|
||||
public DateTime? NextRunTime { get; set; }
|
||||
|
||||
[Column("last_run_time")]
|
||||
public DateTime? LastRunTime { get; set; }
|
||||
|
||||
[Column("hotkey")]
|
||||
[MaxLength(50)]
|
||||
public string? Hotkey { get; set; }
|
||||
|
||||
[Column("hotkey_")]
|
||||
[MaxLength(50)]
|
||||
public string? Hotkey2 { get; set; }
|
||||
|
||||
[Column("category")]
|
||||
[MaxLength(50)]
|
||||
public string? Category { get; set; }
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user