mirror of
https://gitee.com/ccnetcore/Yi
synced 2026-03-20 16:36:37 +08:00
完善ddd模块及错误异常中间件
This commit is contained in:
@@ -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 + "]";
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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; }
|
||||
}
|
||||
}
|
||||
@@ -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}";
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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; }
|
||||
}
|
||||
}
|
||||
@@ -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
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -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
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -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>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user