mirror of
https://github.com/LBPUnion/ProjectLighthouse.git
synced 2025-08-05 03:18:45 +00:00
Slots /s/user/id endpoint
This commit is contained in:
parent
e554ee04c7
commit
897f709288
3 changed files with 39 additions and 4 deletions
|
@ -1,15 +1,28 @@
|
||||||
|
using System;
|
||||||
|
using System.Linq;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
using ProjectLighthouse.Serialization;
|
using ProjectLighthouse.Serialization;
|
||||||
|
using ProjectLighthouse.Types;
|
||||||
|
|
||||||
namespace ProjectLighthouse.Controllers {
|
namespace ProjectLighthouse.Controllers {
|
||||||
[ApiController]
|
[ApiController]
|
||||||
[Route("LITTLEBIGPLANETPS3_XML/slots")]
|
[Route("LITTLEBIGPLANETPS3_XML/")]
|
||||||
[Produces("text/xml")]
|
[Produces("text/xml")]
|
||||||
public class SlotsController : ControllerBase {
|
public class SlotsController : ControllerBase {
|
||||||
[HttpGet("by")]
|
[HttpGet("slots/by")]
|
||||||
public IActionResult SlotsBy() {
|
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());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -18,7 +18,7 @@
|
||||||
"ProjectLighthouse": {
|
"ProjectLighthouse": {
|
||||||
"commandName": "Project",
|
"commandName": "Project",
|
||||||
"dotnetRunMessages": "true",
|
"dotnetRunMessages": "true",
|
||||||
"applicationUrl": "http://localhost:10060;https://localhost:10061",
|
"applicationUrl": "http://localhost:10060;https://localhost:10061;http://localhost:1062",
|
||||||
"environmentVariables": {
|
"environmentVariables": {
|
||||||
"ASPNETCORE_ENVIRONMENT": "Development",
|
"ASPNETCORE_ENVIRONMENT": "Development",
|
||||||
"LIGHTHOUSE_DB_CONNECTION_STRING": "server=127.0.0.1;uid=root;pwd=lighthouse;database=lighthouse"
|
"LIGHTHOUSE_DB_CONNECTION_STRING": "server=127.0.0.1;uid=root;pwd=lighthouse;database=lighthouse"
|
||||||
|
|
|
@ -2,6 +2,7 @@ using System.ComponentModel.DataAnnotations;
|
||||||
using System.ComponentModel.DataAnnotations.Schema;
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Xml.Serialization;
|
using System.Xml.Serialization;
|
||||||
|
using ProjectLighthouse.Serialization;
|
||||||
|
|
||||||
namespace ProjectLighthouse.Types {
|
namespace ProjectLighthouse.Types {
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -79,5 +80,26 @@ namespace ProjectLighthouse.Types {
|
||||||
|
|
||||||
[XmlElement("moveRequired")]
|
[XmlElement("moveRequired")]
|
||||||
public bool MoveRequired { get; set; }
|
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");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Add table
Add a link
Reference in a new issue