init
This commit is contained in:
15
DouyinApi.Model/Tenants/ITenantEntity.cs
Normal file
15
DouyinApi.Model/Tenants/ITenantEntity.cs
Normal file
@@ -0,0 +1,15 @@
|
||||
using SqlSugar;
|
||||
|
||||
namespace DouyinApi.Model.Tenants;
|
||||
|
||||
/// <summary>
|
||||
/// 租户模型接口
|
||||
/// </summary>
|
||||
public interface ITenantEntity
|
||||
{
|
||||
/// <summary>
|
||||
/// 租户Id
|
||||
/// </summary>
|
||||
[SugarColumn(DefaultValue = "0")]
|
||||
public long TenantId { get; set; }
|
||||
}
|
||||
24
DouyinApi.Model/Tenants/MultiTenantAttribute.cs
Normal file
24
DouyinApi.Model/Tenants/MultiTenantAttribute.cs
Normal file
@@ -0,0 +1,24 @@
|
||||
using System;
|
||||
|
||||
namespace DouyinApi.Model.Tenants;
|
||||
|
||||
/// <summary>
|
||||
/// 标识 多租户 的业务表 <br/>
|
||||
/// 默认设置是多库 <br/>
|
||||
/// 公共表无需区分 直接使用主库 各自业务在各自库中 <br/>
|
||||
/// </summary>
|
||||
[AttributeUsage(AttributeTargets.Class)]
|
||||
public class MultiTenantAttribute : Attribute
|
||||
{
|
||||
public MultiTenantAttribute()
|
||||
{
|
||||
}
|
||||
|
||||
public MultiTenantAttribute(TenantTypeEnum tenantType)
|
||||
{
|
||||
TenantType = tenantType;
|
||||
}
|
||||
|
||||
|
||||
public TenantTypeEnum TenantType { get; set; } = TenantTypeEnum.Db;
|
||||
}
|
||||
29
DouyinApi.Model/Tenants/TenantTypeEnum.cs
Normal file
29
DouyinApi.Model/Tenants/TenantTypeEnum.cs
Normal file
@@ -0,0 +1,29 @@
|
||||
using System.ComponentModel;
|
||||
|
||||
namespace DouyinApi.Model.Tenants;
|
||||
|
||||
/// <summary>
|
||||
/// 租户隔离方案
|
||||
/// </summary>
|
||||
public enum TenantTypeEnum
|
||||
{
|
||||
None = 0,
|
||||
|
||||
/// <summary>
|
||||
/// Id隔离
|
||||
/// </summary>
|
||||
[Description("Id隔离")]
|
||||
Id = 1,
|
||||
|
||||
/// <summary>
|
||||
/// 库隔离
|
||||
/// </summary>
|
||||
[Description("库隔离")]
|
||||
Db = 2,
|
||||
|
||||
/// <summary>
|
||||
/// 表隔离
|
||||
/// </summary>
|
||||
[Description("表隔离")]
|
||||
Tables = 3,
|
||||
}
|
||||
Reference in New Issue
Block a user