Commit 8caa5f1c authored by 黄奎's avatar 黄奎

页面修改

parent 914f1c90
...@@ -12,6 +12,11 @@ namespace Edu.Model.ViewModel.System ...@@ -12,6 +12,11 @@ namespace Edu.Model.ViewModel.System
/// </summary> /// </summary>
public int MenuId { get; set; } public int MenuId { get; set; }
/// <summary>
/// 上级菜单编号
/// </summary>
public int ParentId { get; set; }
/// <summary> /// <summary>
/// 菜单名称 /// 菜单名称
/// </summary> /// </summary>
......
...@@ -28,6 +28,11 @@ namespace Edu.Model.ViewModel.System ...@@ -28,6 +28,11 @@ namespace Edu.Model.ViewModel.System
/// </summary> /// </summary>
public int Action_Id { get; set; } public int Action_Id { get; set; }
/// <summary>
/// 上级节点编号
/// </summary>
public int ParentId { get; set; }
/// <summary> /// <summary>
/// 权限名称描述 /// 权限名称描述
/// </summary> /// </summary>
......
...@@ -120,6 +120,7 @@ namespace Edu.Module.System ...@@ -120,6 +120,7 @@ namespace Edu.Module.System
MenuName = fItem.MenuName, MenuName = fItem.MenuName,
MenuUrl = fItem.MenuUrl, MenuUrl = fItem.MenuUrl,
MenuIcon=fItem.MenuIcon, MenuIcon=fItem.MenuIcon,
ParentId=0,
SubList = new List<MenuTree_ViewModel>() SubList = new List<MenuTree_ViewModel>()
}; };
//二级菜单 //二级菜单
...@@ -134,10 +135,11 @@ namespace Edu.Module.System ...@@ -134,10 +135,11 @@ namespace Edu.Module.System
MenuName = sItem.MenuName, MenuName = sItem.MenuName,
MenuUrl = sItem.MenuUrl, MenuUrl = sItem.MenuUrl,
MenuIcon = sItem.MenuIcon, MenuIcon = sItem.MenuIcon,
ParentId = fItem.MenuId,
SubList = new List<MenuTree_ViewModel>() SubList = new List<MenuTree_ViewModel>()
}; };
//三级菜单 //三级菜单
var thirdLevelList= list.Where(qitem => qitem.MenuLevel == 3 && qitem.ParentId == sItem.MenuId).ToList(); var thirdLevelList = list.Where(qitem => qitem.MenuLevel == 3 && qitem.ParentId == sItem.MenuId).ToList();
if (thirdLevelList != null && thirdLevelList.Count > 0) if (thirdLevelList != null && thirdLevelList.Count > 0)
{ {
foreach (var tItem in thirdLevelList) foreach (var tItem in thirdLevelList)
...@@ -145,6 +147,7 @@ namespace Edu.Module.System ...@@ -145,6 +147,7 @@ namespace Edu.Module.System
sModel.SubList.Add(new MenuTree_ViewModel() sModel.SubList.Add(new MenuTree_ViewModel()
{ {
MenuId = tItem.MenuId, MenuId = tItem.MenuId,
ParentId = sItem.MenuId,
MenuName = tItem.MenuName, MenuName = tItem.MenuName,
MenuUrl = tItem.MenuUrl, MenuUrl = tItem.MenuUrl,
MenuIcon = tItem.MenuIcon, MenuIcon = tItem.MenuIcon,
......
...@@ -180,12 +180,14 @@ namespace Edu.Module.System ...@@ -180,12 +180,14 @@ namespace Edu.Module.System
CategoryName = item.CategoryName, CategoryName = item.CategoryName,
IsChecked = false, IsChecked = false,
Role_Id = roleId, Role_Id = roleId,
ParentId = 0,
SubList = resultRoleFunctionTreeList?.Where(qitem => qitem.CategoryId == item.CategoryId)?.ToList() ?? new List<RoleFunctionPermissionTree_ViewModel>() SubList = resultRoleFunctionTreeList?.Where(qitem => qitem.CategoryId == item.CategoryId)?.ToList() ?? new List<RoleFunctionPermissionTree_ViewModel>()
}; };
if (rootModel != null && rootModel.SubList.Count > 0) if (rootModel != null && rootModel.SubList.Count > 0)
{ {
foreach (var subItem in rootModel.SubList) foreach (var subItem in rootModel.SubList)
{ {
subItem.ParentId = Convert.ToInt32(cateModel.CategoryId);
subItem.IsChecked = roleFunctionList?.Where(qitem => (int)qitem.Action_Id == subItem.Action_Id)?.Count() > 0; subItem.IsChecked = roleFunctionList?.Where(qitem => (int)qitem.Action_Id == subItem.Action_Id)?.Count() > 0;
} }
} }
...@@ -217,21 +219,33 @@ namespace Edu.Module.System ...@@ -217,21 +219,33 @@ namespace Edu.Module.System
} }
/// <summary> /// <summary>
/// 新增修改角色菜单权限 /// 新增修改[角色菜单、角色功能]权限
/// </summary> /// </summary>
/// <param name="list"></param> /// <param name="roleMenuList">菜单权限列表</param>
/// <param name="roleFunctionList">功能权限列表</param>
/// <returns></returns> /// <returns></returns>
[TransactionCallHandler] [TransactionCallHandler]
public bool SetRolePermissionModule(List<RB_Role_Permission_ViewModel> list) public bool SetRolePermissionModule(List<RB_Role_Permission_ViewModel> roleMenuList, List<RB_Role_FunctionPermission_ViewModel> roleFunctionList)
{ {
bool flag = false; bool flag = false;
if (list != null && list.Count > 0) //菜单权限
if (roleMenuList != null && roleMenuList.Count > 0)
{ {
rolePermissionRepository.DeleteOne(new WhereHelper(nameof(RB_Role_Permission_ViewModel.Role_Id), list[0].Role_Id)); rolePermissionRepository.DeleteOne(new WhereHelper(nameof(RB_Role_Permission_ViewModel.Role_Id), roleMenuList[0].Role_Id));
foreach (var item in list) foreach (var item in roleMenuList)
{ {
item.ID = 0; item.ID = 0;
flag = rolePermissionRepository.Insert(item); flag = rolePermissionRepository.Insert(item)>0;
}
}
//功能权限
if (roleFunctionList != null && roleFunctionList.Count > 0)
{
roleFunctionPermissionRepository.DeleteOne(new WhereHelper(nameof(RB_Role_FunctionPermission_ViewModel.Role_Id), roleFunctionList[0].Role_Id));
foreach (var item in roleFunctionList)
{
item.ID = 0;
flag = roleFunctionPermissionRepository.Insert(item)>0;
} }
} }
return flag; return flag;
...@@ -247,28 +261,6 @@ namespace Edu.Module.System ...@@ -247,28 +261,6 @@ namespace Edu.Module.System
return rolePermissionRepository.GetRolePermissionListRepository(query); return rolePermissionRepository.GetRolePermissionListRepository(query);
} }
/// <summary>
/// 新增修改角色功能权限
/// </summary>
/// <param name="list"></param>
/// <returns></returns>
[TransactionCallHandler]
public bool SetRoleFunctionPermissionModule(List<RB_Role_FunctionPermission_ViewModel> list)
{
bool flag = false;
if (list != null && list.Count > 0)
{
roleFunctionPermissionRepository.DeleteOne(new WhereHelper(nameof(RB_Role_FunctionPermission_ViewModel.Role_Id), list[0].Role_Id));
foreach (var item in list)
{
item.ID = 0;
flag = roleFunctionPermissionRepository.Insert(item);
}
}
return flag;
}
/// <summary> /// <summary>
/// 获取角色功能菜单列表 /// 获取角色功能菜单列表
/// </summary> /// </summary>
......
...@@ -34,7 +34,7 @@ namespace Edu.WebApi.Controllers.Public ...@@ -34,7 +34,7 @@ namespace Edu.WebApi.Controllers.Public
/// <summary> /// <summary>
/// 角色处理类对象 /// 角色处理类对象
/// </summary> /// </summary>
private readonly RoleModule roleModule = new RoleModule(); private readonly RoleModule roleModule = AOP.AOPHelper.CreateAOPObject<RoleModule>();
#region 省市区 #region 省市区
...@@ -222,10 +222,24 @@ namespace Edu.WebApi.Controllers.Public ...@@ -222,10 +222,24 @@ namespace Edu.WebApi.Controllers.Public
var roleId = base.ParmJObj.GetInt("Role_Id"); var roleId = base.ParmJObj.GetInt("Role_Id");
if (roleId <= 0) if (roleId <= 0)
{ {
return ApiResult.ParamIsNull(message:"请传递角色编号"); return ApiResult.ParamIsNull(message: "请传递角色编号");
} }
var obj = roleModule.GetRolePermissionModule(roleId); var obj = roleModule.GetRolePermissionModule(roleId);
return ApiResult.Success(data: obj); return ApiResult.Success(data: obj);
} }
/// <summary>
/// 保存角色权限
/// </summary>
/// <returns></returns>
public ApiResult SetRolePermission()
{
var roleMenu = base.ParmJObj.GetStringValue("roleMenu");
var roleFunction = base.ParmJObj.GetStringValue("roleFunction");
var rolePermissionList = Common.Plugin.JsonHelper.DeserializeObject<List<RB_Role_Permission_ViewModel>>(roleMenu);
var roleFunctionList= Common.Plugin.JsonHelper.DeserializeObject<List<RB_Role_FunctionPermission_ViewModel>>(roleFunction);
bool flag = roleModule.SetRolePermissionModule(rolePermissionList, roleFunctionList);
return flag ? ApiResult.Success() : ApiResult.Failed();
}
} }
} }
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment