초기커밋
This commit is contained in:
51
UGQDataAccess/Repository/ReportRepository.cs
Normal file
51
UGQDataAccess/Repository/ReportRepository.cs
Normal file
@@ -0,0 +1,51 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.Extensions.Options;
|
||||
using MongoDB.Driver;
|
||||
using SharpCompress.Common;
|
||||
using UGQDatabase.Models;
|
||||
using UGQDataAccess.Settings;
|
||||
using ServerCommon.UGQ;
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
namespace UGQDataAccess.Repository
|
||||
{
|
||||
public class ReportRepository : BaseRepository<ReportEntity>
|
||||
{
|
||||
private const string CollectionName = "Report";
|
||||
|
||||
public ReportRepository(IMongoClient mongoClient, IOptions<UGQDatabaseSettings> settings) :
|
||||
base(mongoClient, settings.Value.DatabaseName, CollectionName)
|
||||
{
|
||||
}
|
||||
|
||||
public async Task<ReportEntity?> get(long questId, long revision, string userGuid)
|
||||
{
|
||||
var builder = Builders<ReportEntity>.Filter;
|
||||
var filter = builder.Eq(x => x.QuestId, questId) &
|
||||
builder.Eq(x => x.Revision, revision) &
|
||||
builder.Eq(x => x.UserGuid, userGuid);
|
||||
|
||||
ReportEntity? entity = await (await Collection.FindAsync(filter)).FirstOrDefaultAsync();
|
||||
return entity;
|
||||
}
|
||||
|
||||
public async Task<ServerErrorCode> insert(long questId, long revision, string userGuid, string contents)
|
||||
{
|
||||
var entity = new ReportEntity
|
||||
{
|
||||
QuestId = questId,
|
||||
Revision = revision,
|
||||
UserGuid = userGuid,
|
||||
Contents = contents,
|
||||
CreatedAt = DateTime.UtcNow,
|
||||
};
|
||||
|
||||
await Collection.InsertOneAsync(entity);
|
||||
return ServerErrorCode.Success;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user