Skip to content
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ Extra:{ "Namespace": "Snap.Hutao.Remastered.Web.Endpoint.Hoyolab" }
"string DeviceFpGetExtList(int platform)",https://public-data-api.mihoyo.com/device-fp/api/getExtList?platform={platform:D},
"string DeviceFpGetFp()",https://public-data-api.mihoyo.com/device-fp/api/getFp,
"string GachaInfoGetGachaLog(string query)",https://public-operation-hk4e.mihoyo.com/gacha_info/api/getGachaLog?{query},https://public-operation-hk4e-sg.hoyoverse.com/gacha_info/api/getGachaLog?{query}
"string GachaInfoGetBeyondGachaLog(string query)",https://public-operation-hk4e.mihoyo.com/gacha_info/api/getBeyondGachaLog?{query},https://public-operation-hk4e-sg.hoyoverse.com/gacha_info/api/getBeyondGachaLog?{query}
"string GameRecordCharacterList()",https://api-takumi-record.mihoyo.com/game_record/app/genshin/api/character/list,https://bbs-api-os.hoyolab.com/game_record/app/genshin/api/character/list
"string GameRecordCharacterDetail()",https://api-takumi-record.mihoyo.com/game_record/app/genshin/api/character/detail,https://bbs-api-os.hoyolab.com/game_record/app/genshin/api/character/detail
"string GameRecordDailyNote(Snap.Hutao.Remastered.Web.Hoyolab.PlayerUid uid)",https://api-takumi-record.mihoyo.com/game_record/app/genshin/api/dailyNote?{Snap.Hutao.Remastered.Web.Hoyolab.PlayerUidExtension.ToRoleIdServerQueryString(uid)},https://bbs-api-os.hoyolab.com/game_record/app/genshin/api/dailyNote?{Snap.Hutao.Remastered.Web.Hoyolab.PlayerUidExtension.ToRoleIdServerQueryString(uid)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@
"Name": "AvatarId",
"Documentation": "角色 Id"
},
{
"Name": "BeyondItemId",
"Documentation": "千星奇域装扮 Id"
},
{
"Name": "ChapterId",
"Documentation": "章节 Id"
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
using Microsoft.EntityFrameworkCore.Migrations;

#nullable disable

namespace Snap.Hutao.Remastered.Migrations
{
/// <inheritdoc />
public partial class AddBeyondGachaItem : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "beyond_gacha_items",
columns: table => new
{
InnerId = table.Column<Guid>(type: "TEXT", nullable: false),
ArchiveId = table.Column<Guid>(type: "TEXT", nullable: false),
GachaType = table.Column<int>(type: "INTEGER", nullable: false),
ItemId = table.Column<uint>(type: "INTEGER", nullable: false),
Time = table.Column<DateTimeOffset>(type: "TEXT", nullable: false),
Id = table.Column<long>(type: "INTEGER", nullable: false),
ItemType = table.Column<string>(type: "TEXT", nullable: false),
ItemName = table.Column<string>(type: "TEXT", nullable: false),
ScheduleId = table.Column<long>(type: "INTEGER", nullable: false),
RankType = table.Column<long>(type: "INTEGER", nullable: false),
Uid = table.Column<string>(type: "TEXT", nullable: false),
IsUp = table.Column<int>(type: "INTEGER", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_beyond_gacha_items", x => x.InnerId);
table.ForeignKey(
name: "FK_beyond_gacha_items_gacha_archives_ArchiveId",
column: x => x.ArchiveId,
principalTable: "gacha_archives",
principalColumn: "InnerId",
onDelete: ReferentialAction.Cascade);
});

migrationBuilder.CreateIndex(
name: "IX_beyond_gacha_items_ArchiveId",
table: "beyond_gacha_items",
column: "ArchiveId");
}

/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "beyond_gacha_items");
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,55 @@ protected override void BuildModel(ModelBuilder modelBuilder)
b.ToTable("gacha_items");
});

modelBuilder.Entity("Snap.Hutao.Remastered.Model.Entity.BeyondGachaItem", b =>
{
b.Property<Guid>("InnerId")
.ValueGeneratedOnAdd()
.HasColumnType("TEXT");

b.Property<Guid>("ArchiveId")
.HasColumnType("TEXT");

b.Property<int>("GachaType")
.HasColumnType("INTEGER");

b.Property<long>("Id")
.HasColumnType("INTEGER");

b.Property<int>("IsUp")
.HasColumnType("INTEGER");

b.Property<uint>("ItemId")
.HasColumnType("INTEGER");

b.Property<string>("ItemName")
.IsRequired()
.HasColumnType("TEXT");

b.Property<string>("ItemType")
.IsRequired()
.HasColumnType("TEXT");

b.Property<long>("RankType")
.HasColumnType("INTEGER");

b.Property<long>("ScheduleId")
.HasColumnType("INTEGER");

b.Property<DateTimeOffset>("Time")
.HasColumnType("TEXT");

b.Property<string>("Uid")
.IsRequired()
.HasColumnType("TEXT");

b.HasKey("InnerId");

b.HasIndex("ArchiveId");

b.ToTable("beyond_gacha_items");
});

modelBuilder.Entity("Snap.Hutao.Remastered.Model.Entity.GameAccount", b =>
{
b.Property<Guid>("InnerId")
Expand Down Expand Up @@ -632,6 +681,17 @@ protected override void BuildModel(ModelBuilder modelBuilder)
b.Navigation("Archive");
});

