代码整理
This commit is contained in:
parent
27e790ccf2
commit
df5ca0c84d
|
@ -226,9 +226,9 @@ namespace NewLife.Cube.Web
|
|||
var ids = GetRoles(client.Items, true).ToList();
|
||||
if (ids.Contains(roleId)) ids.Remove(roleId);
|
||||
if (ids.Count == 0)
|
||||
user2.RoleIDs = null;
|
||||
user2.RoleIds = null;
|
||||
else
|
||||
user2.RoleIDs = "," + ids.OrderBy(e => e).Join() + ",";
|
||||
user2.RoleIds = "," + ids.OrderBy(e => e).Join() + ",";
|
||||
}
|
||||
}
|
||||
// 使用本地角色
|
||||
|
@ -413,7 +413,7 @@ namespace NewLife.Cube.Web
|
|||
code = user2.Code,
|
||||
roleid = user2.RoleID,
|
||||
rolename = user2.RoleName,
|
||||
roleids = user2.RoleIDs,
|
||||
roleids = user2.RoleIds,
|
||||
rolenames = user2.Roles.Skip(1).Join(",", e => e + ""),
|
||||
avatar = user2.Avatar,
|
||||
detail = user2.Remark,
|
||||
|
|
|
@ -24,15 +24,12 @@ namespace NewLife.Cube
|
|||
/// <summary>授权项</summary>
|
||||
public PermissionFlags Permission { get; }
|
||||
|
||||
/// <summary>是否全局特性</summary>
|
||||
internal Boolean IsGlobal;
|
||||
///// <summary>是否全局特性</summary>
|
||||
//internal Boolean IsGlobal;
|
||||
#endregion
|
||||
|
||||
#region 构造
|
||||
static EntityAuthorizeAttribute()
|
||||
{
|
||||
XTrace.WriteLine("注册过滤器:{0}", typeof(EntityAuthorizeAttribute).FullName);
|
||||
}
|
||||
static EntityAuthorizeAttribute() => XTrace.WriteLine("注册过滤器:{0}", typeof(EntityAuthorizeAttribute).FullName);
|
||||
|
||||
/// <summary>实例化实体授权特性</summary>
|
||||
public EntityAuthorizeAttribute() { }
|
||||
|
@ -70,7 +67,7 @@ namespace NewLife.Cube
|
|||
ctrl.MethodInfo.IsDefined(typeof(EntityAuthorizeAttribute), true) ||
|
||||
ctrl.ControllerTypeInfo.IsDefined(typeof(EntityAuthorizeAttribute));
|
||||
|
||||
if (IsGlobal && hasAtt) return;
|
||||
//if (IsGlobal && hasAtt) return;
|
||||
|
||||
// 只验证管辖范围
|
||||
var create = false;
|
||||
|
@ -212,7 +209,7 @@ namespace NewLife.Cube
|
|||
return menu;
|
||||
}
|
||||
|
||||
private static ConcurrentDictionary<String, Type> _ss = new ConcurrentDictionary<String, Type>();
|
||||
private static readonly ConcurrentDictionary<String, Type> _ss = new ConcurrentDictionary<String, Type>();
|
||||
private Boolean CreateMenu(Type type)
|
||||
{
|
||||
if (!_ss.TryAdd(type.Namespace, type)) return false;
|
||||
|
@ -237,7 +234,7 @@ namespace NewLife.Cube
|
|||
if (ctype == null) continue;
|
||||
|
||||
// 添加该类型下的所有Action
|
||||
var dic = new Dictionary<MethodInfo, Int32>();
|
||||
//var dic = new Dictionary<MethodInfo, Int32>();
|
||||
foreach (var method in ctype.GetMethods())
|
||||
{
|
||||
if (method.IsStatic || !method.IsPublic) continue;
|
||||
|
|
|
@ -104,13 +104,13 @@ namespace NewLife.Cube
|
|||
|
||||
private static IHtmlContent ForTreeEditor(IHtmlHelper Html, FieldItem field, IEntityTree entity)
|
||||
{
|
||||
var fact = EntityFactory.CreateOperate(entity.GetType());
|
||||
//var fact = EntityFactory.CreateOperate(entity.GetType());
|
||||
var set = entity.GetType().GetValue("Setting") as IEntityTreeSetting;
|
||||
if (set == null || set.Parent != field.Name) return null;
|
||||
|
||||
var root = entity.GetType().GetValue("Root") as IEntityTree;
|
||||
// 找到完整菜单树,但是排除当前节点这个分支
|
||||
var list = root.FindAllChildsExcept(entity as IEntityTree);
|
||||
var list = root.FindAllChildsExcept(entity);
|
||||
var data = new SelectList(list, set.Key, "TreeNodeText", entity[field.Name]);
|
||||
return Html.DropDownList(field.Name, data, new { @class = "multiselect" });
|
||||
}
|
||||
|
@ -138,8 +138,7 @@ namespace NewLife.Cube
|
|||
// 表单页的映射下拉,开头增加无效值选项
|
||||
if (fact != null && !map.Provider.Key.IsNullOrEmpty())
|
||||
{
|
||||
var fi = fact.Table.FindByName(map.Provider.Key) as FieldItem;
|
||||
if (fi != null && fi.Type.IsInt())
|
||||
if (fact.Table.FindByName(map.Provider.Key) is FieldItem fi && fi.Type.IsInt())
|
||||
{
|
||||
var dic2 = new Dictionary<Object, String>();
|
||||
if (!dic.ContainsKey(-1))
|
||||
|
@ -227,7 +226,7 @@ namespace NewLife.Cube
|
|||
// 首先输出图标
|
||||
var ico = "";
|
||||
|
||||
IHtmlContent txt = null;
|
||||
IHtmlContent txt;
|
||||
if (name.EqualIgnoreCase("Pass", "Password"))
|
||||
{
|
||||
txt = Html.Password(name, value, atts);
|
||||
|
@ -457,6 +456,12 @@ namespace NewLife.Cube
|
|||
return Html.ForListBox(name, dic, values, autoPostback);
|
||||
}
|
||||
|
||||
/// <summary>文件上传</summary>
|
||||
/// <param name="Html"></param>
|
||||
/// <param name="name"></param>
|
||||
/// <param name="value"></param>
|
||||
/// <param name="itemType"></param>
|
||||
/// <returns></returns>
|
||||
public static IHtmlContent ForFile(this IHtmlHelper Html, String name, Object value, String itemType)
|
||||
{
|
||||
var accept = "";
|
||||
|
@ -478,7 +483,7 @@ namespace NewLife.Cube
|
|||
/// <returns></returns>
|
||||
public static IHtmlContent ForDropDownList(this IHtmlHelper Html, String name, IEnumerable items, Object selectedValue = null, String optionLabel = null, Boolean autoPostback = false)
|
||||
{
|
||||
SelectList data = null;
|
||||
SelectList data;
|
||||
if (items is IDictionary)
|
||||
data = new SelectList(items, "Key", "Value", selectedValue);
|
||||
else
|
||||
|
@ -561,8 +566,7 @@ namespace NewLife.Cube
|
|||
/// <returns></returns>
|
||||
public static IHtmlContent ForListBox(this IHtmlHelper Html, String name, IList<IEntity> list, Boolean autoPostback = false)
|
||||
{
|
||||
var entity = Html.ViewData.Model as IEntity;
|
||||
var vs = entity == null ? WebHelper2.Params[name] : entity[name];
|
||||
var vs = Html.ViewData.Model is IEntity entity ? entity[name] : WebHelper2.Params[name];
|
||||
// 如果是字符串,分割为整型数组,全局约定逗号分割
|
||||
if (vs is String) vs = (vs as String).SplitAsInt();
|
||||
|
||||
|
|
|
@ -1,17 +1,17 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace NewLife.Cube.ViewModels
|
||||
{
|
||||
/// <summary>错误模型</summary>
|
||||
public class ErrorModel
|
||||
{
|
||||
/// <summary>请求标识</summary>
|
||||
public String RequestId { get; set; }
|
||||
|
||||
/// <summary>资源地址</summary>
|
||||
public Uri Uri { get; set; }
|
||||
|
||||
/// <summary>异常信息</summary>
|
||||
public Exception Exception { get; set; }
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue