44 lines
1012 B
C#
44 lines
1012 B
C#
using System;
|
|
using Volo.Abp.Domain.Entities.Auditing;
|
|
|
|
namespace KonSoft.Admin.Entities;
|
|
|
|
public class ServiceCategory : FullAuditedAggregateRoot<Guid>
|
|
{
|
|
protected ServiceCategory()
|
|
{
|
|
}
|
|
|
|
public ServiceCategory(Guid id, string name)
|
|
: base(id)
|
|
{
|
|
Name = name;
|
|
}
|
|
|
|
public ServiceCategory(Guid id, string name, Guid? parentId = null, string path = null, int level = 0) : base(id)
|
|
{
|
|
Name = name;
|
|
ParentId = parentId;
|
|
Path = path ?? id.ToString();
|
|
Level = level;
|
|
}
|
|
|
|
public string Name { get; private set; }
|
|
public Guid? ParentId { get; private set; }
|
|
public string Path { get; private set; }
|
|
public int Level { get; private set; }
|
|
|
|
|
|
public void UpdateName(string name)
|
|
{
|
|
Name = name;
|
|
}
|
|
|
|
|
|
public void SetParent(ServiceCategory parent)
|
|
{
|
|
ParentId = parent?.Id;
|
|
Level = (parent?.Level ?? 0) + 1;
|
|
Path = parent != null ? $"{parent.Path}/{Id}" : Id.ToString();
|
|
}
|
|
} |