增加部门管理
This commit is contained in:
@@ -0,0 +1,158 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using COMCMS.Common;
|
||||
using COMCMS.Core;
|
||||
using XCode;
|
||||
using Newtonsoft.Json;
|
||||
using COMCMS.Web.Common;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
|
||||
namespace COMCMS.Web.Areas.AdminCP.Controllers
|
||||
{
|
||||
public class DepartmentController : AdminBaseController
|
||||
{
|
||||
#region 部门管理
|
||||
/// <summary>
|
||||
/// 部门列表
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[MyAuthorize("viewlist", "department")]
|
||||
public IActionResult DepartmentList()
|
||||
{
|
||||
IList<Department> list = Department.GetListTree(0, -1, false, true);
|
||||
Core.Admin.WriteLogActions("查看部门列表页面;");
|
||||
return View(list);
|
||||
}
|
||||
|
||||
|
||||
#endregion
|
||||
#region 添加部门
|
||||
[MyAuthorize("add", "department")]
|
||||
public IActionResult AddDepartment()
|
||||
{
|
||||
//获取上级栏目
|
||||
IList<Department> list = Department.GetListTree(0, 0, true, false);
|
||||
ViewBag.ListTree = list;
|
||||
Department entity = new Department();
|
||||
Core.Admin.WriteLogActions("查看添加部门页面;");
|
||||
return View(entity);
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
[MyAuthorize("add", "department", "JSON")]
|
||||
public IActionResult AddDepartment(Department model)
|
||||
{
|
||||
//获取上级栏目
|
||||
if (string.IsNullOrWhiteSpace(model.DepartmentName))
|
||||
{
|
||||
tip.Message = "部门名称不能为空!";
|
||||
return Json(tip);
|
||||
}
|
||||
|
||||
model.Insert();
|
||||
Core.Admin.WriteLogActions("添加部门(id:" + model.Id + ");");
|
||||
tip.Status = JsonTip.SUCCESS;
|
||||
tip.Message = "添加部门成功";
|
||||
tip.ReturnUrl = "close";
|
||||
|
||||
return Json(tip);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 编辑部门
|
||||
//编辑部门
|
||||
[HttpGet]
|
||||
[MyAuthorize("edit", "department")]
|
||||
public IActionResult EditDepartment(int id)
|
||||
{
|
||||
Department entity = Department.Find(Department._.Id == id);
|
||||
if (entity == null)
|
||||
{
|
||||
return EchoTipPage("系统找不到本记录!");
|
||||
}
|
||||
//获取上级栏目
|
||||
IList<Department> list = Department.GetListTree(0, 0, true, false);
|
||||
ViewBag.ListTree = list;
|
||||
Core.Admin.WriteLogActions("查看/编辑部门(id:" + id + ")页面;");
|
||||
return View(entity);
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
[MyAuthorize("edit", "department", "JSON")]
|
||||
public IActionResult EditDepartment(Department model)
|
||||
{
|
||||
if (model.Id <= 0)
|
||||
{
|
||||
tip.Message = "错误参数传递!";
|
||||
Json(tip);
|
||||
}
|
||||
if (string.IsNullOrWhiteSpace(model.DepartmentName))
|
||||
{
|
||||
tip.Message = "部门名称不能为空!";
|
||||
return Json(tip);
|
||||
}
|
||||
Department entity = Department.Find(Department._.Id == model.Id);
|
||||
if (entity == null)
|
||||
{
|
||||
tip.Message = "系统找不到本记录!";
|
||||
Json(tip);
|
||||
}
|
||||
//赋值
|
||||
|
||||
entity.DepartmentName = model.DepartmentName;
|
||||
entity.Pic = model.Pic;
|
||||
entity.DepartmentDescription = model.DepartmentDescription;
|
||||
entity.Rank = model.Rank;
|
||||
entity.Pic = model.Pic;
|
||||
entity.Tel = model.Tel;
|
||||
entity.Fax = model.Fax;
|
||||
entity.Email = model.Email;
|
||||
entity.IsNotAllowDel = Request.Form["IsNotAllowDel"] == "1" ? 1 : 0;
|
||||
//如果修改了路径
|
||||
if (entity.PId != model.PId)
|
||||
{
|
||||
entity.PId = model.PId;
|
||||
entity.Location = Department.GetNewLocation(model.PId);
|
||||
}
|
||||
entity.Save();
|
||||
|
||||
Core.Admin.WriteLogActions("修改部门(id:" + entity.Id + ");");
|
||||
tip.Status = JsonTip.SUCCESS;
|
||||
tip.Message = "修改部门成功";
|
||||
tip.ReturnUrl = "close";
|
||||
|
||||
return Json(tip);
|
||||
}
|
||||
|
||||
//删除栏目
|
||||
[HttpPost]
|
||||
[MyAuthorize("del", "department", "JSON")]
|
||||
public JsonResult DelDepartment(int id)
|
||||
{
|
||||
Department entity = Department.Find(Department._.Id == id);
|
||||
if (entity == null)
|
||||
{
|
||||
tip.Message = "系统找不到本部门!";
|
||||
return Json(tip);
|
||||
}
|
||||
if (Department.FindCount(Department._.PId == entity.Id, null, null, 0, 0) > 0)
|
||||
{
|
||||
tip.Message = "部门目有下级部门,不允许删除!";
|
||||
return Json(tip);
|
||||
}
|
||||
//删除文章
|
||||
|
||||
Core.Admin.WriteLogActions("删除部门(id:" + entity.Id + ");");
|
||||
entity.IsDel =1;
|
||||
entity.Update();
|
||||
tip.Status = JsonTip.SUCCESS;
|
||||
tip.Message = "删除部门成功";
|
||||
return Json(tip);
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,90 @@
|
||||
@model Department
|
||||
@{
|
||||
ViewBag.title = "添加部门";
|
||||
}
|
||||
|
||||
<div class="wrapper wrapper-content">
|
||||
<div class="ibox float-e-margins">
|
||||
<div class="ibox-title">
|
||||
<h5>@ViewBag.Title</h5>
|
||||
<div class="ibox-tools">
|
||||
</div>
|
||||
</div>
|
||||
<div class="ibox-content">
|
||||
<form id="addDepartmentForm" class="form-horizontal m-t" method="post">
|
||||
<div class="form-group">
|
||||
<label class="col-sm-3 control-label">上级部门:</label>
|
||||
<div class="col-sm-8">
|
||||
<select class="form-control m-b" name="PId" id="PId">
|
||||
<option value="0">一级部门</option>
|
||||
@foreach (var m in ViewBag.ListTree)
|
||||
{
|
||||
<option value="@m.Id">@m.DepartmentName</option>
|
||||
}
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="col-sm-3 control-label">部门名称:</label>
|
||||
<div class="col-sm-8">
|
||||
<input asp-for="DepartmentName" maxlength="200" type="text" class="form-control" required aria-required="true" placeholder="填写部门名称">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="col-sm-3 control-label">说明/备注:</label>
|
||||
<div class="col-sm-8">
|
||||
<input asp-for="DepartmentDescription" type="text" class="form-control" placeholder="部门副标题,非必填" maxlength="200">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group hidden">
|
||||
<label class="col-sm-3 control-label">部门图片:</label>
|
||||
<div class="col-sm-8">
|
||||
<div class="input-group">
|
||||
<input asp-for="Pic" maxlength="250" type="text" class="form-control upload-path" placeholder="请选择或上传一个图片" value="">
|
||||
<span class="input-group-addon my-upload-span upload-img"></span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="col-sm-3 control-label">排序:</label>
|
||||
<div class="col-sm-8">
|
||||
<input asp-for="Rank" type="number" class="form-control" maxlength="20" placeholder="越小排得越前" aria-required="true">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label class="col-sm-3 control-label">部门联系电话:</label>
|
||||
<div class="col-sm-8">
|
||||
<input asp-for="Tel" type="text" class="form-control" maxlength="30" placeholder="部门联系电话" aria-required="true">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="col-sm-3 control-label">部门传真:</label>
|
||||
<div class="col-sm-8">
|
||||
<input asp-for="Fax" type="text" class="form-control" maxlength="30" placeholder="部门传真" aria-required="true">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="col-sm-3 control-label">部门邮箱:</label>
|
||||
<div class="col-sm-8">
|
||||
<input asp-for="Email" type="text" class="form-control" maxlength="100" placeholder="部门邮箱" aria-required="true">
|
||||
</div>
|
||||
</div>
|
||||
<div class="hr-line-dashed"></div>
|
||||
<div class="form-group">
|
||||
<div class="col-sm-4 col-sm-offset-3">
|
||||
<button class="btn btn-primary" type="submit"><i class="fa fa-save"></i> 提交 </button>
|
||||
<button class="btn btn-default" type="button" onclick="closethisdialog();"><i class="fa fa-close"></i> 取消 </button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<script>
|
||||
$(function () {
|
||||
$(".upload-img").InitUploader({ filesize: "10240", sendurl: "/AdminCP/Upload/DoWebuploaderImage", swf: "/js/webuploader/uploader.swf", filetypes: "gif,jpg,png,bmp", notwater: true });
|
||||
DoPost("addDepartmentForm");
|
||||
})
|
||||
</script>
|
||||
@@ -0,0 +1,66 @@
|
||||
@model IList<Department>
|
||||
@{
|
||||
ViewBag.title = "部门管理";
|
||||
}
|
||||
|
||||
<div class="wrapper wrapper-content">
|
||||
<div class="ibox float-e-margins">
|
||||
<div class="ibox-title">
|
||||
<h5>@ViewBag.Title</h5>
|
||||
</div>
|
||||
<div class="ibox-content">
|
||||
<div id="toolbar" class="btn-group">
|
||||
<button id="btn_add" type="button" class="btn btn-outline btn-default" onclick="showDialog('adddepartment','添加部门','/AdminCP/Department/AddDepartment',0,0);">
|
||||
<span class="glyphicon glyphicon-plus" aria-hidden="true"></span>新增
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div id="toolbar2" class="btn-group pull-right">
|
||||
<button id="btn_refresh" type="button" class="btn btn-outline btn-default" onclick="refresh();">
|
||||
<span class="fa fa-refresh" aria-hidden="true"></span>刷新
|
||||
</button>
|
||||
</div>
|
||||
<table class="tree table table-striped table-bordered">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>部门名称</th>
|
||||
<th>ID</th>
|
||||
<th class="text-center">排序</th>
|
||||
<th>联系电话</th>
|
||||
<th>说明/备注</th>
|
||||
<th width="200">操作</th>
|
||||
</tr>
|
||||
</thead>
|
||||
@if (Model.Count == 0)
|
||||
{
|
||||
<tr><td colspan="6" class="text-center">暂无记录...</td></tr>
|
||||
}
|
||||
@foreach (var m in Model)
|
||||
{
|
||||
<tr class="treegrid-@m.Id @(m.PId !=0?"treegrid-parent-"+m.PId:"") ">
|
||||
<td>@m.DepartmentName</td>
|
||||
<td>
|
||||
@m.Id
|
||||
</td>
|
||||
<td class="text-center">@m.Rank</td>
|
||||
<td>@m.Tel</td>
|
||||
<td>
|
||||
@m.DepartmentDescription
|
||||
</td>
|
||||
<td>
|
||||
<a href="javascript:;" class="btn btn-xs btn-primary" title="编辑" onclick="top.showDialog('eidtdepartment', '编辑部门详情', '/AdminCP/Department/EditDepartment?id=@m.Id', 0, 0)"><i class="fa fa-edit"></i> 编辑</a>
|
||||
<a href="javascript:;" class="btn btn-xs btn-danger" title="删除" onclick="doDel('/AdminCP/Department/DelDepartment',@m.Id);"><i class="fa fa-close"></i> 删除</a>
|
||||
</td>
|
||||
</tr>
|
||||
}
|
||||
</table>
|
||||
<script type="text/javascript">
|
||||
$(document).ready(function () {
|
||||
$('.tree').treegrid();
|
||||
});
|
||||
</script>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
@@ -0,0 +1,91 @@
|
||||
@model Department
|
||||
@{
|
||||
ViewBag.title = "编辑部门详情";
|
||||
}
|
||||
|
||||
<div class="wrapper wrapper-content">
|
||||
<div class="ibox float-e-margins">
|
||||
<div class="ibox-title">
|
||||
<h5>@ViewBag.Title</h5>
|
||||
<div class="ibox-tools">
|
||||
</div>
|
||||
</div>
|
||||
<div class="ibox-content">
|
||||
<form id="editDepartmentForm" class="form-horizontal m-t" method="post">
|
||||
<div class="form-group">
|
||||
<label class="col-sm-3 control-label">上级部门:</label>
|
||||
<div class="col-sm-8">
|
||||
<select class="form-control m-b" asp-for="PId">
|
||||
<option value="0">一级部门</option>
|
||||
@foreach (var m in ViewBag.ListTree)
|
||||
{
|
||||
<option value="@m.Id">@m.DepartmentName</option>
|
||||
}
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="col-sm-3 control-label">部门名称:</label>
|
||||
<div class="col-sm-8">
|
||||
<input asp-for="DepartmentName" maxlength="200" type="text" class="form-control" required aria-required="true" placeholder="填写部门名称">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="col-sm-3 control-label">说明/备注:</label>
|
||||
<div class="col-sm-8">
|
||||
<input asp-for="DepartmentDescription" type="text" class="form-control" placeholder="部门副标题,非必填" maxlength="200">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group hidden">
|
||||
<label class="col-sm-3 control-label">部门图片:</label>
|
||||
<div class="col-sm-8">
|
||||
<div class="input-group">
|
||||
<input asp-for="Pic" maxlength="250" type="text" class="form-control upload-path" placeholder="请选择或上传一个图片" value="">
|
||||
<span class="input-group-addon my-upload-span upload-img"></span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="col-sm-3 control-label">排序:</label>
|
||||
<div class="col-sm-8">
|
||||
<input asp-for="Rank" type="number" class="form-control" maxlength="20" placeholder="越小排得越前" aria-required="true">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label class="col-sm-3 control-label">部门联系电话:</label>
|
||||
<div class="col-sm-8">
|
||||
<input asp-for="Tel" type="text" class="form-control" maxlength="30" placeholder="部门联系电话" aria-required="true">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="col-sm-3 control-label">部门传真:</label>
|
||||
<div class="col-sm-8">
|
||||
<input asp-for="Fax" type="text" class="form-control" maxlength="30" placeholder="部门传真" aria-required="true">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="col-sm-3 control-label">部门邮箱:</label>
|
||||
<div class="col-sm-8">
|
||||
<input asp-for="Email" type="text" class="form-control" maxlength="100" placeholder="部门邮箱" aria-required="true">
|
||||
</div>
|
||||
</div>
|
||||
<div class="hr-line-dashed"></div>
|
||||
<div class="form-group">
|
||||
<div class="col-sm-4 col-sm-offset-3">
|
||||
<input type="hidden" asp-for="Id" />
|
||||
<button class="btn btn-primary" type="submit"><i class="fa fa-save"></i> 提交 </button>
|
||||
<button class="btn btn-default" type="button" onclick="closethisdialog();"><i class="fa fa-close"></i> 取消 </button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<script>
|
||||
$(function () {
|
||||
$(".upload-img").InitUploader({ filesize: "10240", sendurl: "/AdminCP/Upload/DoWebuploaderImage", swf: "/js/webuploader/uploader.swf", filetypes: "gif,jpg,png,bmp", notwater: true });
|
||||
DoPost("editDepartmentForm");
|
||||
})
|
||||
</script>
|
||||
@@ -6,13 +6,14 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="MailKit" Version="2.7.0" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="3.1.5" />
|
||||
<PackageReference Include="MailKit" Version="2.8.0" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="3.1.6" />
|
||||
<PackageReference Include="Microsoft.Data.Sqlite.Core" Version="3.1.6" />
|
||||
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.10.9" />
|
||||
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="3.1.3" />
|
||||
<PackageReference Include="MimeKit" Version="2.8.0" />
|
||||
<PackageReference Include="MySql.Data" Version="8.0.20" />
|
||||
<PackageReference Include="NewLife.XCode" Version="9.18.2020.701" />
|
||||
<PackageReference Include="MimeKit" Version="2.9.1" />
|
||||
<PackageReference Include="MySql.Data" Version="8.0.21" />
|
||||
<PackageReference Include="NewLife.XCode" Version="9.18.2020.719-beta" />
|
||||
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
|
||||
<PackageReference Include="Senparc.NeuChar" Version="1.2.108" />
|
||||
<PackageReference Include="Senparc.Weixin" Version="6.7.502" />
|
||||
|
||||
@@ -1,145 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Threading.Tasks;
|
||||
using COMCMS.Core;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using NewLife.Reflection;
|
||||
using XCode;
|
||||
|
||||
namespace COMCMS.Web.Common
|
||||
{
|
||||
public class MenuRegister
|
||||
{
|
||||
private static void StartRegister()
|
||||
{
|
||||
if (AdminMenu.Meta.Count > 0)
|
||||
return;
|
||||
// 操作项定义
|
||||
var menuEventDic = new Dictionary<string, KeyValuePair<int, string>>
|
||||
{
|
||||
{ "add",new KeyValuePair<int, string>(1,"添加")},
|
||||
{ "edit",new KeyValuePair<int, string>(2,"修改")},
|
||||
{ "del",new KeyValuePair<int, string>(3,"删除")},
|
||||
{ "view",new KeyValuePair<int, string>(4,"查看")},
|
||||
{ "viewlist",new KeyValuePair<int, string>(5,"查看列表")},
|
||||
{ "import",new KeyValuePair<int, string>(6,"导入")},
|
||||
{ "export",new KeyValuePair<int, string>(7,"导出")},
|
||||
{ "filter",new KeyValuePair<int, string>(8,"搜索")},
|
||||
{ "batch",new KeyValuePair<int, string>(9,"批量操作")},
|
||||
{ "recycle",new KeyValuePair<int, string>(10,"回收站")},
|
||||
{ "confirm",new KeyValuePair<int, string>(11,"确认")},
|
||||
|
||||
};
|
||||
|
||||
var asms = AppDomain.CurrentDomain.GetAssemblies();
|
||||
foreach (var asmItem in asms)
|
||||
{
|
||||
var types = asmItem.GetTypes().Where(e => e.Name.EndsWith("Controller")).ToList();
|
||||
if (types.Count == 0) continue;
|
||||
|
||||
foreach (var type in types)
|
||||
{
|
||||
if (!type.Namespace.Contains(".AdminCP.Controller"))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
// 控制器名称
|
||||
var ctrName = type.Name.TrimEnd("Controller");
|
||||
|
||||
// 控制器展示名
|
||||
var ctrDpName = type.GetDisplayName();
|
||||
|
||||
var ctrDes = type.GetDescription();
|
||||
|
||||
var url = ctrName;
|
||||
|
||||
var fAdminMenu = AdminMenu.Find(AdminMenu._.MenuKey == ctrName + "Sys" & AdminMenu._.Link == "#");
|
||||
var nAdminMenu = new AdminMenu
|
||||
{
|
||||
Description = ctrDes,
|
||||
IsHide = 0,
|
||||
Level = 0,
|
||||
Link = "#",
|
||||
Location = "0,",
|
||||
MenuKey = ctrName + "Sys",
|
||||
MenuName = ctrDpName,
|
||||
PId = 0
|
||||
};
|
||||
var pAdminMenu = fAdminMenu ?? nAdminMenu;
|
||||
if (pAdminMenu.Id > 0)
|
||||
{
|
||||
pAdminMenu.Description = nAdminMenu.Description;
|
||||
pAdminMenu.MenuName = nAdminMenu.MenuName;
|
||||
}
|
||||
|
||||
// 控制器所有包含MyAuthorizeAttribute的方法
|
||||
var acts = type.GetMethods()
|
||||
.Where(w => w.IsDefined(typeof(MyAuthorizeAttribute)))
|
||||
.ToList();
|
||||
|
||||
if (!acts.Any()) continue;
|
||||
|
||||
pAdminMenu.Save();
|
||||
|
||||
var eventKeyDic = new Dictionary<string, int>();
|
||||
var adminMenuEventList = new List<AdminMenuEvent>();
|
||||
|
||||
foreach (var method in acts)
|
||||
{
|
||||
var dn = method.GetDisplayName();
|
||||
var methodDes = method.GetDescription();
|
||||
var actName = method.Name;
|
||||
var myAuthorize = method.GetCustomAttribute<MyAuthorizeAttribute>();
|
||||
|
||||
var menuKey = myAuthorize.GetValue("_menuKey").ToString();
|
||||
var eventKey = myAuthorize.GetValue("_eventKey").ToString();
|
||||
var returnType = myAuthorize.GetValue("_returnType").ToString();
|
||||
|
||||
//保存菜单
|
||||
if (eventKey == "viewlist" && returnType == "HTML")
|
||||
{
|
||||
var adminMenu = AdminMenu.Find(AdminMenu._.MenuKey == menuKey & AdminMenu._.Link == url + "/" + actName) ?? new AdminMenu
|
||||
{
|
||||
Description = methodDes,
|
||||
IsHide = 0,
|
||||
Level = pAdminMenu.Level + 1,
|
||||
Link = url + "/" + actName,
|
||||
Location = pAdminMenu.Location + ",",
|
||||
MenuKey = menuKey,
|
||||
MenuName = dn,
|
||||
PId = pAdminMenu.Id
|
||||
};
|
||||
adminMenu.Save();
|
||||
|
||||
eventKeyDic[menuKey] = adminMenu.Id;
|
||||
}
|
||||
|
||||
// 保存操作
|
||||
var adminmenuevent = AdminMenuEvent.Find(AdminMenuEvent._.MenuId == menuEventDic[eventKey].Key
|
||||
& AdminMenuEvent._.MenuKey == menuKey & AdminMenuEvent._.EventKey == eventKey)
|
||||
?? new AdminMenuEvent
|
||||
{
|
||||
MenuKey = menuKey,
|
||||
MenuId = menuEventDic[eventKey].Key,
|
||||
EventKey = eventKey,
|
||||
EventName = menuEventDic[eventKey].Value
|
||||
};
|
||||
adminMenuEventList.Add(adminmenuevent);
|
||||
}
|
||||
|
||||
adminMenuEventList.ForEach(f => f.MenuId = eventKeyDic.ContainsKey(f.MenuKey) ? eventKeyDic[f.MenuKey] : 0);
|
||||
adminMenuEventList.Save();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public static void Register()
|
||||
{
|
||||
Task.Run(() => { StartRegister(); });
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -42,13 +42,6 @@ namespace COMCMS.Web
|
||||
// This method gets called by the runtime. Use this method to add services to the container.
|
||||
public void ConfigureServices(IServiceCollection services)
|
||||
{
|
||||
// 注册菜单
|
||||
//MenuRegister.Register();
|
||||
|
||||
//注入自己的HttpContext
|
||||
//services.AddSingleton<IHttpContextAccessor, HttpContextAccessor>();
|
||||
//services.AddMvc().AddSessionStateTempDataProvider();
|
||||
|
||||
//添加Configuration到静态变量
|
||||
Utils.AddUtils(Configuration);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user