modelBuilder.Entity("Snap.Hutao.Remastered.Model.Entity.BeyondGachaItem", b =>
{
b.HasOne("Snap.Hutao.Remastered.Model.Entity.GachaArchive", "Archive")
.WithMany()
.HasForeignKey("ArchiveId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();

b.Navigation("Archive");
});

modelBuilder.Entity("Snap.Hutao.Remastered.Model.Entity.InventoryItem", b =>
{
b.HasOne("Snap.Hutao.Remastered.Model.Entity.CultivateProject", "Project")
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
// Copyright (c) DGP Studio. All rights reserved.
// Licensed under the MIT license.

using Snap.Hutao.Remastered.Model.InterChange.GachaLog;
using Snap.Hutao.Remastered.Web.Hoyolab.Hk4e.Event.GachaInfo;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;

namespace Snap.Hutao.Remastered.Model.Entity;

[Table("beyond_gacha_items")]
public sealed class BeyondGachaItem
{
[Key]
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public Guid InnerId { get; set; }

[ForeignKey(nameof(ArchiveId))]
public GachaArchive Archive { get; set; } = default!;

public Guid ArchiveId { get; set; }

public GachaType GachaType { get; set; }

public uint ItemId { get; set; }

public DateTimeOffset Time { get; set; }

public long Id { get; set; }

public string ItemType { get; set; } = default!;

public string ItemName { get; set; } = default!;

public long ScheduleId { get; set; }

public long RankType { get; set; }

public string Uid { get; set; } = default!;

public int IsUp { get; set; }

public static BeyondGachaItem From(Guid archiveId, BeyondGachaLogItem item)
{
return new()
{
ArchiveId = archiveId,
GachaType = item.GachaType,
ItemId = uint.Parse(item.ItemId),
Time = item.Time,
Id = item.Id,
ItemType = item.ItemType,
ItemName = item.ItemName,
ScheduleId = long.Parse(item.ScheduleId),
RankType = (long)item.RankType,
Uid = item.Uid,
IsUp = item.IsUp,
};
}

public static BeyondGachaItem From(Guid archiveId, Hk4eUGCItem item, int timezoneOffset)
{
return new()
{
ArchiveId = archiveId,
GachaType = item.GachaType,
ItemId = item.ItemId,
Time = new(item.Time, TimeSpan.FromHours(timezoneOffset)),
Id = item.Id,
ItemType = item.ItemType,
ItemName = item.ItemName,
ScheduleId = item.ScheduleId,
RankType = item.RankType,
Uid = string.Empty, // Hk4eUGCItem doesn't have Uid
IsUp = 0, // Hk4eUGCItem doesn't have IsUp
};
}

public Hk4eUGCItem ToHk4eUGCItem()
{
return new()
{
GachaType = GachaType,
ItemId = ItemId,
Time = Time.UtcDateTime,
Id = Id,
ItemType = ItemType,
ItemName = ItemName,
ScheduleId = ScheduleId,
RankType = RankType,
};
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ public AppDbContext(DbContextOptions<AppDbContext> options)

public DbSet<GachaItem> GachaItems { get; set; } = default!;

public DbSet<BeyondGachaItem> BeyondGachaItems { get; set; } = default!;

public DbSet<GachaArchive> GachaArchives { get; set; } = default!;

public DbSet<AvatarInfo> AvatarInfos { get; set; } = default!;
Expand Down Expand Up @@ -96,4 +98,4 @@ protected override void OnModelCreating(ModelBuilder modelBuilder)
.ApplyConfiguration(new HardChallengeEntryConfiguration())
.ApplyConfiguration(new UserConfiguration());
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
using Snap.Hutao.Remastered.Core.Text.Json.Annotation;
using Snap.Hutao.Remastered.Core.Text.Json.Converter;
using Snap.Hutao.Remastered.Web.Hoyolab.Hk4e.Event.GachaInfo;

namespace Snap.Hutao.Remastered.Model.InterChange.GachaLog;

public class Hk4eUGCItem : IJsonOnDeserialized
{
// ReSharper disable once InconsistentNaming

[JsonPropertyName("op_gacha_type")]
[JsonEnumHandling(JsonEnumHandling.NumberString)]
public required GachaType GachaType { get; init; }

[JsonPropertyName("item_id")]
[JsonNumberHandling(JsonNumberHandling.AllowReadingFromString | JsonNumberHandling.WriteAsString)]
public required uint ItemId { get; init; }

[JsonPropertyName("time")]
[JsonConverter(typeof(SimpleDateTimeConverter))]
public required DateTime Time { get; init; }

[JsonPropertyName("id")]
[JsonNumberHandling(JsonNumberHandling.AllowReadingFromString | JsonNumberHandling.WriteAsString)]
public required long Id { get; init; }

[JsonPropertyName("item_type")]
public required string ItemType { get; init; }

[JsonPropertyName("item_name")]
public required string ItemName { get; init; }

[JsonPropertyName("schedule_id")]
[JsonNumberHandling(JsonNumberHandling.AllowReadingFromString | JsonNumberHandling.WriteAsString)]
public required long ScheduleId { get; init; }

[JsonPropertyName("rank_type")]
[JsonNumberHandling(JsonNumberHandling.AllowReadingFromString | JsonNumberHandling.WriteAsString)]
public required long RankType { get; init; }

public void OnDeserialized()
{
if (!Enum.IsDefined(GachaType))
{
throw new JsonException($"Unsupported GachaType: {GachaType}");
}
}
}
Loading
Loading