Skip to content

Commit

Permalink
update to hutao api v2
Browse files Browse the repository at this point in the history
  • Loading branch information
Lightczx committed Oct 13, 2022
1 parent 6e6d125 commit 67a1d5d
Show file tree
Hide file tree
Showing 48 changed files with 412 additions and 814 deletions.
5 changes: 2 additions & 3 deletions src/Snap.Hutao/Snap.Hutao/Core/Logging/LogEntryQueue.cs
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,8 @@ private static LogDbContext InitializeDbContext()
logDbContext.Database.Migrate();
}

logDbContext.Logs.RemoveRange(logDbContext.Logs);
logDbContext.SaveChanges();

// only raw sql can pass
logDbContext.Database.ExecuteSqlRaw("DELETE FROM logs WHERE Exception IS NULL");
return logDbContext;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,4 @@ public CancellationToken Register(TItem item)

return waitingItems.GetOrAdd(item, new CancellationTokenSource()).Token;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ namespace Snap.Hutao.Extension;
/// <summary>
/// <see cref="BinaryReader"/> 扩展
/// </summary>
public static class BinaryReaderExtensions
public static class BinaryReaderExtension
{
/// <summary>
/// 判断是否处于流的结尾
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ namespace Snap.Hutao.Extension;
/// <summary>
/// <see cref="DateTimeOffset"/> 扩展
/// </summary>
public static class DateTimeOffsetExtensions
public static class DateTimeOffsetExtension
{
/// <summary>
/// Converts the current <see cref="DateTimeOffset"/> to a <see cref="DateTimeOffset"/> that represents the local time.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ namespace Snap.Hutao.Extension;
/// <summary>
/// 枚举拓展
/// </summary>
public static class EnumExtensions
public static class EnumExtension
{
/// <summary>
/// 获取枚举的描述
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ namespace Snap.Hutao.Extension;
/// <summary>
/// <see cref="IEnumerable{T}"/> 扩展
/// </summary>
public static partial class EnumerableExtensions
public static partial class EnumerableExtension
{
/// <inheritdoc cref="Enumerable.Average(IEnumerable{int})"/>
public static double AverageNoThrow(this List<int> source)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ namespace Snap.Hutao.Extension;
/// <summary>
/// 数高性能扩展
/// </summary>
public static class NumberExtensions
public static class NumberExtension
{
/// <summary>
/// 获取从右向左某位上的数字
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ namespace Snap.Hutao.Extension;
/// <summary>
/// 对象扩展
/// </summary>
public static class ObjectExtensions
public static class ObjectExtension
{
/// <summary>
/// <see langword="as"/> 的链式调用扩展
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ namespace Snap.Hutao.Extension;
/// <summary>
/// 包版本扩展
/// </summary>
public static class PackageVersionExtensions
public static class PackageVersionExtension
{
/// <summary>
/// 将包版本转换为版本
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public class UIAFInfo
public DateTimeOffset ExportDateTime
{
// Hot fix | 1.0.31 | UIAF.Info.ExportTimestamp can be milliseconds
get => DateTimeOffsetExtensions.FromUnixTime(ExportTimestamp, DateTimeOffset.MinValue);
get => DateTimeOffsetExtension.FromUnixTime(ExportTimestamp, DateTimeOffset.MinValue);
}

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public class UIGFInfo
/// </summary>
public DateTimeOffset ExportDateTime
{
get => DateTimeOffsetExtensions.FromUnixTime(ExportTimestamp, DateTimeOffset.MinValue);
get => DateTimeOffsetExtension.FromUnixTime(ExportTimestamp, DateTimeOffset.MinValue);
}

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,11 @@ private async Task<Summary> GetSummaryCoreAsync(PlayerInfo info, IEnumerable<Web

foreach (Web.Enka.Model.AvatarInfo webInfo in webInfos)
{
if (webInfo.AvatarId == 10000005 || webInfo.AvatarId == 10000007)
{
continue;
}

Model.Entity.AvatarInfo? entity = dbInfos.SingleOrDefault(i => i.Info.AvatarId == webInfo.AvatarId);

if (entity == null)
Expand All @@ -141,8 +146,9 @@ private async Task<Summary> GetSummaryCoreAsync(PlayerInfo info, IEnumerable<Web
return appDbContext.AvatarInfos
.Where(i => i.Uid == uid)
.Select(i => i.Info)
.AsEnumerable()
.OrderByDescending(i => i.AvatarId)

// .AsEnumerable()
// .OrderByDescending(i => i.AvatarId)
.ToList();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,6 @@ public async Task<List<AnnouncementContent>> GetAnnouncementContentsAsync(Cancel
.GetFromJsonAsync<Response<ListWrapper<AnnouncementContent>>>(ApiEndpoints.AnnContent, jsonSerializerOptions, cancellationToken)
.ConfigureAwait(false);

return EnumerableExtensions.EmptyIfNull(resp?.Data?.List);
return EnumerableExtension.EmptyIfNull(resp?.Data?.List);
}
}
2 changes: 1 addition & 1 deletion src/Snap.Hutao/Snap.Hutao/Web/Hoyolab/PlayerUid.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ namespace Snap.Hutao.Web.Hoyolab;
/// </summary>
public struct PlayerUid
{
private string? region = null;
private string? region = default;

/// <summary>
/// 构造一个新的玩家 Uid 结构
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,6 @@ public async Task<List<UserGameRole>> GetUserGameRolesAsync(User user, Cancellat
.TryCatchGetFromJsonAsync<Response<ListWrapper<UserGameRole>>>(ApiEndpoints.UserGameRoles, options, logger, token)
.ConfigureAwait(false);

return EnumerableExtensions.EmptyIfNull(resp?.Data?.List);
return EnumerableExtension.EmptyIfNull(resp?.Data?.List);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ public async Task<List<Character>> GetCharactersAsync(User user, PlayerUid uid,
.TryCatchPostAsJsonAsync<Response<CharacterWrapper>>(logger, token)
.ConfigureAwait(false);

return EnumerableExtensions.EmptyIfNull(resp?.Data?.Avatars);
return EnumerableExtension.EmptyIfNull(resp?.Data?.Avatars);
}

private class CharacterData
Expand Down
Loading

0 comments on commit 67a1d5d

Please sign in to comment.