1.0 beta版

1 完成进出库实例Stock;
2 全面实现组织数据分离,参考Stock实例;
3 全新的基于CodeSmith EF生成机制;
4 全面完成菜单授权;
5 增加Anonymous机制,可以灵活控制Action是否需要权限控制;
This commit is contained in:
yubaolee
2016-01-08 12:53:48 +08:00
parent 5317e07ae5
commit ab3fc27301
17 changed files with 139 additions and 132 deletions

View File

@@ -15,7 +15,9 @@
using Infrastructure.Helper;
using OpenAuth.App.ViewModel;
using OpenAuth.Mvc.Models;
using System;
using System.Linq;
using System.Reflection;
using System.Web.Mvc;
namespace OpenAuth.Mvc.Controllers
@@ -36,8 +38,15 @@ namespace OpenAuth.Mvc.Controllers
if (controllername != "home") //主页控制器无需权限控制
{
var actionname = Request.RequestContext.RouteData.Values["action"].ToString();
var function = this.GetType().GetMethods().FirstOrDefault(u => u.Name == actionname);
if (function == null)
throw new Exception("未能找到Action");
var anonymous = function.GetCustomAttribute(typeof(AnonymousAttribute));
var module = loginUser.Modules.FirstOrDefault(u => u.Url.ToLower().Contains(controllername));
if (module == null)
if (module == null && anonymous == null)
{
filterContext.Result = new RedirectResult("/Login/Index");
return;

View File

@@ -60,6 +60,7 @@ namespace OpenAuth.Mvc.Controllers
var orgs = SessionHelper.GetSessionUser<LoginUserVM>().AccessedOrgs;
return JsonHelper.Instance.Serialize(orgs);
}
[Anonymous]
public string LoadOrg()
{
var orgs = SessionHelper.GetSessionUser<LoginUserVM>().AccessedOrgs.MapToList<Org>();

View File

@@ -3,6 +3,8 @@ using OpenAuth.App;
using OpenAuth.Domain;
using System;
using System.Web.Mvc;
using Infrastructure.Helper;
using OpenAuth.App.ViewModel;
namespace OpenAuth.Mvc.Controllers
{
@@ -33,7 +35,10 @@ namespace OpenAuth.Mvc.Controllers
{
try
{
_app.AddOrUpdate(model);
var newmodel = new Stock();
model.CopyTo(newmodel);
newmodel.User = SessionHelper.GetSessionUser<LoginUserVM>().User.Account;
_app.AddOrUpdate(newmodel);
}
catch (Exception ex)
{
@@ -46,24 +51,11 @@ namespace OpenAuth.Mvc.Controllers
/// <summary>
/// 加载节点下面的所有Stocks
/// </summary>
public string Load(int parentidId, int pageCurrent = 1, int pageSize = 30)
public string Load(int parentId, int pageCurrent = 1, int pageSize = 30)
{
return JsonHelper.Instance.Serialize(_app.Load(parentidId, pageCurrent, pageSize));
return JsonHelper.Instance.Serialize(_app.Load(parentId, pageCurrent, pageSize));
}
public string LoadForTree()
{
var models = _app.LoadAll();
//添加根节点
models.Add(new Stock
{
Id = 0,
OrgId = -1,
Name = "根结点",
});
return JsonHelper.Instance.Serialize(models);
}
public string Delete(int Id)
{
try