Commit 33902769 authored by 黄奎's avatar 黄奎

新增实体类

parent 3cc48927
...@@ -22,9 +22,14 @@ namespace Edu.Model.Entity.System ...@@ -22,9 +22,14 @@ namespace Edu.Model.Entity.System
public int Role_Id { get; set; } public int Role_Id { get; set; }
/// <summary> /// <summary>
/// 功能菜单id /// 菜单编号
/// </summary> /// </summary>
public FunctionPermissionEnum Action_Id { get; set; } public int Menu_Id { get; set; }
/// <summary>
/// 功能编码
/// </summary>
public int Action_Id { get; set; }
/// <summary> /// <summary>
/// 权限名称描述 /// 权限名称描述
......
...@@ -45,6 +45,6 @@ namespace Edu.Model.ViewModel.System ...@@ -45,6 +45,6 @@ namespace Edu.Model.ViewModel.System
/// <summary> /// <summary>
/// 功能权限列表 /// 功能权限列表
/// </summary> /// </summary>
public List<RB_Role_FunctionPermission_ViewModel> FunctionSubList { get; set; } public List<RB_Menu_Function_ViewModel> FunctionSubList { get; set; }
} }
} }
...@@ -68,5 +68,10 @@ namespace Edu.Model.ViewModel.User ...@@ -68,5 +68,10 @@ namespace Edu.Model.ViewModel.User
/// 员工编号【查询使用,逗号分隔】 /// 员工编号【查询使用,逗号分隔】
/// </summary> /// </summary>
public string QIds { get; set; } public string QIds { get; set; }
/// <summary>
/// 部门层级
/// </summary>
public int DeptTier { get; set; }
} }
} }
...@@ -29,6 +29,11 @@ namespace Edu.Module.System ...@@ -29,6 +29,11 @@ namespace Edu.Module.System
/// </summary> /// </summary>
private readonly RB_Role_FunctionPermissionRepository roleFunctionPermissionRepository = new RB_Role_FunctionPermissionRepository(); private readonly RB_Role_FunctionPermissionRepository roleFunctionPermissionRepository = new RB_Role_FunctionPermissionRepository();
/// <summary>
/// 菜单功能权限仓储层对象
/// </summary>
private readonly RB_Menu_FunctionRepository functionRepository = new RB_Menu_FunctionRepository();
/// <summary> /// <summary>
/// 系统菜单处理对象 /// 系统菜单处理对象
/// </summary> /// </summary>
...@@ -117,6 +122,10 @@ namespace Edu.Module.System ...@@ -117,6 +122,10 @@ namespace Edu.Module.System
/// <returns></returns> /// <returns></returns>
public List<MenuTree_ViewModel> GetRolePermissionModule(int roleId) public List<MenuTree_ViewModel> GetRolePermissionModule(int roleId)
{ {
//菜单列表
var menuList = menuModule.GetTreeMenuModule(new RB_Menu_ViewModel(), isGetMenuFuncton: true);
//获取功能权限列表
var actionList = functionRepository.GetMenuFunctionListRepository(new RB_Menu_Function_ViewModel() { }, isQueryNormal: true);
//角色菜单权限列表 //角色菜单权限列表
List<RB_Role_Permission_ViewModel> rolePermissionList = new List<RB_Role_Permission_ViewModel>(); List<RB_Role_Permission_ViewModel> rolePermissionList = new List<RB_Role_Permission_ViewModel>();
//角色功能权限列表 //角色功能权限列表
...@@ -126,22 +135,24 @@ namespace Edu.Module.System ...@@ -126,22 +135,24 @@ namespace Edu.Module.System
rolePermissionList = GetRolePermissionListModule(new RB_Role_Permission_ViewModel() { Role_Id = roleId }); rolePermissionList = GetRolePermissionListModule(new RB_Role_Permission_ViewModel() { Role_Id = roleId });
roleFunctionList = GetRoleFunctionPermissionListModule(new RB_Role_FunctionPermission_ViewModel() { Role_Id = roleId }); roleFunctionList = GetRoleFunctionPermissionListModule(new RB_Role_FunctionPermission_ViewModel() { Role_Id = roleId });
} }
//菜单列表
var menuList = menuModule.GetTreeMenuModule(new RB_Menu_ViewModel(),isGetMenuFuncton:true);
if (menuList != null && menuList.Count > 0) if (menuList != null && menuList.Count > 0)
{ {
foreach (var item in menuList) foreach (var item in menuList)
{ {
item.IsChecked = rolePermissionList?.Where(qitem => qitem.Menu_Id == item.MenuId)?.Count() > 0; item.IsChecked = rolePermissionList?.Where(qitem => qitem.Menu_Id == item.MenuId)?.Count() > 0;
item.FunctionSubList = actionList?.Where(qitem => qitem.MenuId == item.MenuId)?.ToList() ?? new List<RB_Menu_Function_ViewModel>();
if (item.SubList != null && item.SubList.Count > 0) if (item.SubList != null && item.SubList.Count > 0)
{ {
foreach (var subItem in item.SubList) foreach (var subItem in item.SubList)
{ {
subItem.IsChecked = rolePermissionList?.Where(qitem => qitem.Menu_Id == subItem.MenuId)?.Count() > 0; subItem.IsChecked = rolePermissionList?.Where(qitem => qitem.Menu_Id == subItem.MenuId)?.Count() > 0;
subItem.FunctionSubList = actionList?.Where(qitem => qitem.MenuId == subItem.MenuId)?.ToList() ?? new List<RB_Menu_Function_ViewModel>();
if (subItem.SubList != null && subItem.SubList.Count > 0) if (subItem.SubList != null && subItem.SubList.Count > 0)
{ {
foreach (var childItem in subItem.SubList) foreach (var childItem in subItem.SubList)
{ {
childItem.FunctionSubList = actionList?.Where(qitem => qitem.MenuId == childItem.MenuId)?.ToList() ?? new List<RB_Menu_Function_ViewModel>();
childItem.IsChecked = rolePermissionList?.Where(qitem => qitem.Menu_Id == childItem.MenuId)?.Count() > 0; childItem.IsChecked = rolePermissionList?.Where(qitem => qitem.Menu_Id == childItem.MenuId)?.Count() > 0;
} }
} }
...@@ -152,22 +163,6 @@ namespace Edu.Module.System ...@@ -152,22 +163,6 @@ namespace Edu.Module.System
return menuList; return menuList;
} }
/// <summary>
/// 获取功能权限分类名称
/// </summary>
/// <param name="categoryId"></param>
/// <returns></returns>
private string GetCategoryName(string categoryId)
{
string str = "默认";
switch (categoryId)
{
case "10": str = "系统"; break;
case "20": str = "订单"; break;
}
return str;
}
/// <summary> /// <summary>
/// 新增修改[角色菜单、角色功能]权限 /// 新增修改[角色菜单、角色功能]权限
/// </summary> /// </summary>
...@@ -185,7 +180,7 @@ namespace Edu.Module.System ...@@ -185,7 +180,7 @@ namespace Edu.Module.System
foreach (var item in roleMenuList) foreach (var item in roleMenuList)
{ {
item.ID = 0; item.ID = 0;
flag = rolePermissionRepository.Insert(item)>0; flag = rolePermissionRepository.Insert(item) > 0;
} }
} }
//功能权限 //功能权限
...@@ -195,7 +190,7 @@ namespace Edu.Module.System ...@@ -195,7 +190,7 @@ namespace Edu.Module.System
foreach (var item in roleFunctionList) foreach (var item in roleFunctionList)
{ {
item.ID = 0; item.ID = 0;
flag = roleFunctionPermissionRepository.Insert(item)>0; flag = roleFunctionPermissionRepository.Insert(item) > 0;
} }
} }
return flag; return flag;
......
using Edu.Model.Entity.System; using Edu.Common.Enum;
using Edu.Model.Entity.System;
using Edu.Model.ViewModel.System; using Edu.Model.ViewModel.System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
...@@ -46,8 +47,9 @@ WHERE 1=1 ...@@ -46,8 +47,9 @@ WHERE 1=1
/// 获取菜单功能权限列表 /// 获取菜单功能权限列表
/// </summary> /// </summary>
/// <param name="query"></param> /// <param name="query"></param>
/// <param name="isQueryNormal">true-正常数据,false-全部数据</param>
/// <returns></returns> /// <returns></returns>
public List<RB_Menu_Function_ViewModel> GetMenuFunctionListRepository(RB_Menu_Function_ViewModel query) public List<RB_Menu_Function_ViewModel> GetMenuFunctionListRepository(RB_Menu_Function_ViewModel query,bool isQueryNormal=false)
{ {
StringBuilder builder = new StringBuilder(); StringBuilder builder = new StringBuilder();
builder.AppendFormat(@" builder.AppendFormat(@"
...@@ -55,6 +57,10 @@ SELECT A.* ...@@ -55,6 +57,10 @@ SELECT A.*
FROM RB_Menu_Function AS A FROM RB_Menu_Function AS A
WHERE 1=1 WHERE 1=1
"); ");
if (isQueryNormal)
{
builder.Append($" AND A.{nameof(RB_Menu_Function_ViewModel.Status)}={(int)DateStateEnum.Normal} ");
}
if (query != null) if (query != null)
{ {
if (query.MenuId > 0) if (query.MenuId > 0)
......
...@@ -229,7 +229,7 @@ FROM ...@@ -229,7 +229,7 @@ FROM
StringBuilder builder = new StringBuilder(); StringBuilder builder = new StringBuilder();
builder.AppendFormat(@" builder.AppendFormat(@"
SELECT A.Id,A.Account,A.Group_Id,A.School_Id,A.EmployeeName,IFNULL(G.GroupName,'') AS GroupName,IFNULL(s.SName,'') AS SchoolName SELECT A.Id,A.Account,A.Group_Id,A.School_Id,A.EmployeeName,IFNULL(G.GroupName,'') AS GroupName,IFNULL(s.SName,'') AS SchoolName
,IFNULL(d.DeptName,'') AS DeptName,IFNULL(p.PostName,'') AS PostName ,IFNULL(d.DeptId,0) AS Dept_Id,IFNULL(d.DeptName,'') AS DeptName,IFNULL(p.PostId,0) AS Post_Id, IFNULL(p.PostName,'') AS PostName
FROM FROM
( (
SELECT A.*,IFNULL(B.MName,'') AS EmployeeName,B.MHead AS UserIcon,B.Dept_Id,B.Post_Id SELECT A.*,IFNULL(B.MName,'') AS EmployeeName,B.MHead AS UserIcon,B.Dept_Id,B.Post_Id
......
using Edu.Model.Entity.User; using Edu.Model.Entity.User;
using Edu.Model.ViewModel.User; using Edu.Model.ViewModel.User;
using System.Collections.Generic; using System.Collections.Generic;
using System.Data;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using VT.FW.DB.Dapper; using VT.FW.DB.Dapper;
...@@ -127,5 +128,19 @@ WHERE 1=1 ...@@ -127,5 +128,19 @@ WHERE 1=1
return new List<RB_Department_ViewModel>(); return new List<RB_Department_ViewModel>();
} }
} }
/// <summary>
/// 获取当前部门的所有上级部门
/// </summary>
/// <param name="currentIds"></param>
/// <returns></returns>
public List<RB_Department_ViewModel> GetAllSuperiorDepartmentListRepository(object DeptIds)
{
var parameters = new DynamicParameters();
string procName = "proc_getsuperiordepartment";
parameters.Add("QDeptIds", DeptIds, direction: ParameterDirection.Input);
return Get<RB_Department_ViewModel>(procName, parameters, commandType: CommandType.StoredProcedure).ToList();
}
} }
} }
\ No newline at end of file
using Edu.Common.API;
using Edu.Common.Plugin;
using Edu.Module.User;
using Edu.WebApi.Filter;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Cors;
using Microsoft.AspNetCore.Mvc;
using Newtonsoft.Json.Linq;
using System.Linq;
namespace Edu.WebApi.Controllers.Third
{
/// <summary>
/// 第三方API
/// </summary>
[Route("api/[controller]/[action]")]
[ApiExceptionFilter]
[ApiController]
[EnableCors("AllowCors")]
public class ThirdController : BaseController
{
/// <summary>
/// 员工处理类
/// </summary>
private readonly EmployeeModule employeeModule = new EmployeeModule();
/// <summary>
/// 根部部门层级获取部门主管
/// </summary>
/// <returns></returns>
[HttpGet]
[HttpPost]
[AllowAnonymous]
public ApiResult GetEmploeeByTier()
{
JObject jobj = JObject.Parse(RequestParm.Msg.ToString());
int EmployeeId = jobj.GetInt("EmployeeId", 0);
int TierId = jobj.GetInt("TierId", 0);
if (EmployeeId <= 0)
{
return ApiResult.ParamIsNull(message: "请传递员工编号!");
}
var empModel = employeeModule.GetEmployeeListModule(new Model.ViewModel.User.Employee_ViewModel() { Id = EmployeeId })?.FirstOrDefault();
if (empModel == null)
{
return ApiResult.ParamIsNull(message: "当前员工编号不存在!");
}
if (TierId <= 0)
{
return ApiResult.ParamIsNull(message: "请选择部门层级!");
}
var empList = employeeModule.GetEmployeeByDeptTierModule(new Model.ViewModel.User.Employee_ViewModel()
{
Dept_Id = empModel.Dept_Id,
DeptTier = TierId,
Group_Id = empModel.Group_Id
});
var result = empList?.Select(qitem => new
{
qitem.Id,
qitem.EmployeeName,
qitem.Dept_Id,
qitem.DeptName,
qitem.Post_Id,
qitem.PostName,
qitem.School_Id,
qitem.SchoolName,
qitem.Group_Id,
qitem.GroupName
});
return ApiResult.Success(data: result);
}
/// <summary>
/// 根据岗位编号获取岗位员工列表
/// </summary>
/// <returns></returns>
[HttpGet]
[HttpPost]
[AllowAnonymous]
public ApiResult GetEmployeeByPost()
{
JObject jobj = JObject.Parse(RequestParm.Msg.ToString());
int EmployeeId = jobj.GetInt("EmployeeId", 0);
if (EmployeeId <= 0)
{
return ApiResult.ParamIsNull(message: "请传递员工编号!");
}
var empModel = employeeModule.GetEmployeeListModule(new Model.ViewModel.User.Employee_ViewModel() { Id = EmployeeId })?.FirstOrDefault();
if (empModel == null)
{
return ApiResult.ParamIsNull(message: "当前员工编号不存在!");
}
int postId = jobj.GetInt("PostId");
if (postId <= 0)
{
return ApiResult.ParamIsNull(message: "请选择岗位!");
}
var list = employeeModule.GetEmployeeListModule(new Model.ViewModel.User.Employee_ViewModel()
{
QPostIds = postId.ToString(),
Group_Id = empModel.Group_Id
});
return ApiResult.Success(data:
list?.Select(qitem => new
{
qitem.Id,
qitem.EmployeeName,
qitem.Dept_Id,
qitem.DeptName,
qitem.Post_Id,
qitem.PostName,
qitem.School_Id,
qitem.SchoolName,
qitem.Group_Id,
qitem.GroupName
}));
}
}
}
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