Recommiting glbs for LFS
Deploy Promiscuity Auth API / deploy (push) Successful in 1m59s
Deploy Promiscuity Character API / deploy (push) Successful in 1m16s
Deploy Promiscuity Inventory API / deploy (push) Has been cancelled
Deploy Promiscuity Locations API / deploy (push) Has been cancelled
Deploy Promiscuity Mail API / deploy (push) Has been cancelled
Deploy Promiscuity World API / deploy (push) Has been cancelled
Deploy Promiscuity Crafting API / deploy (push) Has been cancelled
k8s smoke test / test (push) Has been cancelled

This commit is contained in:
2026-05-12 15:34:12 -05:00
parent a9e546a121
commit fecbefc15c
141 changed files with 7099 additions and 2601 deletions
+19 -19
View File
@@ -1,17 +1,17 @@
using MongoDB.Bson;
using MongoDB.Bson.Serialization.Attributes;
namespace LocationsApi.Models;
using MongoDB.Bson;
using MongoDB.Bson.Serialization.Attributes;
namespace LocationsApi.Models;
public class Location
{
[BsonId]
[BsonRepresentation(BsonType.ObjectId)]
public string? Id { get; set; }
[BsonElement("name")]
public string Name { get; set; } = string.Empty;
[BsonId]
[BsonRepresentation(BsonType.ObjectId)]
public string? Id { get; set; }
[BsonElement("name")]
public string Name { get; set; } = string.Empty;
[BsonElement("coord")]
public required Coord Coord { get; set; }
@@ -26,10 +26,10 @@ public class Location
[BsonElement("locationObject")]
public LocationObject? LocationObject { get; set; }
[BsonElement("locationObjectResolved")]
public bool LocationObjectResolved { get; set; }
[BsonElement("createdUtc")]
public DateTime CreatedUtc { get; set; } = DateTime.UtcNow;
}
[BsonElement("locationObjectResolved")]
public bool LocationObjectResolved { get; set; }
[BsonElement("createdUtc")]
public DateTime CreatedUtc { get; set; } = DateTime.UtcNow;
}
@@ -1,9 +1,9 @@
using LocationsApi.Models;
using MongoDB.Bson;
using MongoDB.Driver;
namespace LocationsApi.Services;
using LocationsApi.Models;
using MongoDB.Bson;
using MongoDB.Driver;
namespace LocationsApi.Services;
public class LocationStore
{
private readonly IMongoCollection<Location> _col;
@@ -19,7 +19,7 @@ public class LocationStore
{
var cs = cfg["MongoDB:ConnectionString"] ?? "mongodb://127.0.0.1:27017";
var dbName = cfg["MongoDB:DatabaseName"] ?? "GameDb";
var client = new MongoClient(cs);
var client = new MongoClient(cs);
var db = client.GetDatabase(dbName);
var collectionName = "Locations";
EnsureLocationSchema(db, collectionName);
@@ -32,33 +32,33 @@ public class LocationStore
EnsureOriginLocation();
}
private static void EnsureLocationSchema(IMongoDatabase db, string collectionName)
{
var validator = new BsonDocument
{
{
"$jsonSchema", new BsonDocument
{
{ "bsonType", "object" },
private static void EnsureLocationSchema(IMongoDatabase db, string collectionName)
{
var validator = new BsonDocument
{
{
"$jsonSchema", new BsonDocument
{
{ "bsonType", "object" },
{ "required", new BsonArray { "name", "coord", "biomeKey", "elevation", "createdUtc" } },
{
"properties", new BsonDocument
{
{ "name", new BsonDocument { { "bsonType", "string" } } },
{
"coord", new BsonDocument
{
{ "bsonType", "object" },
{ "required", new BsonArray { "x", "y" } },
{
"properties", new BsonDocument
{
{ "x", new BsonDocument { { "bsonType", "int" } } },
{ "y", new BsonDocument { { "bsonType", "int" } } }
}
}
}
{
"coord", new BsonDocument
{
{ "bsonType", "object" },
{ "required", new BsonArray { "x", "y" } },
{
"properties", new BsonDocument
{
{ "x", new BsonDocument { { "bsonType", "int" } } },
{ "y", new BsonDocument { { "bsonType", "int" } } }
}
}
}
},
{ "biomeKey", new BsonDocument { { "bsonType", "string" } } },
{ "elevation", new BsonDocument { { "bsonType", "int" } } },
@@ -118,42 +118,42 @@ public class LocationStore
}
}
}
};
var collections = db.ListCollectionNames().ToList();
if (!collections.Contains(collectionName))
{
var createCommand = new BsonDocument
{
{ "create", collectionName },
{ "validator", validator },
{ "validationAction", "error" }
};
db.RunCommand<BsonDocument>(createCommand);
return;
}
var command = new BsonDocument
{
{ "collMod", collectionName },
{ "validator", validator },
{ "validationAction", "error" }
};
db.RunCommand<BsonDocument>(command);
}
public Task CreateAsync(Location location) => _col.InsertOneAsync(location);
public Task<List<Location>> GetAllAsync() =>
_col.Find(Builders<Location>.Filter.Empty).ToListAsync();
public async Task<bool> DeleteAsync(string id)
{
var filter = Builders<Location>.Filter.Eq(l => l.Id, id);
var result = await _col.DeleteOneAsync(filter);
return result.DeletedCount > 0;
}
};
var collections = db.ListCollectionNames().ToList();
if (!collections.Contains(collectionName))
{
var createCommand = new BsonDocument
{
{ "create", collectionName },
{ "validator", validator },
{ "validationAction", "error" }
};
db.RunCommand<BsonDocument>(createCommand);
return;
}
var command = new BsonDocument
{
{ "collMod", collectionName },
{ "validator", validator },
{ "validationAction", "error" }
};
db.RunCommand<BsonDocument>(command);
}
public Task CreateAsync(Location location) => _col.InsertOneAsync(location);
public Task<List<Location>> GetAllAsync() =>
_col.Find(Builders<Location>.Filter.Empty).ToListAsync();
public async Task<bool> DeleteAsync(string id)
{
var filter = Builders<Location>.Filter.Eq(l => l.Id, id);
var result = await _col.DeleteOneAsync(filter);
return result.DeletedCount > 0;
}
public async Task<bool> UpdateNameAsync(string id, string name)
{
var filter = Builders<Location>.Filter.Eq(l => l.Id, id);
@@ -419,10 +419,10 @@ public class LocationStore
{
_col.InsertOne(origin);
}
catch (MongoWriteException ex) when (ex.WriteError.Category == ServerErrorCategory.DuplicateKey)
{
// Another instance seeded it first.
}
catch (MongoWriteException ex) when (ex.WriteError.Category == ServerErrorCategory.DuplicateKey)
{
// Another instance seeded it first.
}
}
private static string NormalizeItemKey(string itemKey) => itemKey.Trim().ToLowerInvariant();