diff --git a/AMESCoreStudio.Web/Controllers/HomeController.cs b/AMESCoreStudio.Web/Controllers/HomeController.cs
index 9d840595..d1f7ed11 100644
--- a/AMESCoreStudio.Web/Controllers/HomeController.cs
+++ b/AMESCoreStudio.Web/Controllers/HomeController.cs
@@ -9,6 +9,8 @@ using System.Threading.Tasks;
using AMESCoreStudio.WebApi;
using Microsoft.AspNetCore.Authorization;
using Microsoft.Extensions.Localization;
+using Newtonsoft.Json;
+using Newtonsoft.Json.Linq;
namespace AMESCoreStudio.Web.Controllers
{
@@ -60,6 +62,91 @@ namespace AMESCoreStudio.Web.Controllers
int role_id = userRole.Data.ToList()[0].RoleID;
+ //var userModule = await _sysApi.GetRoleModulesByRole(role_id, 0, 10);
+ //var userProgram = await _sysApi.GetRoleProgramsByRole(role_id, 0, 10);
+
+ var userModule = await _sysApi.GetRoleModulesByUser(user_id, 0, 10);
+ var userProgram = await _sysApi.GetRoleProgramsByUser(user_id, 0, 10);
+
+ string menuData = "
";
+
+ int i = 0;
+ foreach (var user_module in userModule.Data)
+ {
+ JObject jo1 = JObject.Parse(user_module.ToString());
+ int module_id = int.Parse(jo1["moduleID"].ToString());
+ i = i + 1;
+ if (i == 0)
+ {
+ menuData = menuData + "- ";
+ }
+ else
+ {
+ menuData = menuData + "
- ";
+ }
+
+ if (user_module != null)
+ {
+ menuData = menuData + "";
+ menuData = menuData + " " + jo1["moduleName"].ToString() + " ";
+ menuData = menuData + "";
+ menuData = menuData + "";
+ menuData = menuData + "
";
+ }
+ menuData = menuData + "
";
+
+ ViewData["MenuList"] = menuData;
+
+ return View();
+ }
+ }
+ else
+ {
+ return RedirectToAction("Index", "Login");
+ }
+ }
+ return View();
+ //return RedirectToAction("Index", "Login");
+ }
+
+ ///
+ ///
+ ///
+ ///
+ public async Task Framework1()
+ {
+ var info = await _authApi.AuthInfo();
+
+ if (Request.Cookies["_AMESCookie"] != null)
+ {
+ var userID = "";
+ HttpContext.Request.Cookies.TryGetValue("UserID", out userID);
+ if (userID != null)
+ {
+ if (int.Parse(userID.ToString()) >= 0)
+ {
+ int user_id = int.Parse(userID.ToString());
+ var userRole = await _sysApi.GetUserRolesByUser(user_id);
+
+ int role_id = userRole.Data.ToList()[0].RoleID;
+
var userModule = await _sysApi.GetRoleModulesByRole(role_id, 0, 10);
var userProgram = await _sysApi.GetRoleProgramsByRole(role_id, 0, 10);
diff --git a/AMESCoreStudio.Web/HttpApis/ISYS.cs b/AMESCoreStudio.Web/HttpApis/ISYS.cs
index b352bd3a..5e306334 100644
--- a/AMESCoreStudio.Web/HttpApis/ISYS.cs
+++ b/AMESCoreStudio.Web/HttpApis/ISYS.cs
@@ -225,6 +225,13 @@ namespace AMESCoreStudio.Web
[WebApiClient.Attributes.HttpGet("api/RoleModules")]
ITask> GetRoleModules();
+ ///
+ /// 根据用户ID獲取所有角色模组資料
+ ///
+ ///
+ [WebApiClient.Attributes.HttpGet("api/RoleModules/User/{id}")]
+ ITask> GetRoleModulesByUser(int id, int page = 0, int limit = 10);
+
///
/// 根据角色ID獲取角色模组資料
///
@@ -271,6 +278,13 @@ namespace AMESCoreStudio.Web
[WebApiClient.Attributes.HttpGet("api/RolePrograms")]
ITask> GetRolePrograms();
+ ///
+ /// 根据用户ID獲取所有角色功能資料
+ ///
+ ///
+ [WebApiClient.Attributes.HttpGet("api/RolePrograms/User/{id}")]
+ ITask> GetRoleProgramsByUser(int id, int page = 0, int limit = 10);
+
///
/// 根据角色ID獲取角色功能資料
///
diff --git a/AMESCoreStudio.WebApi/Controllers/SYS/RoleModulesController.cs b/AMESCoreStudio.WebApi/Controllers/SYS/RoleModulesController.cs
index 7f5a9272..e7ab7cc0 100644
--- a/AMESCoreStudio.WebApi/Controllers/SYS/RoleModulesController.cs
+++ b/AMESCoreStudio.WebApi/Controllers/SYS/RoleModulesController.cs
@@ -56,6 +56,63 @@ namespace AMESCoreStudio.WebApi.Controllers.SYS
//return await _context.RoleModules.Include(r=>r.Module).ToListAsync();
}
+ ///
+ /// 根据用户ID获取所有角色模组资料
+ ///
+ ///
+ ///
+ ///
+ ///
+ // GET: api/RoleModules/User/5
+ [HttpGet("User/{id}")]
+ public async Task> GetRoleModuleByUser(int id, int page = 0, int limit = 10)
+ {
+ ResultModel result = new ResultModel();
+
+ var q = from q1 in _context.RoleModules
+ join q2 in _context.UserRoles on q1.RoleID equals q2.RoleID
+ select new
+ {
+ q1.ModuleID,
+ ModuleNo = q1.Module.ModuleNo,
+ ModuleName = q1.Module.ModuleName,
+ ModuleDesc = q1.Module.ModuleDesc,
+ SortSeq = q1.Module.SortSeq,
+ q2.UserID
+ };
+
+ if (id >= 0)
+ {
+ q = q.Where(p => p.UserID.Equals(id));
+ }
+
+ result.DataTotal = q.Distinct().ToList().Count;
+
+ if (page > 0)
+ {
+ q = q.OrderBy(p => p.ModuleID).Skip((page - 1) * limit).Take(limit);
+ }
+ else
+ {
+ q = q.OrderBy(p => p.ModuleID);
+ }
+
+ var userModule = await q.Distinct().OrderBy(p => p.ModuleID).ToListAsync();
+
+ result.Data = userModule;
+
+ if (userModule == null)
+ {
+ result.Msg = "查無資料";
+ result.Success = false;
+ return result;
+ }
+
+ result.Msg = "OK";
+ result.Success = true;
+ return result;
+ }
+
///
/// 根据角色ID获取该角色模组资料
///
diff --git a/AMESCoreStudio.WebApi/Controllers/SYS/RoleProgramsController.cs b/AMESCoreStudio.WebApi/Controllers/SYS/RoleProgramsController.cs
index 3e6b8e49..bc35d821 100644
--- a/AMESCoreStudio.WebApi/Controllers/SYS/RoleProgramsController.cs
+++ b/AMESCoreStudio.WebApi/Controllers/SYS/RoleProgramsController.cs
@@ -56,6 +56,64 @@ namespace AMESCoreStudio.WebApi.Controllers.SYS
return roleProgram;
}
+ ///
+ /// 根据用户ID获取所有角色功能资料
+ ///
+ ///
+ ///
+ ///
+ ///
+ // GET: api/RolePrograms/User/5
+ [HttpGet("User/{id}")]
+ public async Task> GetRoleProgramByUser(int id, int page = 0, int limit = 10)
+ {
+ ResultModel result = new ResultModel();
+
+ var q = from q1 in _context.RolePrograms
+ join q2 in _context.UserRoles on q1.RoleID equals q2.RoleID
+ select new
+ {
+ q1.ProgramID,
+ ModuleID = q1.Program.ModuleID,
+ ProgramNo = q1.Program.ProgramNo,
+ ProgramName = q1.Program.ProgramName,
+ ProgramPath = q1.Program.ProgramPath,
+ SortSeq = q1.Program.SortSeq,
+ q2.UserID
+ };
+
+ if (id >= 0)
+ {
+ q = q.Where(p => p.UserID.Equals(id));
+ }
+
+ result.DataTotal = q.Distinct().ToList().Count;
+
+ if (page > 0)
+ {
+ q = q.OrderBy(p => p.ProgramID).Skip((page - 1) * limit).Take(limit);
+ }
+ else
+ {
+ q = q.OrderBy(p => p.ProgramID);
+ }
+
+ var userProgram = await q.Distinct().OrderBy(p => p.ProgramID).ToListAsync();
+
+ result.Data = userProgram;
+
+ if (userProgram == null)
+ {
+ result.Msg = "查無資料";
+ result.Success = false;
+ return result;
+ }
+
+ result.Msg = "OK";
+ result.Success = true;
+ return result;
+ }
+
///
/// 根据角色ID获取该角色功能资料
///