完善ddd模块及错误异常中间件

This commit is contained in:
陈淳
2023-01-12 18:30:57 +08:00
parent ea4e8856c2
commit 8ead6c59c0
50 changed files with 3334 additions and 136 deletions

View File

@@ -0,0 +1,31 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Yi.Framework.Ddd.Dtos
{
[Serializable]
public abstract class EntityDto<TKey> : EntityDto, IEntityDto<TKey>, IEntityDto
{
//
// 摘要:
// Id of the entity.
public TKey Id { get; set; }
public override string ToString()
{
return $"[DTO: {GetType().Name}] Id = {Id}";
}
}
[Serializable]
public abstract class EntityDto : IEntityDto
{
public override string ToString()
{
return "[DTO: " + GetType().Name + "]";
}
}
}

View File

@@ -0,0 +1,17 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Yi.Framework.Ddd.Dtos
{
public interface IEntityDto
{
}
public interface IEntityDto<TKey> : IEntityDto
{
TKey Id { get; set; }
}
}

View File

@@ -0,0 +1,50 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Security.Principal;
using System.Text;
using System.Threading.Tasks;
namespace Yi.Framework.Ddd.Entities
{
[Serializable]
public abstract class Entity : IEntity
{
protected Entity()
{
}
public override string ToString()
{
return "[ENTITY: " + GetType().Name + "] Keys = " + GetKeys();
}
public abstract object[] GetKeys();
}
[Serializable]
public abstract class Entity<TKey> : Entity, IEntity<TKey>, IEntity
{
public virtual TKey Id { get; protected set; }
protected Entity()
{
}
protected Entity(TKey id)
{
Id = id;
}
public override object[] GetKeys()
{
return new object[1] { Id };
}
public override string ToString()
{
return $"[ENTITY: {GetType().Name}] Id = {Id}";
}
}
}

View File

@@ -0,0 +1,23 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Yi.Framework.Ddd.Entities
{
public interface IEntity
{
//
// 摘要:
// Returns an array of ordered keys for this entity.
object[] GetKeys();
}
public interface IEntity<TKey> : IEntity
{
//
// 摘要:
// Unique identifier for this entity.
TKey Id { get; }
}
}

View File

@@ -0,0 +1,12 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Yi.Framework.Ddd.Services
{
public abstract class ApplicationService
{
}
}

View File

@@ -0,0 +1,12 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Yi.Framework.Ddd.Services
{
public interface IApplicationService
{
}
}

View File

@@ -7,7 +7,6 @@
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\Yi.Framework.AspNetCore\Yi.Framework.AspNetCore.csproj" />
<ProjectReference Include="..\Yi.Framework.Core\Yi.Framework.Core.csproj" />
</ItemGroup>