mirror of
https://gitee.com/dotnetchina/OpenAuth.Net.git
synced 2025-09-20 10:37:55 +08:00
1 完成用户部门权限分配处理,可以为用户分配可见部门,如果没有任何可见部门,则只能查看自己有关的数据;
2 完善进出库实例; 3 添加CodeSmith生成EF DbContext Entity Mapping;
This commit is contained in:
@@ -3,7 +3,10 @@ using OpenAuth.App;
|
||||
using OpenAuth.Domain;
|
||||
using OpenAuth.Mvc.Models;
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Web.Mvc;
|
||||
using Infrastructure.Helper;
|
||||
using OpenAuth.App.ViewModel;
|
||||
|
||||
namespace OpenAuth.Mvc.Controllers
|
||||
{
|
||||
@@ -23,6 +26,20 @@ namespace OpenAuth.Mvc.Controllers
|
||||
return View();
|
||||
}
|
||||
|
||||
//用于选择模块时使用
|
||||
public ActionResult LookUpMultiForUser(int userId)
|
||||
{
|
||||
ViewBag.UserId = userId;
|
||||
return View();
|
||||
}
|
||||
|
||||
//为角色分配模块
|
||||
public ActionResult LookupMultiForRole(int roleId)
|
||||
{
|
||||
ViewBag.RoleId = roleId;
|
||||
return View();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 选择上级机构页面
|
||||
/// </summary>
|
||||
@@ -37,6 +54,86 @@ namespace OpenAuth.Mvc.Controllers
|
||||
return View();
|
||||
}
|
||||
|
||||
public string LoadForTree()
|
||||
{
|
||||
var orgs = SessionHelper.GetSessionUser<LoginUserVM>().AccessedOrgs;
|
||||
return JsonHelper.Instance.Serialize(orgs);
|
||||
}
|
||||
|
||||
public string LoadOrgWithRoot()
|
||||
{
|
||||
var orgs = SessionHelper.GetSessionUser<LoginUserVM>().AccessedOrgs;
|
||||
//添加根节点
|
||||
orgs.Add(new Org
|
||||
{
|
||||
Id = 0,
|
||||
ParentId = -1,
|
||||
Name = "根节点",
|
||||
CascadeId = "0"
|
||||
});
|
||||
return JsonHelper.Instance.Serialize(orgs);
|
||||
}
|
||||
|
||||
public string LoadForUser(int userId)
|
||||
{
|
||||
var orgs = _orgApp.LoadForUser(userId);
|
||||
//添加根节点
|
||||
orgs.Add(new Org
|
||||
{
|
||||
Id = 0,
|
||||
ParentId = -1,
|
||||
Name = "用户及角色可访问的部门",
|
||||
CascadeId = "0"
|
||||
});
|
||||
return JsonHelper.Instance.Serialize(orgs);
|
||||
}
|
||||
|
||||
public string LoadForRole(int roleId)
|
||||
{
|
||||
var orgs = _orgApp.LoadForRole(roleId);
|
||||
//添加根节点
|
||||
orgs.Add(new Org
|
||||
{
|
||||
Id = 0,
|
||||
ParentId = -1,
|
||||
Name = "已为角色分配的可访问部门",
|
||||
CascadeId = "0"
|
||||
});
|
||||
return JsonHelper.Instance.Serialize(orgs);
|
||||
}
|
||||
|
||||
public string AssignOrgForRole(int roleId, string moduleIds)
|
||||
{
|
||||
try
|
||||
{
|
||||
var ids = moduleIds.Split(',').Select(id => int.Parse(id)).ToArray();
|
||||
_orgApp.AssignModuleForRole(roleId, ids);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
BjuiResponse.message = e.Message;
|
||||
BjuiResponse.statusCode = "300";
|
||||
}
|
||||
|
||||
return JsonHelper.Instance.Serialize(BjuiResponse);
|
||||
}
|
||||
|
||||
public string AssignOrgForUser(int userId, string moduleIds)
|
||||
{
|
||||
try
|
||||
{
|
||||
var ids = moduleIds.Split(',').Select(id => int.Parse(id)).ToArray();
|
||||
_orgApp.AssignModuleForUser(userId, ids);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
BjuiResponse.message = e.Message;
|
||||
BjuiResponse.statusCode = "300";
|
||||
}
|
||||
|
||||
return JsonHelper.Instance.Serialize(BjuiResponse);
|
||||
}
|
||||
|
||||
//添加组织提交
|
||||
[HttpPost]
|
||||
public string AddOrg(Org org)
|
||||
|
82
OpenAuth.Mvc/Controllers/StockManagerController.cs
Normal file
82
OpenAuth.Mvc/Controllers/StockManagerController.cs
Normal file
@@ -0,0 +1,82 @@
|
||||
using Infrastructure;
|
||||
using OpenAuth.App;
|
||||
using OpenAuth.Domain;
|
||||
using System;
|
||||
using System.Web.Mvc;
|
||||
|
||||
namespace OpenAuth.Mvc.Controllers
|
||||
{
|
||||
public class StockManagerController : BaseController
|
||||
{
|
||||
private StockManagerApp _app;
|
||||
|
||||
public StockManagerController()
|
||||
{
|
||||
_app = AutofacExt.GetFromFac<StockManagerApp>();
|
||||
}
|
||||
|
||||
//
|
||||
// GET: /UserManager/
|
||||
public ActionResult Index()
|
||||
{
|
||||
return View();
|
||||
}
|
||||
|
||||
public ActionResult Add(int id = 0)
|
||||
{
|
||||
return View(_app.Find(id));
|
||||
}
|
||||
|
||||
//添加或修改Stock
|
||||
[HttpPost]
|
||||
public string Add(Stock model)
|
||||
{
|
||||
try
|
||||
{
|
||||
_app.AddOrUpdate(model);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
BjuiResponse.statusCode = "300";
|
||||
BjuiResponse.message = ex.Message;
|
||||
}
|
||||
return JsonHelper.Instance.Serialize(BjuiResponse);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 加载节点下面的所有Stocks
|
||||
/// </summary>
|
||||
public string Load(int parentidId, int pageCurrent = 1, int pageSize = 30)
|
||||
{
|
||||
return JsonHelper.Instance.Serialize(_app.Load(parentidId, 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
|
||||
{
|
||||
_app.Delete(Id);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
BjuiResponse.statusCode = "300";
|
||||
BjuiResponse.message = e.Message;
|
||||
}
|
||||
|
||||
return JsonHelper.Instance.Serialize(BjuiResponse);
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user