Slots /s/user/id endpoint

This commit is contained in:
jvyden 2021-10-06 23:17:01 -04:00
commit 897f709288
No known key found for this signature in database
GPG key ID: 18BCF2BE0262B278
3 changed files with 39 additions and 4 deletions

View file

@ -1,15 +1,28 @@
using System;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
using ProjectLighthouse.Serialization;
using ProjectLighthouse.Types;
namespace ProjectLighthouse.Controllers {
[ApiController]
[Route("LITTLEBIGPLANETPS3_XML/slots")]
[Route("LITTLEBIGPLANETPS3_XML/")]
[Produces("text/xml")]
public class SlotsController : ControllerBase {
[HttpGet("by")]
[HttpGet("slots/by")]
public IActionResult SlotsBy() {
return this.Ok(LbpSerializer.BlankElement("slots"));
string response = Enumerable.Aggregate(new Database().Slots, string.Empty, (current, slot) => current + slot.Serialize());
return this.Ok(LbpSerializer.TaggedStringElement("slots", response, "total", 1));
}
[HttpGet("s/user/{id:int}")]
public async Task<IActionResult> SUser(int id) {
Slot slot = await new Database().Slots.FirstOrDefaultAsync(s => s.SlotId == id);
return this.Ok(slot.Serialize());
}
}
}

View file

@ -18,7 +18,7 @@
"ProjectLighthouse": {
"commandName": "Project",
"dotnetRunMessages": "true",
"applicationUrl": "http://localhost:10060;https://localhost:10061",
"applicationUrl": "http://localhost:10060;https://localhost:10061;http://localhost:1062",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development",
"LIGHTHOUSE_DB_CONNECTION_STRING": "server=127.0.0.1;uid=root;pwd=lighthouse;database=lighthouse"

View file

@ -2,6 +2,7 @@ using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
using System.Xml.Serialization;
using ProjectLighthouse.Serialization;
namespace ProjectLighthouse.Types {
/// <summary>
@ -79,5 +80,26 @@ namespace ProjectLighthouse.Types {
[XmlElement("moveRequired")]
public bool MoveRequired { get; set; }
public string Serialize() {
string slotData = LbpSerializer.StringElement("name", Name) +
LbpSerializer.StringElement("id", SlotId) +
LbpSerializer.StringElement("game", 1) +
LbpSerializer.StringElement("npHandle", "jvyden") +
LbpSerializer.StringElement("description", Description) +
LbpSerializer.StringElement("icon", IconHash) +
LbpSerializer.StringElement("resource", Resource) +
LbpSerializer.StringElement("location", Location.Serialize()) +
LbpSerializer.StringElement("initiallyLocked", InitiallyLocked) +
LbpSerializer.StringElement("isSubLevel", SubLevel) +
LbpSerializer.StringElement("isLBP1Only", Lbp1Only) +
LbpSerializer.StringElement("shareable", Shareable) +
LbpSerializer.StringElement("background", BackgroundHash) +
LbpSerializer.StringElement("minPlayers", MinimumPlayers) +
LbpSerializer.StringElement("maxPlayers", MaximumPlayers) +
LbpSerializer.StringElement("moveRequired", MoveRequired);
return LbpSerializer.TaggedStringElement("slot", slotData, "type", "user");
}
}
}