mirror of
https://github.com/LBPUnion/ProjectLighthouse.git
synced 2025-06-11 02:11:29 +00:00
Revert slot API to old functionality
This commit is contained in:
parent
c6156d85cd
commit
f2dd41dd52
3 changed files with 81 additions and 10 deletions
|
@ -39,7 +39,7 @@ public class SlotEndpoints : ApiEndpointController
|
|||
List<ApiSlot> minimalSlots = (await this.database.Slots.OrderByDescending(s => s.FirstUploaded)
|
||||
.Skip(skip)
|
||||
.Take(limit)
|
||||
.ToListAsync()).ToSerializableList(ApiSlot.CreateFromEntity);
|
||||
.ToListAsync()).ToSerializableList(MinimalApiSlot.CreateFromEntity);
|
||||
|
||||
return this.Ok(minimalSlots);
|
||||
}
|
||||
|
@ -59,6 +59,6 @@ public class SlotEndpoints : ApiEndpointController
|
|||
SlotEntity? slot = await this.database.Slots.FirstOrDefaultAsync(u => u.SlotId == id);
|
||||
if (slot == null) return this.NotFound();
|
||||
|
||||
return this.Ok(ApiSlot.CreateFromEntity(slot));
|
||||
return this.Ok(ApiSlot.CreateFromEntity(slot, this.database));
|
||||
}
|
||||
}
|
|
@ -1,40 +1,69 @@
|
|||
using LBPUnion.ProjectLighthouse.Types.Entities.Level;
|
||||
using LBPUnion.ProjectLighthouse.Database;
|
||||
using LBPUnion.ProjectLighthouse.Types.Entities.Level;
|
||||
using LBPUnion.ProjectLighthouse.Types.Misc;
|
||||
using LBPUnion.ProjectLighthouse.Types.Users;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace LBPUnion.ProjectLighthouse.Servers.API.Responses;
|
||||
|
||||
[JsonObject]
|
||||
public struct ApiSlot
|
||||
{
|
||||
public int SlotId { get; set; }
|
||||
public string Name { get; set; }
|
||||
public string Description { get; set; }
|
||||
public string IconHash { get; set; }
|
||||
public bool TeamPick { get; set; }
|
||||
public bool IsAdventure { get; set; }
|
||||
public Location Location { get; set; }
|
||||
public GameVersion GameVersion { get; set; }
|
||||
public int CreatorId { get; set; }
|
||||
public bool InitiallyLocked { get; set; }
|
||||
public bool SubLevel { get; set; }
|
||||
public bool Lbp1Only { get; set; }
|
||||
public int Shareable { get; set; }
|
||||
public string AuthorLabels { get; set; }
|
||||
public string[] LevelTags { get; set; }
|
||||
public int MinimumPlayers { get; set; }
|
||||
public int MaximumPlayers { get; set; }
|
||||
public bool MoveRequired { get; set; }
|
||||
public long FirstUploaded { get; set; }
|
||||
public long LastUpdated { get; set; }
|
||||
public bool TeamPick { get; set; }
|
||||
public Location Location { get; set; }
|
||||
public GameVersion GameVersion { get; set; }
|
||||
public int Plays { get; set; }
|
||||
public int PlaysUnique { get; set; }
|
||||
public int PlaysComplete { get; set; }
|
||||
public bool CommentsEnabled { get; set; }
|
||||
public double AverageRating { get; set; }
|
||||
public string LevelType { get; set; }
|
||||
|
||||
public static ApiSlot CreateFromEntity(SlotEntity slot) =>
|
||||
public static ApiSlot CreateFromEntity(SlotEntity slot, DatabaseContext context) =>
|
||||
new()
|
||||
{
|
||||
SlotId = slot.SlotId,
|
||||
Name = slot.Name,
|
||||
Description = slot.Description,
|
||||
IconHash = slot.IconHash,
|
||||
TeamPick = slot.TeamPick,
|
||||
IsAdventure = slot.IsAdventurePlanet,
|
||||
Location = slot.Location,
|
||||
GameVersion = slot.GameVersion,
|
||||
CreatorId = slot.CreatorId,
|
||||
InitiallyLocked = slot.InitiallyLocked,
|
||||
SubLevel = slot.SubLevel,
|
||||
Lbp1Only = slot.Lbp1Only,
|
||||
Shareable = slot.Shareable,
|
||||
AuthorLabels = slot.AuthorLabels,
|
||||
LevelTags = slot.LevelTags(context),
|
||||
MinimumPlayers = slot.MinimumPlayers,
|
||||
MaximumPlayers = slot.MaximumPlayers,
|
||||
MoveRequired = slot.MoveRequired,
|
||||
FirstUploaded = slot.FirstUploaded,
|
||||
LastUpdated = slot.LastUpdated,
|
||||
TeamPick = slot.TeamPick,
|
||||
Location = slot.Location,
|
||||
GameVersion = slot.GameVersion,
|
||||
Plays = slot.Plays,
|
||||
PlaysUnique = slot.PlaysUnique,
|
||||
PlaysComplete = slot.PlaysComplete,
|
||||
CommentsEnabled = slot.CommentsEnabled,
|
||||
AverageRating = slot.RatingLBP1,
|
||||
LevelType = slot.LevelType,
|
||||
};
|
||||
}
|
42
ProjectLighthouse.Servers.API/Responses/MinimalApiSlot.cs
Normal file
42
ProjectLighthouse.Servers.API/Responses/MinimalApiSlot.cs
Normal file
|
@ -0,0 +1,42 @@
|
|||
using LBPUnion.ProjectLighthouse.Types.Entities.Level;
|
||||
using LBPUnion.ProjectLighthouse.Types.Misc;
|
||||
using LBPUnion.ProjectLighthouse.Types.Users;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace LBPUnion.ProjectLighthouse.Servers.API.Responses;
|
||||
|
||||
[JsonObject]
|
||||
public struct MinimalApiSlot
|
||||
{
|
||||
public int SlotId { get; set; }
|
||||
public string Name { get; set; }
|
||||
public string IconHash { get; set; }
|
||||
public bool TeamPick { get; set; }
|
||||
public bool IsAdventure { get; set; }
|
||||
public Location Location { get; set; }
|
||||
public GameVersion GameVersion { get; set; }
|
||||
public long FirstUploaded { get; set; }
|
||||
public long LastUpdated { get; set; }
|
||||
public int Plays { get; set; }
|
||||
public int PlaysUnique { get; set; }
|
||||
public int PlaysComplete { get; set; }
|
||||
public bool CommentsEnabled { get; set; }
|
||||
|
||||
public static ApiSlot CreateFromEntity(SlotEntity slot) =>
|
||||
new()
|
||||
{
|
||||
SlotId = slot.SlotId,
|
||||
Name = slot.Name,
|
||||
IconHash = slot.IconHash,
|
||||
TeamPick = slot.TeamPick,
|
||||
IsAdventure = slot.IsAdventurePlanet,
|
||||
Location = slot.Location,
|
||||
GameVersion = slot.GameVersion,
|
||||
FirstUploaded = slot.FirstUploaded,
|
||||
LastUpdated = slot.LastUpdated,
|
||||
Plays = slot.Plays,
|
||||
PlaysUnique = slot.PlaysUnique,
|
||||
PlaysComplete = slot.PlaysComplete,
|
||||
CommentsEnabled = slot.CommentsEnabled,
|
||||
};
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue