添加项目文件。
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
using FileService.Domain.Entities;
|
||||
using FileService.Domain.IReposities;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace FileService.Infrastructure.Reposites
|
||||
{
|
||||
public class UploadFileReposity : IUploadFileReposity
|
||||
{
|
||||
private readonly FileDbContext db;
|
||||
|
||||
public UploadFileReposity(FileDbContext db)
|
||||
{
|
||||
this.db = db;
|
||||
}
|
||||
|
||||
public void Create(UploadFile file)
|
||||
{
|
||||
db.Files.Add(file);
|
||||
}
|
||||
|
||||
public async Task<UploadFile?> FindByCheckSumAsync(Guid uploaderId, string value)
|
||||
{
|
||||
return await db.Files.FirstOrDefaultAsync(
|
||||
x => x.OwnerId == uploaderId &&
|
||||
x.CheckSum.Value == value
|
||||
);
|
||||
}
|
||||
|
||||
public async Task<UploadFile?> FindByIdAsync(Guid id)
|
||||
{
|
||||
return await db.Files.FirstOrDefaultAsync(x => x.Id == id);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user