namespace YLErp.DBModels.Consts
{
///
/// 业务组常量
///
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();
}
}
///
/// 获取所有用户组
///
public static IEnumerable GetGroups()
{
return userGroups;
}
///
/// 是否包含用户组
///
public static bool Contains(string userGroup)
{
return userGroups.Any(n => n.ItemValue == userGroup);
}
///
/// 获取用户组描述
///
public static string GetGroupDesc(string groupValue)
{
return userGroups.FirstOrDefault(n => n.ItemValue == groupValue)?.ItemDesc;
}
///
/// 是否用户组选项
///
public static bool HasGroup { get; private set; }
}
///
/// 用户组选项
///
public class UserGroupItem
{
public UserGroupItem(string itemValue, string itemDesc)
{
ItemValue = itemValue;
ItemDesc = itemDesc ?? itemValue;
}
///
/// 值
///
public string ItemValue { get; }
///
/// 描述
///
public string ItemDesc { get; }
}
}