Files
zszq-trs/Framework/YLErp.Core/DBModels/Consts/ConsUserGroup.cs
T
2024-05-09 14:06:26 +08:00

83 lines
2.0 KiB
C#

namespace YLErp.DBModels.Consts
{
/// <summary>
/// 业务组常量
/// </summary>
public static class ConsUserGroup
{
public const string GroupA = "A";
public const string GroupB = "B";
public static readonly string DefaultGroup;
static readonly UserGroupItem[] userGroups;
static ConsUserGroup()
{
HasGroup = true;
if (PS.Config.Company == Configuration.CompanyEnum.宏源)
{
DefaultGroup = GroupA;
userGroups = new[] { new UserGroupItem("A", "团队A"), new UserGroupItem("B", "团队B") };
}
else
{
HasGroup = false;
userGroups = Array.Empty<UserGroupItem>();
}
}
/// <summary>
/// 获取所有用户组
/// </summary>
public static IEnumerable<UserGroupItem> GetGroups()
{
return userGroups;
}
/// <summary>
/// 是否包含用户组
/// </summary>
public static bool Contains(string userGroup)
{
return userGroups.Any(n => n.ItemValue == userGroup);
}
/// <summary>
/// 获取用户组描述
/// </summary>
public static string GetGroupDesc(string groupValue)
{
return userGroups.FirstOrDefault(n => n.ItemValue == groupValue)?.ItemDesc;
}
/// <summary>
/// 是否用户组选项
/// </summary>
public static bool HasGroup { get; private set; }
}
/// <summary>
/// 用户组选项
/// </summary>
public class UserGroupItem
{
public UserGroupItem(string itemValue, string itemDesc)
{
ItemValue = itemValue;
ItemDesc = itemDesc ?? itemValue;
}
/// <summary>
/// 值
/// </summary>
public string ItemValue { get; }
/// <summary>
/// 描述
/// </summary>
public string ItemDesc { get; }
}
}