MES登录接口设置
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace JY.Inspection.Enums
|
||||
{
|
||||
/// <summary>
|
||||
/// 用户权限
|
||||
/// </summary>
|
||||
public enum EnumAutority
|
||||
{
|
||||
/// <summary>
|
||||
/// 管理员
|
||||
/// </summary>
|
||||
[Description("管理员")]
|
||||
Administrator = 1,
|
||||
|
||||
/// <summary>
|
||||
/// 工程师
|
||||
/// </summary>
|
||||
[Description("工程师")]
|
||||
Engineer = 2,
|
||||
|
||||
/// <summary>
|
||||
/// 操作员
|
||||
/// </summary>
|
||||
[Description("操作员")]
|
||||
Operator = 3,
|
||||
|
||||
None = 4
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
using JY.Inspection.Common;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace JY.Inspection.Enums
|
||||
{
|
||||
public static class EnumExtension
|
||||
{
|
||||
// 输入枚举,获取其Description属性对应的名称
|
||||
public static string GetDescription(this Enum value)
|
||||
{
|
||||
FieldInfo field = value.GetType().GetField(value.ToString());
|
||||
if (field != null)
|
||||
{
|
||||
DescriptionAttribute attribute = Attribute.GetCustomAttribute(field, typeof(DescriptionAttribute)) as DescriptionAttribute;
|
||||
if (attribute != null)
|
||||
{
|
||||
return attribute.Description;
|
||||
}
|
||||
}
|
||||
return value.ToString();
|
||||
}
|
||||
|
||||
// 输入数字,转化成对应的枚举
|
||||
public static T ToEnum<T>(this int value)
|
||||
{
|
||||
return (T)Enum.ToObject(typeof(T), value);
|
||||
}
|
||||
|
||||
public static Autuority MapperEnum(this EnumAutority srcEnum)
|
||||
{
|
||||
switch (srcEnum)
|
||||
{
|
||||
case EnumAutority.Administrator:
|
||||
return Autuority.管理员;
|
||||
|
||||
case EnumAutority.Engineer:
|
||||
return Autuority.工程师;
|
||||
|
||||
case EnumAutority.Operator:
|
||||
return Autuority.操作员;
|
||||
|
||||
case EnumAutority.None:
|
||||
return Autuority.Empty;
|
||||
|
||||
default:
|
||||
return Autuority.Empty;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user