You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

152 lines
3.9 KiB

using BaseService.RelationBaseData;
using JetBrains.Annotations;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using Volo.Abp;
using Volo.Abp.Domain.Entities.Auditing;
using Volo.Abp.MultiTenancy;
namespace BaseService.BaseData
{
public class Branch : AuditedAggregateRoot<Guid>, ISoftDelete
{
public Guid? TenantId { get; set; }
/// <summary>
/// 机构分类:1.公司;2.组织;3.部门;4.供应商
/// </summary>
public short CategoryId { get; set; }
public Guid? Pid { get; set; }
public string Name { get; set; }
public string FullName { get; set; }
public int Sort { get; set; }
/// <summary>
/// 是否子集
/// </summary>
public bool Leaf { get; set; }
/// <summary>
/// 级联
/// </summary>
public string CascadeId { get; set; }
public bool Enabled { get; set; }
public bool IsDeleted { get; set; }
public virtual ICollection<BranchRole> Roles { get; set; }
public Branch(Guid id, Guid? tenantId, short categoryId, Guid? pid, [NotNull] string name, string fullName, int sort, bool leaf, bool enabled)
{
TenantId = tenantId;
Id = id;
CategoryId = categoryId;
Pid = pid;
Name = name;
FullName = fullName;
Sort = sort;
Enabled = enabled;
Leaf = leaf;
Roles = new Collection<BranchRole>();
}
public virtual void AddRole(Guid roleId)
{
Check.NotNull(roleId, nameof(roleId));
if (IsInRole(roleId))
{
return;
}
Roles.Add(new BranchRole(roleId, Id));
}
public virtual void RemoveRole(Guid roleId)
{
Check.NotNull(roleId, nameof(roleId));
if (!IsInRole(roleId))
{
return;
}
Roles.RemoveAll(r => r.RoleId == roleId);
}
public virtual bool IsInRole(Guid roleId)
{
Check.NotNull(roleId, nameof(roleId));
return Roles.Any(r => r.RoleId == roleId);
}
///// <summary>
///// 机构分类:1.公司;2.分支;3.部门;4.供应商
///// </summary>
//public short CategoryId { get; set; }
//public Guid? Pid { get; set; }
//public string Name { get; set; }
//public string FullName { get; set; }
//public int Sort { get; set; }
//public bool Enabled { get; set; }
//public bool IsDeleted { get; set; }
//public virtual ICollection<BranchRole> Roles { get; set; }
//public Branch(Guid id, short categoryId, Guid? pid, [NotNull] string name, string fullName, int sort, bool enabled)
//{
// Id = id;
// CategoryId = categoryId;
// Pid = pid;
// Name = name;
// FullName = fullName;
// Sort = sort;
// Enabled = enabled;
// Roles = new Collection<BranchRole>();
//}
//public virtual void AddRole(Guid roleId)
//{
// Check.NotNull(roleId, nameof(roleId));
// if (IsInRole(roleId))
// {
// return;
// }
// Roles.Add(new BranchRole(roleId, Id));
//}
//public virtual void RemoveRole(Guid roleId)
//{
// Check.NotNull(roleId, nameof(roleId));
// if (!IsInRole(roleId))
// {
// return;
// }
// Roles.RemoveAll(r => r.RoleId == roleId);
//}
//public virtual bool IsInRole(Guid roleId)
//{
// Check.NotNull(roleId, nameof(roleId));
// return Roles.Any(r => r.RoleId == roleId);
//}
}
}