71 lines
2.3 KiB
C#
71 lines
2.3 KiB
C#
using FreeSql.DataAnnotations;
|
|
using F9WebAiTest.Domain.Events.SYS.Registries;
|
|
|
|
namespace F9WebAiTest.Domain.Entities.SYS.Registries;
|
|
|
|
/// <summary>
|
|
/// 注册表(参数配置):按"命名空间 + 键名"存一条配置值,供各业务模块读取(如基础数据\工种 → 业务类型)。
|
|
/// 命名空间用反斜杠分层,如 "基础数据\工种"。
|
|
/// </summary>
|
|
[Table(Name = "sys_registry")]
|
|
public class Registry : AggregateRoot
|
|
{
|
|
/// <summary>命名空间(分类,用 \ 分层)</summary>
|
|
[Column(Name = "category")]
|
|
public string Category { get; private set; }
|
|
|
|
/// <summary>键名</summary>
|
|
[Column(Name = "key_name")]
|
|
public string KeyName { get; private set; }
|
|
|
|
/// <summary>值(数组类型存逗号分隔字符串,json 类型存 JSON 文本)</summary>
|
|
[Column(Name = "value")]
|
|
public string Value { get; private set; }
|
|
|
|
/// <summary>数据类型:string / int / decimal / bool / json / array</summary>
|
|
[Column(Name = "data_type")]
|
|
public string DataType { get; private set; }
|
|
|
|
/// <summary>描述</summary>
|
|
[Column(Name = "description")]
|
|
public string Description { get; private set; }
|
|
|
|
/// <summary>是否启用</summary>
|
|
[Column(Name = "is_active")]
|
|
public bool IsActive { get; private set; }
|
|
|
|
public Registry() { }
|
|
|
|
public Registry(long id, string category, string keyName, string value, string dataType, string description, bool isActive)
|
|
{
|
|
Id = id;
|
|
Category = category;
|
|
KeyName = keyName;
|
|
Value = value;
|
|
DataType = dataType;
|
|
Description = description;
|
|
IsActive = isActive;
|
|
AddDomainEvent(new Registry_ChangedDomainEvent(Id));
|
|
}
|
|
|
|
public void Update(string category, string keyName, string value, string dataType, string description, bool isActive)
|
|
{
|
|
Category = category;
|
|
KeyName = keyName;
|
|
Value = value;
|
|
DataType = dataType;
|
|
Description = description;
|
|
IsActive = isActive;
|
|
AddDomainEvent(new Registry_ChangedDomainEvent(Id));
|
|
}
|
|
|
|
/// <summary>只修改值(对应"设置注册表值"场景)</summary>
|
|
public void SetValue(string value)
|
|
{
|
|
Value = value;
|
|
AddDomainEvent(new Registry_ChangedDomainEvent(Id));
|
|
}
|
|
|
|
public void Deleted() => AddDomainEvent(new Registry_ChangedDomainEvent(Id));
|
|
}
|