添加项目文件。
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
using FileService.Domain.ValueObjects;
|
||||
using IM.DomainCommons;
|
||||
|
||||
namespace FileService.Domain.Entities
|
||||
{
|
||||
public class UploadFile:AggregateRootEntity
|
||||
{
|
||||
public Guid OwnerId { get; private set; }
|
||||
public FileName FileName { get; private set; }
|
||||
public long FileSize { get;private set; }
|
||||
public ContentType ContentType { get;private set; }
|
||||
public FileState State { get; private set; } = FileState.Uploaded;
|
||||
public StorageLocation StorageLocation { get; private set; } = new StorageLocation();
|
||||
public CheckSum CheckSum { get; private set; }
|
||||
|
||||
private UploadFile() { }
|
||||
|
||||
public UploadFile(Guid ownerId, FileName fileName, long fileSize, ContentType contentType, StorageLocation? storageLocation, CheckSum checkSum)
|
||||
{
|
||||
OwnerId = ownerId;
|
||||
FileName = fileName;
|
||||
FileSize = fileSize;
|
||||
ContentType = contentType;
|
||||
StorageLocation = storageLocation ?? new StorageLocation();
|
||||
CheckSum = checkSum;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
using FileService.Domain.Events;
|
||||
using FileService.Domain.ValueObjects;
|
||||
using IM.DomainCommons;
|
||||
|
||||
namespace FileService.Domain.Entities
|
||||
{
|
||||
public class UploadTask:AggregateRootEntity
|
||||
{
|
||||
public Guid UploaderId { get; private set; }
|
||||
public Guid ConversationId { get; private set; }
|
||||
public FileName FileName { get; private set; }
|
||||
public long FileSize { get; private set; }
|
||||
public ContentType ContentType { get; private set; }
|
||||
public StorageLocation StorageLocation { get; private set; }
|
||||
public UploadTaskState State { get; private set; }
|
||||
public CheckSum CheckSum { get; private set; }
|
||||
|
||||
private UploadTask() { }
|
||||
|
||||
public UploadTask(Guid uploaderId, Guid conversationId, FileName fileName, long fileSize, ContentType contentType, StorageLocation? storageLocation, CheckSum checkSum)
|
||||
{
|
||||
UploaderId = uploaderId;
|
||||
ConversationId = conversationId;
|
||||
FileName = fileName;
|
||||
FileSize = fileSize;
|
||||
ContentType = contentType;
|
||||
StorageLocation = storageLocation ?? new StorageLocation();
|
||||
CheckSum = checkSum;
|
||||
}
|
||||
|
||||
public void StartUpload()
|
||||
{
|
||||
State = UploadTaskState.Uploading;
|
||||
}
|
||||
|
||||
public void CompleteUpload(StorageLocation location)
|
||||
{
|
||||
State = UploadTaskState.Completed;
|
||||
AddDomainEvent(new UploadTaskCompletedDomainEvent(this));
|
||||
}
|
||||
|
||||
public void Fail()
|
||||
{
|
||||
State = UploadTaskState.Failed;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user