!提交代码
This commit is contained in:
12
WCS.Model/ApiModel/User/AddRoleRequest.cs
Normal file
12
WCS.Model/ApiModel/User/AddRoleRequest.cs
Normal file
@ -0,0 +1,12 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace WCS.Model.ApiModel.User
|
||||
{
|
||||
public class AddRoleRequest<T> : RequestBase
|
||||
{
|
||||
public T Role { get; set; }
|
||||
public AddOrUpdate AddOrUpdate { get; set; }
|
||||
}
|
||||
}
|
19
WCS.Model/ApiModel/User/AddUserRequest.cs
Normal file
19
WCS.Model/ApiModel/User/AddUserRequest.cs
Normal file
@ -0,0 +1,19 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace WCS.Model.ApiModel.User
|
||||
{
|
||||
public class AddUserRequest<T> : RequestBase
|
||||
{
|
||||
public T User { get; set; }
|
||||
public AddOrUpdate AddOrUpdate { get; set; }
|
||||
}
|
||||
|
||||
public enum AddOrUpdate
|
||||
{
|
||||
Add = 0,
|
||||
Update = 1,
|
||||
Delete = 2
|
||||
}
|
||||
}
|
58
WCS.Model/ApiModel/User/AuthEnum.cs
Normal file
58
WCS.Model/ApiModel/User/AuthEnum.cs
Normal file
@ -0,0 +1,58 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace WCS.Model.ApiModel
|
||||
{
|
||||
/// <summary>
|
||||
/// 认证项
|
||||
/// </summary>
|
||||
public enum AuthEnum
|
||||
{
|
||||
/* 注意:枚举的值必须大于0 */
|
||||
查询 = 1000,
|
||||
权限 = 2000,
|
||||
//[Description("用户")]
|
||||
//[EnumTree(权限, new[] { 用户新增, 用户删除, 用户修改 })]
|
||||
//用户管理 = 3100, 用户新增 = 3110, 用户删除, 用户修改,
|
||||
//[Description("角色")]
|
||||
//[EnumTree(权限, new[] { 角色新增, 角色删除, 角色修改 })]
|
||||
//角色管理 = 3200, 角色新增 = 3210, 角色删除, 角色修改,
|
||||
设置 = 3000,
|
||||
调试 = 4000,
|
||||
}
|
||||
|
||||
public class EnumTreeAttribute : Attribute
|
||||
{
|
||||
public EnumTreeAttribute() { }
|
||||
|
||||
public EnumTreeAttribute(AuthEnum parent)
|
||||
{
|
||||
Parent = parent;
|
||||
}
|
||||
|
||||
public EnumTreeAttribute(AuthEnum[] childs)
|
||||
{
|
||||
Childs = childs;
|
||||
}
|
||||
|
||||
public EnumTreeAttribute(AuthEnum parent, AuthEnum[] childs)
|
||||
{
|
||||
Parent = parent;
|
||||
Childs = childs;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 父级
|
||||
/// </summary>
|
||||
public AuthEnum? Parent { get; set; } = null;
|
||||
/// <summary>
|
||||
/// 子级
|
||||
/// </summary>
|
||||
public AuthEnum[]? Childs { get; set; } = null;
|
||||
}
|
||||
}
|
59
WCS.Model/ApiModel/User/AuthModels.cs
Normal file
59
WCS.Model/ApiModel/User/AuthModels.cs
Normal file
@ -0,0 +1,59 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace WCS.Model.ApiModel
|
||||
{
|
||||
|
||||
public class UserModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
/// <summary>
|
||||
/// 登录名
|
||||
/// </summary>
|
||||
public string LoginName { get; set; }
|
||||
/// <summary>
|
||||
/// 密码
|
||||
/// </summary>
|
||||
public string Password { get; set; }
|
||||
|
||||
public List<int> RoleIds { get; set; } = new List<int>();
|
||||
|
||||
public List<string> RoleNames { get; set; }
|
||||
/// <summary>
|
||||
/// 是否最大权限
|
||||
/// </summary>
|
||||
public bool IsAdmin { get; set; }
|
||||
/// <summary>
|
||||
/// 创建时间
|
||||
/// </summary>
|
||||
public DateTime Time { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 用户拥有的权限
|
||||
/// </summary>
|
||||
public List<RoleModel> GetRoles { get; set; }
|
||||
}
|
||||
public class RoleModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
/// <summary>
|
||||
/// 角色名
|
||||
/// </summary>
|
||||
public string Name { get; set; }
|
||||
|
||||
public List<int> Auths { get; set; } = new List<int>();
|
||||
|
||||
public List<string> AuthNames { get => (Auths == null || !Auths.Any()) ? new List<string>() : EnumHelps.GetEnumDescriptionList(typeof(AuthEnum), true).Where(o => Auths.Contains(o.Item1)).Select(o => o.Item3).ToList(); }
|
||||
/// <summary>
|
||||
/// 是否最大权限
|
||||
/// </summary>
|
||||
public bool IsAdmin { get; set; }
|
||||
/// <summary>
|
||||
/// 创建时间
|
||||
/// </summary>
|
||||
public DateTime Time { get; set; }
|
||||
}
|
||||
|
||||
}
|
68
WCS.Model/ApiModel/User/EnumHelps.cs
Normal file
68
WCS.Model/ApiModel/User/EnumHelps.cs
Normal file
@ -0,0 +1,68 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
|
||||
namespace WCS.Model.ApiModel
|
||||
{
|
||||
public static class EnumHelps
|
||||
{
|
||||
public static List<string> GetEnumList(Type type)
|
||||
{
|
||||
List<string> strings = new List<string>();
|
||||
if (type.IsEnum)
|
||||
{
|
||||
var fields = type.GetFields(BindingFlags.Static | BindingFlags.Public) ?? new FieldInfo[] { };
|
||||
foreach (var field in fields)
|
||||
{
|
||||
strings.Add(field.Name);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
return strings;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 得到枚举详情
|
||||
/// </summary>
|
||||
/// <param name="type">枚举</param>
|
||||
/// <param name="isDescriptionNullInName">描述为空时,是否采用名称值</param>
|
||||
/// <returns>枚举值,名称,描述</returns>
|
||||
public static List<Tuple<int, string, string>> GetEnumDescriptionList(Type type, bool isDescriptionNullInName = false)
|
||||
{
|
||||
var strings = new List<Tuple<int, string, string>>();
|
||||
if (type.IsEnum)
|
||||
{
|
||||
var fields = type.GetFields(BindingFlags.Static | BindingFlags.Public);
|
||||
if (fields == null)
|
||||
return strings;
|
||||
|
||||
foreach (var field in fields)
|
||||
{
|
||||
int enumValue = Convert.ToInt32(field.GetRawConstantValue());
|
||||
string enumName = field.Name;
|
||||
string description = string.Empty;
|
||||
|
||||
var descriptionAttribute = field.GetCustomAttribute<DescriptionAttribute>(false);
|
||||
if (descriptionAttribute != null)
|
||||
description = descriptionAttribute.Description;
|
||||
else if (isDescriptionNullInName)
|
||||
description = enumName;
|
||||
|
||||
strings.Add(new Tuple<int, string, string>(enumValue, enumName, description));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
return strings;
|
||||
}
|
||||
}
|
||||
}
|
11
WCS.Model/ApiModel/User/GetUsersRequest.cs
Normal file
11
WCS.Model/ApiModel/User/GetUsersRequest.cs
Normal file
@ -0,0 +1,11 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace WCS.Model.ApiModel.User
|
||||
{
|
||||
public class GetUsersRequest : RequestBase
|
||||
{
|
||||
public string Info { get; set; }
|
||||
}
|
||||
}
|
18
WCS.Model/ApiModel/User/UserLoginRequest.cs
Normal file
18
WCS.Model/ApiModel/User/UserLoginRequest.cs
Normal file
@ -0,0 +1,18 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace WCS.Model.ApiModel.User
|
||||
{
|
||||
public class UserLoginRequest : RequestBase
|
||||
{
|
||||
/// <summary>
|
||||
/// 密码
|
||||
/// </summary>
|
||||
public string PassWord { get; set; }
|
||||
/// <summary>
|
||||
/// 是否配置为不登陆(如果不登陆 直接获取admin 且不验证密码了)
|
||||
/// </summary>
|
||||
public bool IsNoLogin { get; set; } = false;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user