초기커밋

This commit is contained in:
2025-05-01 07:20:41 +09:00
commit 98bb2e3c5c
2747 changed files with 646947 additions and 0 deletions

View File

@@ -0,0 +1,62 @@
using Microsoft.Extensions.Options;
using MongoDB.Bson;
using MongoDB.Driver;
using SharpCompress.Common;
using UGQDatabase.Models;
using UGQDataAccess.Settings;
using ServerCommon.UGQ;
namespace UGQDataAccess.Repository;
public class QuestDialogRepository : BaseRepository<QuestDialogEntity>
{
private const string CollectionName = "QuestDialog";
public QuestDialogRepository(IMongoClient mongoClient, IOptions<UGQDatabaseSettings> settings) :
base(mongoClient, settings.Value.DatabaseName, CollectionName)
{
}
public async Task<(ServerErrorCode, QuestDialogEntity)> add(QuestDialogEntity entity)
{
await Collection.InsertOneAsync(entity);
return (ServerErrorCode.Success, entity);
}
public async Task<QuestDialogEntity?> get(string id)
{
var filter = Builders<QuestDialogEntity>.Filter
.Eq(x => x.Id, id);
var entity = await Collection.Find(filter).FirstOrDefaultAsync();
return entity;
}
public async Task<List<QuestDialogEntity>> get(IEnumerable<string> ids)
{
var filter = Builders<QuestDialogEntity>.Filter
.In(x => x.Id, ids);
return await Collection.Find(filter).ToListAsync();
}
public async Task<(ServerErrorCode, QuestDialogEntity?)> updateSequences(string dialogId, List<DialogSequenceEntity> sequences)
{
var filter = Builders<QuestDialogEntity>.Filter
.Eq(x => x.Id, dialogId);
var update = Builders<QuestDialogEntity>.Update
.Set(x => x.Sequences, sequences)
.Set(x => x.UpdatedAt, DateTime.UtcNow);
var options = new FindOneAndUpdateOptions<QuestDialogEntity>
{
ReturnDocument = ReturnDocument.After,
};
var updated = await Collection.FindOneAndUpdateAsync(filter, update, options);
return (ServerErrorCode.Success, updated);
}
}