Commit 492c78a8 authored by 吴春's avatar 吴春

Merge branch 'master' of http://gitlab.oytour.com/Kui2/education

parents 56b8fe15 b7f2193e
......@@ -94,5 +94,10 @@ namespace Edu.Model.CacheModel
/// 岗位名称
/// </summary>
public string PostName { get; set; }
/// <summary>
/// 功能权限列表
/// </summary>
public object ActionMenuList { get; set; }
}
}
\ No newline at end of file
......@@ -11,5 +11,10 @@ namespace Edu.Model.ViewModel.System
/// 菜单名称
/// </summary>
public string MenuName { get; set; }
/// <summary>
/// 菜单列表
/// </summary>
public string MenuUrl { get; set; }
}
}
......@@ -592,7 +592,7 @@ namespace Edu.Module.Course
item.PlanTimeList = timeList?.Where(qitem => qitem.ClassPlanId == item.ClassPlanId)?.ToList();
list.Add(new
{
IsEndDate = item.ClassDate <= today ? true : false,
IsEndDate = item.ClassDate <= today,
item.ClassPlanId,
item.ClassId,
item.ClassDate,
......@@ -816,9 +816,8 @@ namespace Edu.Module.Course
[TransactionCallHandler]
public bool AddClassStudentDropOutModule(RB_Order_Guest_ViewModel model, string CreateName)
{
bool flag = false;
//写日志
flag = order_GuestRepository.Insert(model) > 0;
bool flag = order_GuestRepository.Insert(model) > 0;
if (flag)
{
//更新学生的状态
......@@ -854,14 +853,11 @@ namespace Edu.Module.Course
[TransactionCallHandler]
public bool AddClassCheckModule(List<RB_Class_Check_ViewModel> list)
{
bool flag = false;
//写日志
flag = classCheckRepository.InsertBatch(list);
bool flag = classCheckRepository.InsertBatch(list);
return flag;
}
/// <summary>
/// 获取班级上课记录
/// </summary>
......
......@@ -149,7 +149,7 @@ namespace Edu.Module.System
/// <returns></returns>
public List<MenuTree_ViewModel> GetTreeMenuModule(RB_Menu_ViewModel query, int roleId = 0)
{
List<RB_Menu_ViewModel> list = new List<RB_Menu_ViewModel>();
List<RB_Menu_ViewModel> list;
if (roleId <= 0)
{
list = GetMenuListModule(query);
......@@ -251,6 +251,27 @@ namespace Edu.Module.System
return functionRepository.GetMenuFunctionListRepository(query);
}
/// <summary>
/// 根据岗位编号获取岗位角色菜单功能权限
/// </summary>
/// <param name="postIds">岗位编号</param>
/// <returns></returns>
public List<RB_Menu_Function_ViewModel> GetPostMenuFunctionListModule(string postIds)
{
return functionRepository.GetPostMenuFunctionListRepository(postIds);
}
/// <summary>
/// 判断用户是否有某项功能权限
/// </summary>
/// <param name="actionCode">权限编码</param>
/// <param name="postIds">岗位编号【可以多个】</param>
/// <returns></returns>
public bool CheckUserFunctionModule(string actionCode, string postIds)
{
return functionRepository.CheckUserFunctionRepository(actionCode, postIds);
}
/// <summary>
/// 新增修改菜单功能权限
/// </summary>
......
......@@ -119,6 +119,10 @@ namespace Edu.Module.User
}
else
{
if (model.LeaveStatus != LeaveStatusEnum.Departure)
{
model.LeaveTime = null;
}
fileds.Add(nameof(RB_Assist.IDCard), model.IDCard);
fileds.Add(nameof(RB_Assist.Sex),model.Sex);
fileds.Add(nameof(RB_Assist.EntryTime),model.EntryTime);
......@@ -203,7 +207,7 @@ namespace Edu.Module.User
/// <param name="model"></param>
/// <param name="isUpdateBasic">是否更新基础资料</param>
/// <returns></returns>
public bool SetAssistDeptModule(RB_Assist model, bool isUpdateBasic = false)
public bool SetAssistDeptModule(RB_Assist model)
{
bool flag;
if (model.AId > 0)
......@@ -211,21 +215,16 @@ namespace Edu.Module.User
var oldModel = GetAssistModule(model.AId);
Dictionary<string, object> fileds = new Dictionary<string, object>()
{
{nameof(RB_Assist.UpdateBy),model.UpdateBy },
{nameof(RB_Assist.UpdateTime),model.UpdateTime },
{nameof(RB_Assist.Dept_Id),model.Dept_Id },
// {nameof(RB_Assist.Post_Id),model.Post_Id },
};
string logContent = "";
if (model.Dept_Id != oldModel.Dept_Id)
{
var deptList = departmentRepository.GetDepartmentListRepository(new RB_Department_ViewModel() { QDeptIds = model.Dept_Id + "," + oldModel.Dept_Id });
logContent += string.Format(",将部门由【{0}】修改为【{1}】。", (deptList.Where(qitem => qitem.DeptId == oldModel.Dept_Id)?.FirstOrDefault()?.DeptName ?? ""), (deptList.Where(qitem => qitem.DeptId == model.Dept_Id)?.FirstOrDefault()?.DeptName ?? ""));
}
if (!string.IsNullOrEmpty(logContent))
{
//新增日志
......@@ -249,7 +248,7 @@ namespace Edu.Module.User
/// <param name="model"></param>
/// <param name="isUpdateBasic">是否更新基础资料</param>
/// <returns></returns>
public bool SetAssistPostModule(RB_Assist model, bool isUpdateBasic = false)
public bool SetAssistPostModule(RB_Assist model)
{
bool flag;
if (model.AId > 0)
......@@ -261,15 +260,12 @@ namespace Edu.Module.User
{nameof(RB_Assist.UpdateTime),model.UpdateTime },
{nameof(RB_Assist.Post_Id),model.Post_Id },
};
string logContent = "";
if (model.Post_Id != oldModel.Post_Id)
{
var postList = postRepository.GetPostListRepository(new RB_Post_ViewModel() { QPostIds = model.Post_Id + "," + oldModel.Post_Id });
logContent += string.Format(",将岗位由【{0}】修改为【{1}】。", (postList.Where(qitem => qitem.PostId == oldModel.Post_Id)?.FirstOrDefault()?.PostName ?? ""), (postList.Where(qitem => qitem.PostId == model.Post_Id)?.FirstOrDefault()?.PostName ?? ""));
}
if (!string.IsNullOrEmpty(logContent))
{
//新增日志
......@@ -291,9 +287,8 @@ namespace Edu.Module.User
/// 添加修改助教离职时间
/// </summary>
/// <param name="model"></param>
/// <param name="isUpdateBasic">是否更新基础资料</param>
/// <returns></returns>
public bool SetAssistLeaveTimeModule(RB_Assist model, bool isUpdateBasic = false)
public bool SetAssistLeaveTimeModule(RB_Assist model)
{
bool flag;
if (model.AId > 0)
......@@ -307,9 +302,7 @@ namespace Edu.Module.User
{nameof(RB_Assist.UpdateTime),model.UpdateTime },
};
string logContent = "";
if (model.LeaveStatus != oldModel.LeaveStatus)
{
logContent += string.Format(",将在职状态由【{0}】修改为【{1}】。", oldModel.LeaveStatus.ToName(), model.LeaveStatus.ToName());
......@@ -318,7 +311,6 @@ namespace Edu.Module.User
{
logContent += string.Format(",将离职时间由【{0}】修改为【{1}】。", oldModel?.LeaveTime, model.LeaveTime);
}
if (!string.IsNullOrEmpty(logContent))
{
//新增日志
......
......@@ -125,6 +125,10 @@ namespace Edu.Module.User
}
else
{
if (model.LeaveStatus != LeaveStatusEnum.Departure)
{
model.LeaveTime = null;
}
fileds.Add(nameof(RB_Teacher_ViewModel.IDCard), model.IDCard);
fileds.Add(nameof(RB_Teacher_ViewModel.Sex), model.Sex);
fileds.Add(nameof(RB_Teacher_ViewModel.EntryTime), model.EntryTime);
......@@ -201,9 +205,8 @@ namespace Edu.Module.User
/// 新增修改讲师
/// </summary>
/// <param name="model"></param>
/// <param name="isUpdateBasic">是否更新基础资料</param>
/// <returns></returns>
public bool SetTeacherDeptModule(RB_Teacher_ViewModel model, bool isUpdateBasic = false)
public bool SetTeacherDeptModule(RB_Teacher_ViewModel model)
{
bool flag;
if (model.TId > 0)
......@@ -211,7 +214,6 @@ namespace Edu.Module.User
var oldModel = GetTeacherModule(model.TId);
Dictionary<string, object> fileds = new Dictionary<string, object>()
{
{nameof(RB_Teacher_ViewModel.UpdateBy),model.UpdateBy },
{nameof(RB_Teacher_ViewModel.UpdateTime),model.UpdateTime },
{nameof(RB_Teacher_ViewModel.Dept_Id),model.Dept_Id },
......@@ -223,7 +225,6 @@ namespace Edu.Module.User
var deptList = departmentRepository.GetDepartmentListRepository(new RB_Department_ViewModel() { QDeptIds = model.Dept_Id + "," + oldModel.Dept_Id });
logContent += string.Format(",将部门由【{0}】修改为【{1}】。", (deptList.Where(qitem => qitem.DeptId == oldModel.Dept_Id)?.FirstOrDefault()?.DeptName ?? ""), (deptList.Where(qitem => qitem.DeptId == model.Dept_Id)?.FirstOrDefault()?.DeptName ?? ""));
}
if (!string.IsNullOrEmpty(logContent))
{
//新增日志
......@@ -245,9 +246,8 @@ namespace Edu.Module.User
/// 新增修改讲师
/// </summary>
/// <param name="model"></param>
/// <param name="isUpdateBasic">是否更新基础资料</param>
/// <returns></returns>
public bool SetTeacherPostModule(RB_Teacher_ViewModel model, bool isUpdateBasic = false)
public bool SetTeacherPostModule(RB_Teacher_ViewModel model)
{
bool flag;
if (model.TId > 0)
......@@ -255,20 +255,16 @@ namespace Edu.Module.User
var oldModel = GetTeacherModule(model.TId);
Dictionary<string, object> fileds = new Dictionary<string, object>()
{
{nameof(RB_Teacher_ViewModel.UpdateBy),model.UpdateBy },
{nameof(RB_Teacher_ViewModel.UpdateTime),model.UpdateTime },
{nameof(RB_Teacher_ViewModel.Post_Id),model.Post_Id },
};
string logContent = "";
if (model.Post_Id != oldModel.Post_Id)
{
var postList = postRepository.GetPostListRepository(new RB_Post_ViewModel() { QPostIds = model.Post_Id + "," + oldModel.Post_Id });
logContent += string.Format(",将岗位由【{0}】修改为【{1}】。", (postList.Where(qitem => qitem.PostId == oldModel.Post_Id)?.FirstOrDefault()?.PostName ?? ""), (postList.Where(qitem => qitem.PostId == model.Post_Id)?.FirstOrDefault()?.PostName ?? ""));
}
if (!string.IsNullOrEmpty(logContent))
{
//新增日志
......@@ -290,9 +286,8 @@ namespace Edu.Module.User
/// 新增修改讲师
/// </summary>
/// <param name="model"></param>
/// <param name="isUpdateBasic">是否更新基础资料</param>
/// <returns></returns>
public bool SetTeacherLeaveTimeModule(RB_Teacher_ViewModel model, bool isUpdateBasic = false)
public bool SetTeacherLeaveTimeModule(RB_Teacher_ViewModel model)
{
bool flag;
if (model.TId > 0)
......@@ -300,13 +295,11 @@ namespace Edu.Module.User
var oldModel = GetTeacherModule(model.TId);
Dictionary<string, object> fileds = new Dictionary<string, object>()
{
{nameof(RB_Teacher_ViewModel.UpdateBy),model.UpdateBy },
{nameof(RB_Teacher_ViewModel.UpdateTime),model.UpdateTime },
{nameof(RB_Teacher_ViewModel.LeaveStatus),model.LeaveStatus },
{nameof(RB_Teacher_ViewModel.LeaveTime),model.LeaveTime }
};
string logContent = "";
if (model.LeaveStatus != oldModel.LeaveStatus)
{
......
using Edu.Common.Enum;
using Edu.Model.Entity.System;
using Edu.Model.ViewModel.System;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
......@@ -78,5 +79,44 @@ WHERE 1=1
return new List<RB_Menu_Function_ViewModel>();
}
}
/// <summary>
/// 根据岗位编号获取岗位角色菜单功能权限
/// </summary>
/// <param name="postIds">岗位编号</param>
/// <returns></returns>
public List<RB_Menu_Function_ViewModel> GetPostMenuFunctionListRepository(string postIds)
{
StringBuilder builder = new StringBuilder();
builder.AppendFormat(@"
SELECT A.*,IFNULL(B.MenuName,'') AS MenuName,IFNULL(B.MenuUrl,'') AS MenuUrl
FROM RB_Menu_Function AS A LEFT JOIN rb_menu AS B ON A.MenuId=B.MenuId
WHERE 1=1 AND A.Id IN(SELECT Action_Id FROM rb_role_functionpermission WHERE Role_Id IN (SELECT RoleId FROM rb_post_role WHERE PostId IN({0})))
", postIds);
return Get<RB_Menu_Function_ViewModel>(builder.ToString()).ToList();
}
/// <summary>
/// 判断用户是否有某项功能权限
/// </summary>
/// <param name="actionCode">权限编码</param>
/// <param name="postIds">岗位编号【可以多个】</param>
/// <returns></returns>
public bool CheckUserFunctionRepository(string actionCode, string postIds)
{
int result = 0;
StringBuilder builder = new StringBuilder();
builder.AppendFormat(@"
SELECT 1
FROM RB_Menu_Function AS A
WHERE 1=1 AND A.FunctionCode='{0}' AND A.Id IN(SELECT Action_Id FROM rb_role_functionpermission WHERE Role_Id IN (SELECT RoleId FROM rb_post_role WHERE PostId IN({1})))
", actionCode.Trim(), postIds);
var obj = base.ExecuteScalar(builder.ToString());
if (obj != null)
{
Int32.TryParse(obj.ToString(), out result);
}
return result > 0;
}
}
}
\ No newline at end of file
......@@ -215,10 +215,6 @@ FROM
{
where.AppendFormat(" AND A.{0}='{1}' ", nameof(Employee_ViewModel.Account), query.Account.Trim());
}
//if (query.Id > 0)
//{
// where.AppendFormat(" AND A.{0}={1} ", nameof(Employee_ViewModel.Id), query.Id);
//}
if (!string.IsNullOrEmpty(query.QIds))
{
where.AppendFormat(" AND A.{0} IN({1}) ", nameof(Employee_ViewModel.Id), query.QIds);
......@@ -270,11 +266,11 @@ FROM
}
if (!string.IsNullOrEmpty(query.StartLeaveTime))
{
where.AppendFormat(" AND b.{0}>='{1}' ", nameof(Employee_ViewModel.LeaveTime), query.StartLeaveTime);
where.AppendFormat(" AND B.LeaveStatus=4 AND b.{0}>='{1}' ", nameof(Employee_ViewModel.LeaveTime), query.StartLeaveTime);
}
if (!string.IsNullOrEmpty(query.EndLeaveTime))
{
where.AppendFormat(" AND b.{0}<='{1} 23:59:59' ", nameof(Employee_ViewModel.LeaveTime), query.EndLeaveTime);
where.AppendFormat(" AND B.LeaveStatus=4 AND b.{0}<='{1} 23:59:59' ", nameof(Employee_ViewModel.LeaveTime), query.EndLeaveTime);
}
if (!string.IsNullOrEmpty(query.StartBirthDate))
{
......
......@@ -8,6 +8,7 @@ using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using Edu.Model.CacheModel;
using Edu.Cache.User;
using Edu.Module.System;
namespace Edu.WebApi.Controllers
{
......@@ -17,6 +18,10 @@ namespace Edu.WebApi.Controllers
[EnableCors("AllowCors")]
public class BaseController : ControllerBase
{
/// <summary>
/// 菜单处理类对象
/// </summary>
private readonly MenuModule menuModule = new MenuModule();
/// <summary>
/// 整理前端传递的post参数
......@@ -72,5 +77,20 @@ namespace Edu.WebApi.Controllers
return userInfo;
}
}
/// <summary>
/// 判断用户是否有功能权限
/// </summary>
/// <param name="actionCode">权限编码</param>
/// <returns></returns>
public bool CheckUserActionAuth(string actionCode)
{
bool flag = false;
if (this.UserInfo != null && this.UserInfo.PostId > 0)
{
flag = menuModule.CheckUserFunctionModule(actionCode, this.UserInfo.PostId.ToString());
}
return flag;
}
}
}
\ No newline at end of file
......@@ -396,7 +396,6 @@ namespace Edu.WebApi.Controllers.Course
}
}
}
var orderGuestList = classModule.GetOrderGuest(new RB_Order_Guest_ViewModel { Group_Id = base.UserInfo.Group_Id, School_Id = data.School_Id, ClassId = data.ClassId });
var checkLogList = classModule.GetClassCheckListRepository(new RB_Class_Check_ViewModel { Group_Id = data.Group_Id, School_Id = data.School_Id, ClassId = data.ClassId, StartDate = data.ClassDate.ToString("yyyy-MM-dd HH:mm:ss"), EndDate = data.ClassDate.ToString("yyyy-MM-dd HH:mm:ss") });
List<object> guestList = new List<object>();
......@@ -438,7 +437,7 @@ namespace Edu.WebApi.Controllers.Course
return ApiResult.Failed("班级信息不存在");
}
bool result = classModule.UpdateClassStudentDropOutModule(ids, dropOutRemark, classId, base.UserInfo.Id, classModel.Group_Id, classModel.School_Id, studentName);
return ApiResult.Success();
return result ? ApiResult.Success() : ApiResult.Failed();
}
......@@ -462,7 +461,7 @@ namespace Edu.WebApi.Controllers.Course
model.UpdateTime = model.CreateTime;
model.Group_Id = base.UserInfo.Group_Id;
bool result = classModule.AddClassStudentDropOutModule(model, base.UserInfo.AccountName);
return ApiResult.Success();
return result? ApiResult.Success():ApiResult.Failed();
}
/// <summary>
/// 获取教室页列表
......
......@@ -91,6 +91,8 @@ namespace Edu.WebApi.Controllers.User
{
MenuType = accountType
}, postIds: model.Post_Id.ToString());
//获取功能权限列表
var actionList = menuModule.GetPostMenuFunctionListModule(model.Post_Id.ToString());
UserInfo obj = new UserInfo
{
Id = model.Id,
......@@ -110,6 +112,7 @@ namespace Edu.WebApi.Controllers.User
DeptName = model.DeptName,
PostId = model.Post_Id,
PostName = model.PostName,
ActionMenuList= actionList?.Select(qitem => new {qitem.FunctionCode,qitem.FunctionName,qitem.MenuName,qitem.MenuUrl }),
};
UserReidsCache.UserInfoSet(Cache.CacheKey.User_Login_Key + model.Id, obj, Common.Config.JwtExpirTime);
return ApiResult.Success(data: obj);
......@@ -143,6 +146,9 @@ namespace Edu.WebApi.Controllers.User
MenuType = (int)userInfo.AccountType
}, userInfo.PostId.ToString());
userInfo.MenuList = treeList;
//获取功能权限列表
var actionList = menuModule.GetPostMenuFunctionListModule(userInfo.PostId.ToString());
userInfo.ActionMenuList = actionList?.Select(qitem => new { qitem.FunctionCode, qitem.FunctionName, qitem.MenuName, qitem.MenuUrl });
}
return ApiResult.Success(data: userInfo);
}
......
......@@ -671,7 +671,6 @@ namespace Edu.WebApi.Controllers.User
pageModel.PageData = list.Select((qitem, i) => new
{
Id = (pageModel.PageSize * (pageModel.PageIndex - 1)) + i + 1,
// qitem.Id,
qitem.UserIcon,
qitem.EmployeeName,
qitem.SchoolName,
......
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