添加项目文件。
This commit is contained in:
1 parent
05e131ca4e
commit
514d6f5255
1162 files changed
+81255
No files matched your search
@@ -0,0 +1,79 @@
|
||||
// WTM默认页面 Wtm buidin page
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using WalkingTec.Mvvm.Core;
|
||||
using WalkingTec.Mvvm.Core.Extensions;
|
||||
using WalkingTec.Mvvm.Mvc.Admin.ViewModels.ActionLogVMs;
|
||||
|
||||
namespace WalkingTec.Mvvm.Mvc.Admin.Controllers
|
||||
{
|
||||
[Area("_Admin")]
|
||||
[ActionDescription("MenuKey.ActionLog")]
|
||||
public class ActionLogController : BaseController
|
||||
{
|
||||
[ActionDescription("Sys.Search")]
|
||||
public IActionResult Index()
|
||||
{
|
||||
var vm = Wtm.CreateVM<ActionLogListVM>();
|
||||
return PartialView(vm);
|
||||
}
|
||||
|
||||
[ActionDescription("Sys.Search")]
|
||||
[HttpPost]
|
||||
public string Search(ActionLogSearcher searcher)
|
||||
{
|
||||
var vm = Wtm.CreateVM<ActionLogListVM>(passInit:true);
|
||||
if (ModelState.IsValid)
|
||||
{
|
||||
vm.Searcher = searcher;
|
||||
return vm.GetJson(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
return vm.GetError();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
[HttpGet]
|
||||
[ActionDescription("Sys.Details")]
|
||||
public IActionResult Details(string id)
|
||||
{
|
||||
var vm = Wtm.CreateVM<ActionLogVM>(id);
|
||||
return PartialView(vm);
|
||||
}
|
||||
|
||||
[ActionDescription("Sys.Export")]
|
||||
[HttpPost]
|
||||
public IActionResult ExportExcel(ActionLogListVM vm)
|
||||
{
|
||||
return vm.GetExportData();
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
[ActionDescription("Sys.BatchDelete")]
|
||||
public ActionResult BatchDelete(string[] IDs)
|
||||
{
|
||||
var vm = Wtm.CreateVM<ActionLogBatchVM>(Ids: IDs);
|
||||
return PartialView(vm);
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
[ActionDescription("Sys.BatchDelete")]
|
||||
public ActionResult DoBatchDelete(ActionLogBatchVM vm, IFormCollection nouse)
|
||||
{
|
||||
if (!ModelState.IsValid || !vm.DoBatchDelete())
|
||||
{
|
||||
return PartialView("BatchDelete", vm);
|
||||
}
|
||||
else
|
||||
{
|
||||
return FFResult().CloseDialog().RefreshGrid().Alert(Localizer["Sys.BatchDeleteSuccess", vm.Ids.Length]);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,154 @@
|
||||
// WTM默认页面 Wtm buidin page
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using WalkingTec.Mvvm.Core;
|
||||
using WalkingTec.Mvvm.Mvc.Admin.ViewModels.DataPrivilegeVMs;
|
||||
using WalkingTec.Mvvm.Core.Extensions;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace WalkingTec.Mvvm.Mvc.Admin.Controllers
|
||||
{
|
||||
[Area("_Admin")]
|
||||
[ActionDescription("MenuKey.DataPrivilege")]
|
||||
public class DataPrivilegeController : BaseController
|
||||
{
|
||||
[ActionDescription("Sys.Search")]
|
||||
public ActionResult Index()
|
||||
{
|
||||
var vm = Wtm.CreateVM<DataPrivilegeListVM>();
|
||||
vm.Searcher.TableNames = Wtm.DataPrivilegeSettings.ToListItems(x => x.PrivillegeName, x => x.ModelName);
|
||||
return PartialView(vm);
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public ActionResult Index(DataPrivilegeListVM vm)
|
||||
{
|
||||
vm.Searcher.TableNames = Wtm.DataPrivilegeSettings.ToListItems(x => x.PrivillegeName, x => x.ModelName);
|
||||
return PartialView(vm);
|
||||
}
|
||||
|
||||
|
||||
[ActionDescription("Sys.Search")]
|
||||
[HttpPost]
|
||||
public string Search(DataPrivilegeSearcher searcher)
|
||||
{
|
||||
var vm = Wtm.CreateVM<DataPrivilegeListVM>(passInit: true);
|
||||
if (ModelState.IsValid)
|
||||
{
|
||||
vm.Searcher = searcher;
|
||||
return vm.GetJson(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
return vm.GetError();
|
||||
}
|
||||
}
|
||||
|
||||
[ActionDescription("Sys.Create")]
|
||||
public ActionResult Create(DpTypeEnum Type)
|
||||
{
|
||||
var vm = Wtm.CreateVM<DataPrivilegeVM>(values:x=>x.DpType == Type);
|
||||
return PartialView(vm);
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
[ActionDescription("Sys.Create")]
|
||||
public async Task<ActionResult> Create(DataPrivilegeVM vm)
|
||||
{
|
||||
if (!ModelState.IsValid)
|
||||
{
|
||||
return PartialView(vm);
|
||||
}
|
||||
else
|
||||
{
|
||||
await vm.DoAddAsync();
|
||||
return FFResult().CloseDialog().RefreshGrid();
|
||||
}
|
||||
}
|
||||
|
||||
[ActionDescription("Sys.Edit")]
|
||||
public ActionResult Edit(string ModelName, string Id, DpTypeEnum Type)
|
||||
{
|
||||
DataPrivilegeVM vm = null;
|
||||
if (Type == DpTypeEnum.User)
|
||||
{
|
||||
vm = Wtm.CreateVM<DataPrivilegeVM>(values: x => x.Entity.TableName == ModelName && x.Entity.UserCode == Id && x.DpType == Type);
|
||||
}
|
||||
else
|
||||
{
|
||||
vm = Wtm.CreateVM<DataPrivilegeVM>(values: x => x.Entity.TableName == ModelName && x.Entity.GroupCode == Id && x.DpType == Type);
|
||||
}
|
||||
return PartialView(vm);
|
||||
}
|
||||
|
||||
[ActionDescription("Sys.Edit")]
|
||||
[HttpPost]
|
||||
public async Task<ActionResult> Edit(DataPrivilegeVM vm)
|
||||
{
|
||||
if (!ModelState.IsValid)
|
||||
{
|
||||
return PartialView(vm);
|
||||
}
|
||||
else
|
||||
{
|
||||
await vm.DoEditAsync();
|
||||
return FFResult().CloseDialog().RefreshGrid();
|
||||
}
|
||||
}
|
||||
|
||||
[ActionDescription("Sys.Delete")]
|
||||
public async Task<ActionResult> Delete(string ModelName, string Id, DpTypeEnum Type)
|
||||
{
|
||||
DataPrivilegeVM vm = null;
|
||||
if (Type == DpTypeEnum.User)
|
||||
{
|
||||
vm = Wtm.CreateVM<DataPrivilegeVM>(values: x => x.Entity.TableName == ModelName && x.Entity.UserCode == Id && x.DpType == Type);
|
||||
}
|
||||
else
|
||||
{
|
||||
vm = Wtm.CreateVM<DataPrivilegeVM>(values: x => x.Entity.TableName == ModelName && x.Entity.GroupCode == Id && x.DpType == Type);
|
||||
}
|
||||
await vm.DoDeleteAsync();
|
||||
return FFResult().RefreshGrid();
|
||||
}
|
||||
|
||||
[AllRights]
|
||||
public ActionResult GetPrivilegeByTableName(string table)
|
||||
{
|
||||
var AllItems = new List<ComboSelectListItem>();
|
||||
var dps = Wtm.DataPrivilegeSettings.Where(x => x.ModelName == table).SingleOrDefault();
|
||||
if (dps != null)
|
||||
{
|
||||
AllItems = dps.GetItemList(Wtm);
|
||||
}
|
||||
return JsonMore(AllItems);
|
||||
}
|
||||
|
||||
[ActionDescription("Sys.Export")]
|
||||
[HttpPost]
|
||||
public IActionResult ExportExcel(DataPrivilegeListVM vm)
|
||||
{
|
||||
return vm.GetExportData();
|
||||
}
|
||||
[AllRights]
|
||||
public IActionResult GetUserGroups()
|
||||
{
|
||||
WalkingTec.Mvvm.Admin.Api.DataPrivilegeController userapi = new Mvvm.Admin.Api.DataPrivilegeController();
|
||||
userapi.Wtm = Wtm;
|
||||
var rv = userapi.GetUserGroupsTree() as OkObjectResult;
|
||||
List<TreeSelectListItem> users = new List<TreeSelectListItem>();
|
||||
if (rv != null && rv.Value is string && rv.Value != null)
|
||||
{
|
||||
users = System.Text.Json.JsonSerializer.Deserialize<List<TreeSelectListItem>>(rv.Value.ToString());
|
||||
}
|
||||
else if (rv != null && rv.Value is List<TreeSelectListItem> c)
|
||||
{
|
||||
users = c;
|
||||
}
|
||||
return JsonMore(users);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,254 @@
|
||||
// WTM默认页面 Wtm buidin page
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Linq.Expressions;
|
||||
using System.Threading.Tasks;
|
||||
using WalkingTec.Mvvm.Core;
|
||||
using WalkingTec.Mvvm.Core.Extensions;
|
||||
using WalkingTec.Mvvm.Mvc.Admin.ViewModels.FrameworkGroupVMs;
|
||||
|
||||
namespace WalkingTec.Mvvm.Mvc.Admin.Controllers
|
||||
{
|
||||
[Area("_Admin")]
|
||||
[ActionDescription("MenuKey.GroupManagement")]
|
||||
public class FrameworkGroupController : BaseController
|
||||
{
|
||||
#region 查询
|
||||
[ActionDescription("Sys.Search")]
|
||||
public ActionResult Index()
|
||||
{
|
||||
var vm = Wtm.CreateVM<FrameworkGroupListVM>();
|
||||
return PartialView(vm);
|
||||
}
|
||||
|
||||
[ActionDescription("Sys.Search")]
|
||||
[HttpPost]
|
||||
public IActionResult Search(FrameworkGroupSearcher searcher)
|
||||
{
|
||||
if (ConfigInfo.HasMainHost && Wtm.LoginUserInfo?.CurrentTenant == null)
|
||||
{
|
||||
searcher.IsPlainText = false;
|
||||
return Wtm.CallAPI<string>("mainhost", "/api/_frameworkgroup/search", HttpMethodEnum.POST, searcher).Result.ToActionResult();
|
||||
}
|
||||
var vm = Wtm.CreateVM<FrameworkGroupListVM>(passInit: true);
|
||||
if (ModelState.IsValid)
|
||||
{
|
||||
vm.Searcher = searcher;
|
||||
return Content(vm.GetJson(false));
|
||||
}
|
||||
else
|
||||
{
|
||||
return Content(vm.GetError());
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
[ActionDescription("Sys.Create")]
|
||||
public ActionResult Create()
|
||||
{
|
||||
if (ConfigInfo.HasMainHost && Wtm.LoginUserInfo?.CurrentTenant == null)
|
||||
{
|
||||
return Content(Localizer["_Admin.HasMainHost"]);
|
||||
}
|
||||
var vm = Wtm.CreateVM<FrameworkGroupVM>();
|
||||
return PartialView(vm);
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
[ActionDescription("Sys.Create")]
|
||||
public ActionResult Create(FrameworkGroupVM vm)
|
||||
{
|
||||
if (ConfigInfo.HasMainHost && Wtm.LoginUserInfo?.CurrentTenant == null)
|
||||
{
|
||||
return Content(Localizer["_Admin.HasMainHost"]);
|
||||
}
|
||||
if (!ModelState.IsValid)
|
||||
{
|
||||
return PartialView(vm);
|
||||
}
|
||||
else
|
||||
{
|
||||
vm.DoAdd();
|
||||
return FFResult().CloseDialog().RefreshGrid();
|
||||
}
|
||||
}
|
||||
|
||||
[ActionDescription("Sys.Edit")]
|
||||
public ActionResult Edit(Guid id)
|
||||
{
|
||||
if (ConfigInfo.HasMainHost && Wtm.LoginUserInfo?.CurrentTenant == null)
|
||||
{
|
||||
return Content(Localizer["_Admin.HasMainHost"]);
|
||||
}
|
||||
var vm = Wtm.CreateVM<FrameworkGroupVM>(id);
|
||||
return PartialView(vm);
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
[ActionDescription("Sys.Edit")]
|
||||
[ValidateFormItemOnly]
|
||||
public ActionResult Edit(FrameworkGroupVM vm)
|
||||
{
|
||||
if (ConfigInfo.HasMainHost && Wtm.LoginUserInfo?.CurrentTenant == null)
|
||||
{
|
||||
return Content(Localizer["_Admin.HasMainHost"]);
|
||||
}
|
||||
if (!ModelState.IsValid)
|
||||
{
|
||||
return PartialView(vm);
|
||||
}
|
||||
else
|
||||
{
|
||||
vm.DoEdit();
|
||||
return FFResult().CloseDialog().RefreshGrid();
|
||||
}
|
||||
}
|
||||
|
||||
[ActionDescription("Sys.Delete")]
|
||||
public ActionResult Delete(Guid id)
|
||||
{
|
||||
if (ConfigInfo.HasMainHost && Wtm.LoginUserInfo?.CurrentTenant == null)
|
||||
{
|
||||
return Content(Localizer["_Admin.HasMainHost"]);
|
||||
}
|
||||
var vm = Wtm.CreateVM<FrameworkGroupVM>(id);
|
||||
return PartialView(vm);
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
[ActionDescription("Sys.Delete")]
|
||||
public async Task<ActionResult> Delete(Guid id, IFormCollection noUse)
|
||||
{
|
||||
if (ConfigInfo.HasMainHost && Wtm.LoginUserInfo?.CurrentTenant == null)
|
||||
{
|
||||
return Content(Localizer["_Admin.HasMainHost"]);
|
||||
}
|
||||
var vm = Wtm.CreateVM<FrameworkGroupVM>(id);
|
||||
await vm.DoDeleteAsync();
|
||||
if (!ModelState.IsValid)
|
||||
{
|
||||
return PartialView(vm);
|
||||
}
|
||||
else
|
||||
{
|
||||
return FFResult().CloseDialog().RefreshGrid();
|
||||
}
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
[ActionDescription("Sys.BatchDelete")]
|
||||
public ActionResult BatchDelete(Guid[] ids)
|
||||
{
|
||||
if (ConfigInfo.HasMainHost && Wtm.LoginUserInfo?.CurrentTenant == null)
|
||||
{
|
||||
return Content(Localizer["_Admin.HasMainHost"]);
|
||||
}
|
||||
var vm = Wtm.CreateVM<FrameworkGroupBatchVM>(Ids: ids);
|
||||
return PartialView(vm);
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
[ActionDescription("Sys.BatchDelete")]
|
||||
public async Task<ActionResult> DoBatchDelete(FrameworkGroupBatchVM vm, IFormCollection noUse)
|
||||
{
|
||||
if (ConfigInfo.HasMainHost && Wtm.LoginUserInfo?.CurrentTenant == null)
|
||||
{
|
||||
return Content(Localizer["_Admin.HasMainHost"]);
|
||||
}
|
||||
List<string> GroupCode = DC.Set<FrameworkGroup>().CheckIDs(new List<string>(vm.Ids)).Select(x => x.GroupCode).ToList();
|
||||
if (!ModelState.IsValid || !vm.DoBatchDelete())
|
||||
{
|
||||
return PartialView("BatchDelete", vm);
|
||||
}
|
||||
else
|
||||
{
|
||||
var gr = DC.Set<FrameworkUserGroup>().Where(x => GroupCode.Contains(x.GroupCode)).ToList();
|
||||
var itcodes = gr.Select(x => x.UserCode).ToArray();
|
||||
DC.Set<FrameworkUserGroup>().RemoveRange(gr);
|
||||
DC.SaveChanges();
|
||||
await Wtm.RemoveUserCacheByGroup(GroupCode.ToArray());
|
||||
await Wtm.RemoveGroupCache(Wtm.LoginUserInfo?.CurrentTenant);
|
||||
return FFResult().CloseDialog().RefreshGrid().Alert(Localizer["Sys.OprationSuccess"]);
|
||||
}
|
||||
}
|
||||
|
||||
[ActionDescription("Sys.Import")]
|
||||
public ActionResult Import()
|
||||
{
|
||||
if (ConfigInfo.HasMainHost && Wtm.LoginUserInfo?.CurrentTenant == null)
|
||||
{
|
||||
return Content(Localizer["_Admin.HasMainHost"]);
|
||||
}
|
||||
var vm = Wtm.CreateVM<FrameworkGroupImportVM>();
|
||||
return PartialView(vm);
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
[ActionDescription("Sys.Import")]
|
||||
public ActionResult Import(FrameworkGroupImportVM vm, IFormCollection nouse)
|
||||
{
|
||||
if (ConfigInfo.HasMainHost && Wtm.LoginUserInfo?.CurrentTenant == null)
|
||||
{
|
||||
return Content(Localizer["_Admin.HasMainHost"]);
|
||||
}
|
||||
if (vm.ErrorListVM.EntityList.Count > 0 || !vm.BatchSaveData())
|
||||
{
|
||||
return PartialView(vm);
|
||||
}
|
||||
else
|
||||
{
|
||||
Wtm.RemoveGroupCache(Wtm.LoginUserInfo.CurrentTenant).Wait();
|
||||
return FFResult().CloseDialog().RefreshGrid().Alert(Localizer["Sys.ImportSuccess", vm.EntityList.Count.ToString()]);
|
||||
}
|
||||
}
|
||||
|
||||
[ActionDescription("_Admin.DataPrivilege")]
|
||||
public PartialViewResult DataFunction(string groupcode)
|
||||
{
|
||||
var role = Wtm.CreateVM<FrameworkGroupMDVM>(values: x=>x.GroupCode == groupcode);
|
||||
return PartialView(role);
|
||||
}
|
||||
|
||||
[ActionDescription("_Admin.DataPrivilege")]
|
||||
[HttpPost]
|
||||
public ActionResult DataFunction(FrameworkGroupMDVM vm, IFormCollection noUse)
|
||||
{
|
||||
vm.DoChange();
|
||||
return FFResult().CloseDialog().Alert(Localizer["Sys.OprationSuccess"]);
|
||||
}
|
||||
|
||||
[ActionDescription("Sys.Export")]
|
||||
[HttpPost]
|
||||
public IActionResult ExportExcel(FrameworkGroupListVM vm)
|
||||
{
|
||||
if (ConfigInfo.HasMainHost && Wtm.LoginUserInfo?.CurrentTenant == null)
|
||||
{
|
||||
return Content(Localizer["_Admin.HasMainHost"]);
|
||||
}
|
||||
return vm.GetExportData();
|
||||
}
|
||||
|
||||
[AllRights]
|
||||
public IActionResult GetParents()
|
||||
{
|
||||
WalkingTec.Mvvm.Admin.Api.FrameworkGroupController userapi = new Mvvm.Admin.Api.FrameworkGroupController();
|
||||
userapi.Wtm = Wtm;
|
||||
var rv = userapi.GetParentsTree() as OkObjectResult;
|
||||
List<TreeSelectListItem> users = new List<TreeSelectListItem>();
|
||||
if (rv != null && rv.Value is string && rv.Value != null)
|
||||
{
|
||||
users = System.Text.Json.JsonSerializer.Deserialize<List<TreeSelectListItem>>(rv.Value.ToString());
|
||||
}
|
||||
else if (rv != null && rv.Value is List<TreeSelectListItem> c)
|
||||
{
|
||||
users = c;
|
||||
}
|
||||
return JsonMore(users);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,218 @@
|
||||
// WTM默认页面 Wtm buidin page
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Caching.Memory;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using WalkingTec.Mvvm.Core;
|
||||
using WalkingTec.Mvvm.Core.Extensions;
|
||||
using WalkingTec.Mvvm.Mvc.Admin.ViewModels.FrameworkMenuVMs;
|
||||
|
||||
namespace WalkingTec.Mvvm.Mvc.Admin.Controllers
|
||||
{
|
||||
[Area("_Admin")]
|
||||
[ActionDescription("MenuKey.MenuMangement")]
|
||||
[MainTenantOnly]
|
||||
public class FrameworkMenuController : BaseController
|
||||
{
|
||||
[ActionDescription("Sys.Search")]
|
||||
public ActionResult Index()
|
||||
{
|
||||
var vm = Wtm.CreateVM<FrameworkMenuListVM>();
|
||||
return PartialView(vm);
|
||||
}
|
||||
|
||||
[ActionDescription("Sys.Search")]
|
||||
[HttpPost]
|
||||
public string Search(FrameworkMenuSearcher searcher)
|
||||
{
|
||||
var vm = Wtm.CreateVM<FrameworkMenuListVM>(passInit: true);
|
||||
if (ModelState.IsValid)
|
||||
{
|
||||
vm.Searcher = searcher;
|
||||
return vm.GetJson(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
return vm.GetError();
|
||||
}
|
||||
}
|
||||
|
||||
[ActionDescription("Sys.Create")]
|
||||
public ActionResult Create(Guid? id)
|
||||
{
|
||||
var vm = Wtm.CreateVM<FrameworkMenuVM>();
|
||||
if (id != null)
|
||||
{
|
||||
vm.Entity.ParentId = id;
|
||||
}
|
||||
vm.Entity.IsInside = true;
|
||||
vm.Entity.IsPublic = false;
|
||||
vm.Entity.FolderOnly = false;
|
||||
vm.Entity.ShowOnMenu = true;
|
||||
return PartialView(vm);
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
[Public]
|
||||
[ActionDescription("Sys.Create")]
|
||||
public ActionResult Create(FrameworkMenuVM vm)
|
||||
{
|
||||
if (!ModelState.IsValid)
|
||||
{
|
||||
return PartialView(vm);
|
||||
}
|
||||
else
|
||||
{
|
||||
vm.DoAdd();
|
||||
if (!ModelState.IsValid)
|
||||
{
|
||||
vm.DoReInit();
|
||||
return PartialView(vm);
|
||||
}
|
||||
else
|
||||
{
|
||||
return FFResult().CloseDialog().RefreshGrid();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[ActionDescription("Sys.Edit")]
|
||||
public ActionResult Edit(Guid id)
|
||||
{
|
||||
var vm = Wtm.CreateVM<FrameworkMenuVM>(id);
|
||||
vm.IconSelectItems = !string.IsNullOrEmpty(vm.IconFont) && IconFontsHelper
|
||||
.IconFontDicItems
|
||||
.ContainsKey(vm.IconFont)
|
||||
? IconFontsHelper
|
||||
.IconFontDicItems[vm.IconFont]
|
||||
.Select(x => new ComboSelectListItem()
|
||||
{
|
||||
Text = x.Text,
|
||||
Value = x.Value,
|
||||
Icon = x.Icon
|
||||
}).ToList()
|
||||
: new List<ComboSelectListItem>();
|
||||
|
||||
return PartialView(vm);
|
||||
}
|
||||
|
||||
[ActionDescription("Sys.Edit")]
|
||||
[HttpPost]
|
||||
public ActionResult Edit(FrameworkMenuVM vm)
|
||||
{
|
||||
if (!ModelState.IsValid)
|
||||
{
|
||||
vm.IconSelectItems = !string.IsNullOrEmpty(vm.IconFont) && IconFontsHelper
|
||||
.IconFontDicItems
|
||||
.ContainsKey(vm.IconFont)
|
||||
? IconFontsHelper
|
||||
.IconFontDicItems[vm.IconFont]
|
||||
.Select(x => new ComboSelectListItem()
|
||||
{
|
||||
Text = x.Text,
|
||||
Value = x.Value,
|
||||
Icon = x.Icon
|
||||
}).ToList()
|
||||
: new List<ComboSelectListItem>();
|
||||
return PartialView(vm);
|
||||
}
|
||||
else
|
||||
{
|
||||
vm.DoEdit();
|
||||
if (!ModelState.IsValid)
|
||||
{
|
||||
vm.DoReInit();
|
||||
return PartialView(vm);
|
||||
}
|
||||
else
|
||||
{
|
||||
return FFResult().CloseDialog().RefreshGrid();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[ActionDescription("Sys.Delete")]
|
||||
public ActionResult Delete(Guid id)
|
||||
{
|
||||
var vm = Wtm.CreateVM<FrameworkMenuVM>(id);
|
||||
return PartialView(vm);
|
||||
}
|
||||
|
||||
[ActionDescription("Sys.Delete")]
|
||||
[HttpPost]
|
||||
public ActionResult Delete(Guid id, IFormCollection noUser)
|
||||
{
|
||||
var vm = Wtm.CreateVM<FrameworkMenuVM>(id);
|
||||
vm.DoDelete();
|
||||
if (!ModelState.IsValid)
|
||||
{
|
||||
return PartialView(vm);
|
||||
}
|
||||
else
|
||||
{
|
||||
return FFResult().CloseDialog().RefreshGrid();
|
||||
}
|
||||
}
|
||||
|
||||
[ActionDescription("Sys.Details")]
|
||||
public PartialViewResult Details(Guid id)
|
||||
{
|
||||
var v = Wtm.CreateVM<FrameworkMenuVM>(id);
|
||||
return PartialView("Details", v);
|
||||
}
|
||||
|
||||
[ActionDescription("_Admin.UnsetPages")]
|
||||
public ActionResult UnsetPages()
|
||||
{
|
||||
var vm = Wtm.CreateVM<FrameworkActionListVM>();
|
||||
return PartialView(vm);
|
||||
}
|
||||
|
||||
[ActionDescription("_Admin.RefreshMenu")]
|
||||
public ActionResult RefreshMenu()
|
||||
{
|
||||
Cache.Delete(nameof(GlobalData.AllMenus));
|
||||
return FFResult().Alert(Localizer["Sys.OprationSuccess"]);
|
||||
}
|
||||
|
||||
[ActionDescription("GetActionsByModelId")]
|
||||
[AllRights]
|
||||
public JsonResult GetActionsByModelId(string Id)
|
||||
{
|
||||
if (string.IsNullOrEmpty(Id))
|
||||
{
|
||||
return JsonMore(new List<ComboSelectListItem>());
|
||||
}
|
||||
var modules = Wtm.GlobaInfo.AllModule;
|
||||
var m =Utils.ResetModule(modules);
|
||||
|
||||
List<ComboSelectListItem> AllActions = new List<ComboSelectListItem>();
|
||||
var action = m.Where(x => x.FullName == Id)?.FirstOrDefault().Actions;
|
||||
if (action != null)
|
||||
{
|
||||
var mList = action?.Where(x => x.MethodName != "Index" && x.IgnorePrivillege == false)?.ToList();
|
||||
AllActions = mList.ToListItems(y => y.ActionName, y => y.Url);
|
||||
AllActions.ForEach(x => x.Selected = true);
|
||||
}
|
||||
|
||||
return JsonMore(AllActions);
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
[ResponseCache(Duration = 3600)]
|
||||
[AllRights]
|
||||
public IActionResult GetIconFontItems(string id)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(id) && IconFontsHelper.IconFontDicItems.ContainsKey(id))
|
||||
return JsonMore(IconFontsHelper.IconFontDicItems[id]);
|
||||
else
|
||||
return JsonMore(null);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,243 @@
|
||||
// WTM默认页面 Wtm buidin page
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using WalkingTec.Mvvm.Core;
|
||||
using WalkingTec.Mvvm.Core.Extensions;
|
||||
using WalkingTec.Mvvm.Mvc.Admin.ViewModels.FrameworkRoleVMs;
|
||||
|
||||
namespace WalkingTec.Mvvm.Mvc.Admin.Controllers
|
||||
{
|
||||
[Area("_Admin")]
|
||||
[ActionDescription("MenuKey.RoleManagement")]
|
||||
public class FrameworkRoleController : BaseController
|
||||
{
|
||||
[ActionDescription("Sys.Search")]
|
||||
public ActionResult Index()
|
||||
{
|
||||
var vm = Wtm.CreateVM<FrameworkRoleListVM>();
|
||||
return PartialView(vm);
|
||||
}
|
||||
[ActionDescription("Sys.Search")]
|
||||
[HttpPost]
|
||||
public IActionResult Search(FrameworkRoleSearcher searcher)
|
||||
{
|
||||
if (ConfigInfo.HasMainHost && Wtm.LoginUserInfo?.CurrentTenant == null)
|
||||
{
|
||||
searcher.IsPlainText = false;
|
||||
return Wtm.CallAPI<string>("mainhost", "/api/_frameworkrole/search", HttpMethodEnum.POST, searcher).Result.ToActionResult();
|
||||
}
|
||||
var vm = Wtm.CreateVM<FrameworkRoleListVM>(passInit: true);
|
||||
if (ModelState.IsValid)
|
||||
{
|
||||
vm.Searcher = searcher;
|
||||
return Content(vm.GetJson(false));
|
||||
}
|
||||
else
|
||||
{
|
||||
return Content(vm.GetError());
|
||||
}
|
||||
}
|
||||
|
||||
[ActionDescription("Sys.Create")]
|
||||
public ActionResult Create()
|
||||
{
|
||||
if (ConfigInfo.HasMainHost && Wtm.LoginUserInfo?.CurrentTenant == null)
|
||||
{
|
||||
return Content(Localizer["_Admin.HasMainHost"]);
|
||||
}
|
||||
var vm = Wtm.CreateVM<FrameworkRoleVM>();
|
||||
return PartialView(vm);
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
[ActionDescription("Sys.Create")]
|
||||
public ActionResult Create(FrameworkRoleVM vm)
|
||||
{
|
||||
if (ConfigInfo.HasMainHost && Wtm.LoginUserInfo?.CurrentTenant == null)
|
||||
{
|
||||
return Content(Localizer["_Admin.HasMainHost"]);
|
||||
}
|
||||
if (!ModelState.IsValid)
|
||||
{
|
||||
return PartialView(vm);
|
||||
}
|
||||
else
|
||||
{
|
||||
vm.DoAdd();
|
||||
return FFResult().CloseDialog().RefreshGrid();
|
||||
}
|
||||
}
|
||||
|
||||
[ActionDescription("Sys.Edit")]
|
||||
public ActionResult Edit(Guid id)
|
||||
{
|
||||
if (ConfigInfo.HasMainHost && Wtm.LoginUserInfo?.CurrentTenant == null)
|
||||
{
|
||||
return Content(Localizer["_Admin.HasMainHost"]);
|
||||
}
|
||||
var vm = Wtm.CreateVM<FrameworkRoleVM>(id);
|
||||
return PartialView(vm);
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
[ActionDescription("Sys.Edit")]
|
||||
[ValidateFormItemOnly]
|
||||
public ActionResult Edit(FrameworkRoleVM vm)
|
||||
{
|
||||
if (ConfigInfo.HasMainHost && Wtm.LoginUserInfo?.CurrentTenant == null)
|
||||
{
|
||||
return Content(Localizer["_Admin.HasMainHost"]);
|
||||
}
|
||||
if (!ModelState.IsValid)
|
||||
{
|
||||
return PartialView(vm);
|
||||
}
|
||||
else
|
||||
{
|
||||
vm.DoEdit();
|
||||
return FFResult().CloseDialog().RefreshGrid();
|
||||
}
|
||||
}
|
||||
|
||||
[ActionDescription("Sys.Delete")]
|
||||
public ActionResult Delete(Guid id)
|
||||
{
|
||||
if (ConfigInfo.HasMainHost && Wtm.LoginUserInfo?.CurrentTenant == null)
|
||||
{
|
||||
return Content(Localizer["_Admin.HasMainHost"]);
|
||||
}
|
||||
var vm = Wtm.CreateVM<FrameworkRoleVM>(id);
|
||||
return PartialView(vm);
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
[ActionDescription("Sys.Delete")]
|
||||
public async Task<ActionResult> Delete(Guid id, IFormCollection noUse)
|
||||
{
|
||||
if (ConfigInfo.HasMainHost && Wtm.LoginUserInfo?.CurrentTenant == null)
|
||||
{
|
||||
return Content(Localizer["_Admin.HasMainHost"]);
|
||||
}
|
||||
var vm = Wtm.CreateVM<FrameworkRoleVM>(id);
|
||||
await vm.DoDeleteAsync();
|
||||
if (!ModelState.IsValid)
|
||||
{
|
||||
return PartialView(vm);
|
||||
}
|
||||
else
|
||||
{
|
||||
return FFResult().CloseDialog().RefreshGrid();
|
||||
}
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
[ActionDescription("Sys.BatchDelete")]
|
||||
public ActionResult BatchDelete(Guid[] ids)
|
||||
{
|
||||
if (ConfigInfo.HasMainHost && Wtm.LoginUserInfo?.CurrentTenant == null)
|
||||
{
|
||||
return Content(Localizer["_Admin.HasMainHost"]);
|
||||
}
|
||||
var vm = Wtm.CreateVM<FrameworkRoleBatchVM>(Ids: ids);
|
||||
return PartialView(vm);
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
[ActionDescription("Sys.BatchDelete")]
|
||||
public async Task<ActionResult> DoBatchDelete(FrameworkRoleBatchVM vm, IFormCollection noUse)
|
||||
{
|
||||
if (ConfigInfo.HasMainHost && Wtm.LoginUserInfo?.CurrentTenant == null)
|
||||
{
|
||||
return Content(Localizer["_Admin.HasMainHost"]);
|
||||
}
|
||||
List<string> RoleCode = DC.Set<FrameworkRole>().CheckIDs(new List<string>(vm.Ids)).Select(x => x.RoleCode).ToList();
|
||||
if (!ModelState.IsValid || !vm.DoBatchDelete())
|
||||
{
|
||||
return PartialView("BatchDelete", vm);
|
||||
}
|
||||
else
|
||||
{
|
||||
var ur = DC.Set<FrameworkUserRole>().Where(x => RoleCode.Contains(x.RoleCode)).ToList();
|
||||
var itcodes = ur.Select(x => x.UserCode).ToArray();
|
||||
DC.Set<FrameworkUserRole>().RemoveRange(ur);
|
||||
DC.SaveChanges();
|
||||
await Wtm.RemoveUserCacheByRole(RoleCode.ToArray());
|
||||
await Wtm.RemoveRoleCache(Wtm.LoginUserInfo.CurrentTenant);
|
||||
return FFResult().CloseDialog().RefreshGrid();
|
||||
}
|
||||
}
|
||||
|
||||
[ActionDescription("Sys.Import")]
|
||||
public ActionResult Import()
|
||||
{
|
||||
if (ConfigInfo.HasMainHost && Wtm.LoginUserInfo?.CurrentTenant == null)
|
||||
{
|
||||
return Content(Localizer["_Admin.HasMainHost"]);
|
||||
}
|
||||
var vm = Wtm.CreateVM<FrameworkRoleImportVM>();
|
||||
return PartialView(vm);
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
[ActionDescription("Sys.Import")]
|
||||
public ActionResult Import(FrameworkRoleImportVM vm, IFormCollection nouse)
|
||||
{
|
||||
if (ConfigInfo.HasMainHost && Wtm.LoginUserInfo?.CurrentTenant == null)
|
||||
{
|
||||
return Content(Localizer["_Admin.HasMainHost"]);
|
||||
}
|
||||
if (vm.ErrorListVM.EntityList.Count > 0 || !vm.BatchSaveData())
|
||||
{
|
||||
return PartialView(vm);
|
||||
}
|
||||
else
|
||||
{
|
||||
Wtm.RemoveRoleCache(Wtm.LoginUserInfo.CurrentTenant).Wait();
|
||||
return FFResult().CloseDialog().RefreshGrid().Alert(Localizer["Sys.ImportSuccess", vm.EntityList.Count.ToString()]);
|
||||
}
|
||||
}
|
||||
|
||||
[ActionDescription("Sys.Details")]
|
||||
public PartialViewResult Details(Guid id)
|
||||
{
|
||||
var role = Wtm.CreateVM<FrameworkRoleMDVM>(id);
|
||||
role.ListVM.SearcherMode = ListVMSearchModeEnum.Custom1;
|
||||
return PartialView(role);
|
||||
}
|
||||
|
||||
[ActionDescription("_Admin.PageFunction")]
|
||||
public PartialViewResult PageFunction(Guid id)
|
||||
{
|
||||
var role = Wtm.CreateVM<FrameworkRoleMDVM>(id);
|
||||
role.ListVM.SearcherMode = ListVMSearchModeEnum.Custom2;
|
||||
return PartialView(role);
|
||||
}
|
||||
|
||||
[ActionDescription("_Admin.PageFunction")]
|
||||
[HttpPost]
|
||||
public async Task<ActionResult> PageFunction(FrameworkRoleMDVM vm, IFormCollection noUse)
|
||||
{
|
||||
await vm.DoChangeAsync();
|
||||
//if(vm.MSD.IsValid == false)
|
||||
//{
|
||||
// return FFResult().CloseDialog().Alert(vm.MSD.GetFirstError());
|
||||
//}
|
||||
return FFResult().CloseDialog().Alert(Localizer["Sys.OprationSuccess"]);
|
||||
}
|
||||
|
||||
[ActionDescription("Sys.Export")]
|
||||
[HttpPost]
|
||||
public IActionResult ExportExcel(FrameworkRoleListVM vm)
|
||||
{
|
||||
if (ConfigInfo.HasMainHost && Wtm.LoginUserInfo?.CurrentTenant == null)
|
||||
{
|
||||
return Content(Localizer["_Admin.HasMainHost"]);
|
||||
}
|
||||
return vm.GetExportData();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,294 @@
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using System;
|
||||
using WalkingTec.Mvvm.Core;
|
||||
using WalkingTec.Mvvm.Mvc;
|
||||
using WalkingTec.Mvvm.Core.Extensions;
|
||||
using WalkingTec.Mvvm.Mvc.Admin.ViewModels.FrameworkTenantVMs;
|
||||
using System.Linq;
|
||||
|
||||
namespace WalkingTec.Mvvm.Mvc.Admin.Controllers
|
||||
{
|
||||
[Area("_Admin")]
|
||||
[ActionDescription("MenuKey.FrameworkTenant")]
|
||||
[FixConnection(CsName = "default")]
|
||||
public partial class FrameworkTenantController : BaseController
|
||||
{
|
||||
#region Search
|
||||
[ActionDescription("Sys.Search")]
|
||||
public ActionResult Index()
|
||||
{
|
||||
if(CanUseTenant() == false)
|
||||
{
|
||||
return Content(Localizer["_Admin.TenantNotAllowed"]);
|
||||
}
|
||||
var vm = Wtm.CreateVM<FrameworkTenantListVM>();
|
||||
return PartialView(vm);
|
||||
}
|
||||
|
||||
[ActionDescription("Sys.Search")]
|
||||
[HttpPost]
|
||||
public IActionResult Search(FrameworkTenantSearcher searcher)
|
||||
{
|
||||
if (CanUseTenant() == false)
|
||||
{
|
||||
return Content(Localizer["_Admin.TenantNotAllowed"]);
|
||||
}
|
||||
var vm = Wtm.CreateVM<FrameworkTenantListVM>(passInit: true);
|
||||
if (ModelState.IsValid)
|
||||
{
|
||||
vm.Searcher = searcher;
|
||||
return Content(vm.GetJson(false));
|
||||
}
|
||||
else
|
||||
{
|
||||
return Content(vm.GetError());
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Create
|
||||
[ActionDescription("Sys.Create")]
|
||||
public ActionResult Create()
|
||||
{
|
||||
if (CanUseTenant() == false)
|
||||
{
|
||||
return Content(Localizer["_Admin.TenantNotAllowed"]);
|
||||
}
|
||||
var vm = Wtm.CreateVM<FrameworkTenantVM>();
|
||||
return PartialView(vm);
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
[ActionDescription("Sys.Create")]
|
||||
public ActionResult Create(FrameworkTenantVM vm)
|
||||
{
|
||||
if (CanUseTenant() == false)
|
||||
{
|
||||
return Content(Localizer["_Admin.TenantNotAllowed"]);
|
||||
}
|
||||
if (!ModelState.IsValid)
|
||||
{
|
||||
return PartialView(vm);
|
||||
}
|
||||
else
|
||||
{
|
||||
vm.DoAdd();
|
||||
if (!ModelState.IsValid)
|
||||
{
|
||||
vm.DoReInit();
|
||||
return PartialView(vm);
|
||||
}
|
||||
else
|
||||
{
|
||||
return FFResult().CloseDialog().RefreshGrid();
|
||||
}
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Edit
|
||||
[ActionDescription("Sys.Edit")]
|
||||
public ActionResult Edit(string id)
|
||||
{
|
||||
if (CanUseTenant() == false)
|
||||
{
|
||||
return Content(Localizer["_Admin.TenantNotAllowed"]);
|
||||
}
|
||||
var vm = Wtm.CreateVM<FrameworkTenantVM>(id);
|
||||
return PartialView(vm);
|
||||
}
|
||||
|
||||
[ActionDescription("Sys.Edit")]
|
||||
[HttpPost]
|
||||
[ValidateFormItemOnly]
|
||||
public ActionResult Edit(FrameworkTenantVM vm)
|
||||
{
|
||||
if (CanUseTenant() == false)
|
||||
{
|
||||
return Content(Localizer["_Admin.TenantNotAllowed"]);
|
||||
}
|
||||
if (!ModelState.IsValid)
|
||||
{
|
||||
return PartialView(vm);
|
||||
}
|
||||
else
|
||||
{
|
||||
vm.DoEdit();
|
||||
if (!ModelState.IsValid)
|
||||
{
|
||||
vm.DoReInit();
|
||||
return PartialView(vm);
|
||||
}
|
||||
else
|
||||
{
|
||||
return FFResult().CloseDialog().RefreshGridRow(vm.Entity.ID);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Delete
|
||||
[ActionDescription("Sys.Delete")]
|
||||
public ActionResult Delete(string id)
|
||||
{
|
||||
if (CanUseTenant() == false)
|
||||
{
|
||||
return Content(Localizer["_Admin.TenantNotAllowed"]);
|
||||
}
|
||||
var vm = Wtm.CreateVM<FrameworkTenantVM>(id);
|
||||
return PartialView(vm);
|
||||
}
|
||||
|
||||
[ActionDescription("Sys.Delete")]
|
||||
[HttpPost]
|
||||
public ActionResult Delete(string id, IFormCollection nouse)
|
||||
{
|
||||
if (CanUseTenant() == false)
|
||||
{
|
||||
return Content(Localizer["_Admin.TenantNotAllowed"]);
|
||||
}
|
||||
var vm = Wtm.CreateVM<FrameworkTenantVM>(id);
|
||||
vm.DoDelete();
|
||||
if (!ModelState.IsValid)
|
||||
{
|
||||
return PartialView(vm);
|
||||
}
|
||||
else
|
||||
{
|
||||
return FFResult().CloseDialog().RefreshGrid();
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Details
|
||||
[ActionDescription("Sys.Details")]
|
||||
public ActionResult Details(string id)
|
||||
{
|
||||
if (CanUseTenant() == false)
|
||||
{
|
||||
return Content(Localizer["_Admin.TenantNotAllowed"]);
|
||||
}
|
||||
var vm = Wtm.CreateVM<FrameworkTenantVM>(id);
|
||||
return PartialView(vm);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region BatchEdit
|
||||
[HttpPost]
|
||||
[ActionDescription("Sys.BatchEdit")]
|
||||
public ActionResult BatchEdit(string[] IDs)
|
||||
{
|
||||
if (CanUseTenant() == false)
|
||||
{
|
||||
return Content(Localizer["_Admin.TenantNotAllowed"]);
|
||||
}
|
||||
var vm = Wtm.CreateVM<FrameworkTenantBatchVM>(Ids: IDs);
|
||||
return PartialView(vm);
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
[ActionDescription("Sys.BatchEdit")]
|
||||
public ActionResult DoBatchEdit(FrameworkTenantBatchVM vm, IFormCollection nouse)
|
||||
{
|
||||
if (CanUseTenant() == false)
|
||||
{
|
||||
return Content(Localizer["_Admin.TenantNotAllowed"]);
|
||||
}
|
||||
if (!ModelState.IsValid || !vm.DoBatchEdit())
|
||||
{
|
||||
return PartialView("BatchEdit",vm);
|
||||
}
|
||||
else
|
||||
{
|
||||
return FFResult().CloseDialog().RefreshGrid().Alert(Localizer["Sys.BatchEditSuccess", vm.Ids.Length]);
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region BatchDelete
|
||||
[HttpPost]
|
||||
[ActionDescription("Sys.BatchDelete")]
|
||||
public ActionResult BatchDelete(string[] IDs)
|
||||
{
|
||||
if (CanUseTenant() == false)
|
||||
{
|
||||
return Content(Localizer["_Admin.TenantNotAllowed"]);
|
||||
}
|
||||
var vm = Wtm.CreateVM<FrameworkTenantBatchVM>(Ids: IDs);
|
||||
return PartialView(vm);
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
[ActionDescription("Sys.BatchDelete")]
|
||||
public ActionResult DoBatchDelete(FrameworkTenantBatchVM vm, IFormCollection nouse)
|
||||
{
|
||||
if (CanUseTenant() == false)
|
||||
{
|
||||
return Content(Localizer["_Admin.TenantNotAllowed"]);
|
||||
}
|
||||
if (!ModelState.IsValid || !vm.DoBatchDelete())
|
||||
{
|
||||
return PartialView("BatchDelete",vm);
|
||||
}
|
||||
else
|
||||
{
|
||||
Cache.Delete(nameof(GlobalData.AllTenant));
|
||||
return FFResult().CloseDialog().RefreshGrid().Alert(Localizer["Sys.BatchDeleteSuccess", vm.Ids.Length]);
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Import
|
||||
[ActionDescription("Sys.Import")]
|
||||
public ActionResult Import()
|
||||
{
|
||||
if (CanUseTenant() == false)
|
||||
{
|
||||
return Content(Localizer["_Admin.TenantNotAllowed"]);
|
||||
}
|
||||
var vm = Wtm.CreateVM<FrameworkTenantImportVM>();
|
||||
return PartialView(vm);
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
[ActionDescription("Sys.Import")]
|
||||
public ActionResult Import(FrameworkTenantImportVM vm, IFormCollection nouse)
|
||||
{
|
||||
if (CanUseTenant() == false)
|
||||
{
|
||||
return Content(Localizer["_Admin.TenantNotAllowed"]);
|
||||
}
|
||||
if (vm.ErrorListVM.EntityList.Count > 0 || !vm.BatchSaveData())
|
||||
{
|
||||
return PartialView(vm);
|
||||
}
|
||||
else
|
||||
{
|
||||
return FFResult().CloseDialog().RefreshGrid().Alert(Localizer["Sys.ImportSuccess", vm.EntityList.Count.ToString()]);
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
[ActionDescription("Sys.Export")]
|
||||
[HttpPost]
|
||||
public IActionResult ExportExcel(FrameworkTenantListVM vm)
|
||||
{
|
||||
if (CanUseTenant() == false)
|
||||
{
|
||||
return Content(Localizer["_Admin.TenantNotAllowed"]);
|
||||
}
|
||||
return vm.GetExportData();
|
||||
}
|
||||
|
||||
private bool CanUseTenant()
|
||||
{
|
||||
if(Wtm.LoginUserInfo != null && (Wtm.LoginUserInfo.CurrentTenant == null || Wtm.GlobaInfo.AllTenant.Any(x=>x.TCode == Wtm.LoginUserInfo.CurrentTenant && x.Enabled==true && x.EnableSub == true)))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,407 @@
|
||||
// WTM默认页面 Wtm buidin page
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using System;
|
||||
using System.Linq;
|
||||
using WalkingTec.Mvvm.Core;
|
||||
using WalkingTec.Mvvm.Mvc.Admin.ViewModels.FrameworkUserVms;
|
||||
using WalkingTec.Mvvm.Core.Extensions;
|
||||
using System.Threading.Tasks;
|
||||
using System.Collections.Generic;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
|
||||
namespace WalkingTec.Mvvm.Mvc.Admin.Controllers
|
||||
{
|
||||
[Area("_Admin")]
|
||||
[ActionDescription("MenuKey.UserManagement")]
|
||||
public class FrameworkUserController : BaseController
|
||||
{
|
||||
[ActionDescription("Sys.Search", IsPage = true)]
|
||||
public ActionResult Index()
|
||||
{
|
||||
if (ConfigInfo.HasMainHost && Wtm.LoginUserInfo?.CurrentTenant == null)
|
||||
{
|
||||
return Content(Localizer["_Admin.HasMainHost"]);
|
||||
}
|
||||
var vm = Wtm.CreateVM<FrameworkUserListVM>();
|
||||
// vm.Searcher.IsValid = true;
|
||||
return PartialView(vm);
|
||||
}
|
||||
|
||||
[ActionDescription("Sys.Search")]
|
||||
[HttpPost]
|
||||
public string Search(FrameworkUserSearcher searcher)
|
||||
{
|
||||
if (ConfigInfo.HasMainHost && Wtm.LoginUserInfo?.CurrentTenant == null)
|
||||
{
|
||||
return Localizer["_Admin.HasMainHost"];
|
||||
}
|
||||
var vm = Wtm.CreateVM<FrameworkUserListVM>(passInit: true);
|
||||
if (ModelState.IsValid)
|
||||
{
|
||||
vm.Searcher = searcher;
|
||||
return vm.GetJson(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
return vm.GetError();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
[ActionDescription("Sys.Create")]
|
||||
public ActionResult Create()
|
||||
{
|
||||
if (ConfigInfo.HasMainHost && Wtm.LoginUserInfo?.CurrentTenant == null)
|
||||
{
|
||||
return Content(Localizer["_Admin.HasMainHost"]);
|
||||
}
|
||||
var vm = Wtm.CreateVM<FrameworkUserVM>();
|
||||
return PartialView(vm);
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
[ActionDescription("Sys.Create")]
|
||||
public async Task<ActionResult> Create(FrameworkUserVM vm)
|
||||
{
|
||||
if (ConfigInfo.HasMainHost && Wtm.LoginUserInfo?.CurrentTenant == null)
|
||||
{
|
||||
return Content(Localizer["_Admin.HasMainHost"]);
|
||||
}
|
||||
if (!ModelState.IsValid)
|
||||
{
|
||||
return PartialView(vm);
|
||||
}
|
||||
else
|
||||
{
|
||||
await vm.DoAddAsync();
|
||||
if (!ModelState.IsValid)
|
||||
{
|
||||
vm.DoReInit();
|
||||
return PartialView(vm);
|
||||
}
|
||||
else
|
||||
{
|
||||
return FFResult().CloseDialog().RefreshGrid();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[ActionDescription("Sys.Edit")]
|
||||
public ActionResult Edit(string id)
|
||||
{
|
||||
if (ConfigInfo.HasMainHost && Wtm.LoginUserInfo?.CurrentTenant == null)
|
||||
{
|
||||
return Content(Localizer["_Admin.HasMainHost"]);
|
||||
}
|
||||
var vm = Wtm.CreateVM<FrameworkUserVM>(id);
|
||||
vm.Entity.Password = null;
|
||||
return PartialView(vm);
|
||||
}
|
||||
|
||||
[ActionDescription("Sys.Edit")]
|
||||
[HttpPost]
|
||||
[ValidateFormItemOnly]
|
||||
public async Task<ActionResult> Edit(FrameworkUserVM vm)
|
||||
{
|
||||
if (ConfigInfo.HasMainHost && Wtm.LoginUserInfo?.CurrentTenant == null)
|
||||
{
|
||||
return Content(Localizer["_Admin.HasMainHost"]);
|
||||
}
|
||||
if (ModelState.Any(x => x.Key != "Entity.Password" && x.Value.ValidationState == Microsoft.AspNetCore.Mvc.ModelBinding.ModelValidationState.Invalid))
|
||||
{
|
||||
return PartialView(vm);
|
||||
}
|
||||
else
|
||||
{
|
||||
ModelState.Clear();
|
||||
await vm.DoEditAsync();
|
||||
if (!ModelState.IsValid)
|
||||
{
|
||||
vm.DoReInit();
|
||||
return PartialView(vm);
|
||||
}
|
||||
else
|
||||
{
|
||||
return FFResult().CloseDialog().RefreshGridRow(vm.Entity.ID);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[ActionDescription("Login.ChangePassword")]
|
||||
public ActionResult Password(Guid id)
|
||||
{
|
||||
if (ConfigInfo.HasMainHost && Wtm.LoginUserInfo?.CurrentTenant == null)
|
||||
{
|
||||
return Content(Localizer["_Admin.HasMainHost"]);
|
||||
}
|
||||
var vm = Wtm.CreateVM<FrameworkUserVM>(id, passInit: true);
|
||||
vm.Entity.Password = null;
|
||||
return PartialView(vm);
|
||||
}
|
||||
|
||||
[ActionDescription("Login.ChangePassword")]
|
||||
[HttpPost]
|
||||
public ActionResult Password(FrameworkUserVM vm)
|
||||
{
|
||||
if (ConfigInfo.HasMainHost && Wtm.LoginUserInfo?.CurrentTenant == null)
|
||||
{
|
||||
return Content(Localizer["_Admin.HasMainHost"]);
|
||||
}
|
||||
var keys = ModelState.Keys.ToList();
|
||||
foreach (var item in keys)
|
||||
{
|
||||
if (item != "Entity.Password")
|
||||
{
|
||||
ModelState.Remove(item);
|
||||
}
|
||||
}
|
||||
if (ModelState.IsValid == false)
|
||||
{
|
||||
return PartialView(vm);
|
||||
}
|
||||
else
|
||||
{
|
||||
vm.ChangePassword();
|
||||
if (!ModelState.IsValid)
|
||||
{
|
||||
vm.DoReInit();
|
||||
return PartialView(vm);
|
||||
}
|
||||
else
|
||||
{
|
||||
return FFResult().CloseDialog().RefreshGridRow(vm.Entity.ID);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[ActionDescription("Sys.Delete")]
|
||||
public ActionResult Delete(Guid id)
|
||||
{
|
||||
if (ConfigInfo.HasMainHost && Wtm.LoginUserInfo?.CurrentTenant == null)
|
||||
{
|
||||
return Content(Localizer["_Admin.HasMainHost"]);
|
||||
}
|
||||
var vm = Wtm.CreateVM<FrameworkUserVM>(id);
|
||||
return PartialView(vm);
|
||||
}
|
||||
|
||||
[ActionDescription("Sys.Delete")]
|
||||
[HttpPost]
|
||||
public async Task<ActionResult> Delete(Guid id, IFormCollection nouse)
|
||||
{
|
||||
if (ConfigInfo.HasMainHost && Wtm.LoginUserInfo?.CurrentTenant == null)
|
||||
{
|
||||
return Content(Localizer["_Admin.HasMainHost"]);
|
||||
}
|
||||
var vm = Wtm.CreateVM<FrameworkUserVM>(id);
|
||||
await vm.DoDeleteAsync();
|
||||
if (!ModelState.IsValid)
|
||||
{
|
||||
return PartialView(vm);
|
||||
}
|
||||
else
|
||||
{
|
||||
return FFResult().CloseDialog().RefreshGrid();
|
||||
}
|
||||
}
|
||||
|
||||
[ActionDescription("Sys.Details")]
|
||||
public PartialViewResult Details(Guid id)
|
||||
{
|
||||
var v = Wtm.CreateVM<FrameworkUserVM>(id);
|
||||
return PartialView("Details", v);
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
[ActionDescription("Sys.BatchEdit")]
|
||||
public ActionResult BatchEdit(string[] IDs)
|
||||
{
|
||||
if (ConfigInfo.HasMainHost && Wtm.LoginUserInfo?.CurrentTenant == null)
|
||||
{
|
||||
return Content(Localizer["_Admin.HasMainHost"]);
|
||||
}
|
||||
var vm = Wtm.CreateVM<FrameworkUserBatchVM>(Ids: IDs);
|
||||
return PartialView(vm);
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
[ActionDescription("Sys.BatchEdit")]
|
||||
public ActionResult DoBatchEdit(FrameworkUserBatchVM vm, IFormCollection nouse)
|
||||
{
|
||||
if (ConfigInfo.HasMainHost && Wtm.LoginUserInfo?.CurrentTenant == null)
|
||||
{
|
||||
return Content(Localizer["_Admin.HasMainHost"]);
|
||||
}
|
||||
if (!ModelState.IsValid || !vm.DoBatchEdit())
|
||||
{
|
||||
return PartialView("BatchEdit", vm);
|
||||
}
|
||||
else
|
||||
{
|
||||
return FFResult().CloseDialog().RefreshGrid().Alert(Localizer["Sys.BatchEditSuccess", vm.Ids.Length]);
|
||||
}
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
[ActionDescription("Sys.BatchDelete")]
|
||||
public ActionResult BatchDelete(string[] IDs)
|
||||
{
|
||||
if (ConfigInfo.HasMainHost && Wtm.LoginUserInfo?.CurrentTenant == null)
|
||||
{
|
||||
return Content(Localizer["_Admin.HasMainHost"]);
|
||||
}
|
||||
var vm = Wtm.CreateVM<FrameworkUserBatchVM>(Ids: IDs);
|
||||
return PartialView(vm);
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
[ActionDescription("Sys.BatchDelete")]
|
||||
public async Task<ActionResult> DoBatchDelete(FrameworkUserBatchVM vm, IFormCollection nouse)
|
||||
{
|
||||
if (ConfigInfo.HasMainHost && Wtm.LoginUserInfo?.CurrentTenant == null)
|
||||
{
|
||||
return Content(Localizer["_Admin.HasMainHost"]);
|
||||
}
|
||||
List<string> itcode = new List<string>();
|
||||
itcode = DC.Set<FrameworkUser>().CheckIDs(new List<string>(vm.Ids)).Select(x => x.ITCode).ToList();
|
||||
if (!ModelState.IsValid || !vm.DoBatchDelete())
|
||||
{
|
||||
return PartialView("BatchDelete", vm);
|
||||
}
|
||||
else
|
||||
{
|
||||
using (var tran = DC.BeginTransaction())
|
||||
{
|
||||
try
|
||||
{
|
||||
var ur = DC.Set<FrameworkUserRole>().Where(x => itcode.Contains(x.UserCode));
|
||||
DC.Set<FrameworkUserRole>().RemoveRange(ur);
|
||||
var ug = DC.Set<FrameworkUserGroup>().Where(x => itcode.Contains(x.UserCode));
|
||||
DC.Set<FrameworkUserGroup>().RemoveRange(ug);
|
||||
DC.SaveChanges();
|
||||
tran.Commit();
|
||||
}
|
||||
catch
|
||||
{
|
||||
tran.Rollback();
|
||||
}
|
||||
}
|
||||
|
||||
await Wtm.RemoveUserCache(itcode.ToArray());
|
||||
return FFResult().CloseDialog().RefreshGrid().Alert(Localizer["Sys.OprationSuccess"]);
|
||||
}
|
||||
}
|
||||
|
||||
[ActionDescription("Sys.Import")]
|
||||
public ActionResult Import()
|
||||
{
|
||||
if (ConfigInfo.HasMainHost && Wtm.LoginUserInfo?.CurrentTenant == null)
|
||||
{
|
||||
return Content(Localizer["_Admin.HasMainHost"]);
|
||||
}
|
||||
var vm = Wtm.CreateVM<FrameworkUserImportVM>();
|
||||
return PartialView(vm);
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
[ActionDescription("Sys.Import")]
|
||||
public ActionResult Import(FrameworkUserImportVM vm, IFormCollection nouse)
|
||||
{
|
||||
if (ConfigInfo.HasMainHost && Wtm.LoginUserInfo?.CurrentTenant == null)
|
||||
{
|
||||
return Content(Localizer["_Admin.HasMainHost"]);
|
||||
}
|
||||
if (vm.ErrorListVM.EntityList.Count > 0 || !vm.BatchSaveData())
|
||||
{
|
||||
return PartialView(vm);
|
||||
}
|
||||
else
|
||||
{
|
||||
return FFResult().CloseDialog().RefreshGrid().Alert(Localizer["Sys.ImportSuccess", vm.EntityList.Count.ToString()]);
|
||||
}
|
||||
}
|
||||
|
||||
[ActionDescription("Sys.Enable")]
|
||||
public ActionResult Enable(Guid id, bool enable)
|
||||
{
|
||||
if (ConfigInfo.HasMainHost && Wtm.LoginUserInfo?.CurrentTenant == null)
|
||||
{
|
||||
return Content(Localizer["_Admin.HasMainHost"]);
|
||||
}
|
||||
FrameworkUser user = new FrameworkUser { ID = id };
|
||||
user.IsValid = enable;
|
||||
DC.UpdateProperty(user, x => x.IsValid);
|
||||
DC.SaveChanges();
|
||||
return FFResult().RefreshGrid(CurrentWindowId);
|
||||
}
|
||||
|
||||
[AllRights]
|
||||
public ActionResult GetUserById(string keywords)
|
||||
{
|
||||
WalkingTec.Mvvm.Admin.Api.AccountController userapi = new WalkingTec.Mvvm.Admin.Api.AccountController();
|
||||
userapi.Wtm = Wtm;
|
||||
var rv = userapi.GetUserById(keywords) as OkObjectResult;
|
||||
List<ComboSelectListItem> users = new List<ComboSelectListItem>();
|
||||
if (rv != null && rv.Value is string && rv.Value != null)
|
||||
{
|
||||
users = System.Text.Json.JsonSerializer.Deserialize<List<ComboSelectListItem>>(rv.Value.ToString());
|
||||
}
|
||||
else if (rv != null && rv.Value is List<ComboSelectListItem> c)
|
||||
{
|
||||
users = c;
|
||||
}
|
||||
return JsonMore(users);
|
||||
|
||||
}
|
||||
|
||||
[ActionDescription("Sys.Export")]
|
||||
[HttpPost]
|
||||
public IActionResult ExportExcel(FrameworkUserListVM vm)
|
||||
{
|
||||
if (ConfigInfo.HasMainHost && Wtm.LoginUserInfo?.CurrentTenant == null)
|
||||
{
|
||||
return Content(Localizer["_Admin.HasMainHost"]);
|
||||
}
|
||||
return vm.GetExportData();
|
||||
}
|
||||
|
||||
[AllRights]
|
||||
public IActionResult GetFrameworkRoles()
|
||||
{
|
||||
WalkingTec.Mvvm.Admin.Api.AccountController userapi = new WalkingTec.Mvvm.Admin.Api.AccountController();
|
||||
userapi.Wtm = Wtm;
|
||||
var rv = userapi.GetFrameworkRoles() as OkObjectResult;
|
||||
List<ComboSelectListItem> users = new List<ComboSelectListItem>();
|
||||
if (rv != null && rv.Value is string && rv.Value != null)
|
||||
{
|
||||
users = System.Text.Json.JsonSerializer.Deserialize<List<ComboSelectListItem>>(rv.Value.ToString());
|
||||
}
|
||||
else if (rv != null && rv.Value is List<ComboSelectListItem> c)
|
||||
{
|
||||
users = c;
|
||||
}
|
||||
return JsonMore(users);
|
||||
}
|
||||
|
||||
[AllRights]
|
||||
public IActionResult GetFrameworkGroups()
|
||||
{
|
||||
WalkingTec.Mvvm.Admin.Api.AccountController userapi = new WalkingTec.Mvvm.Admin.Api.AccountController();
|
||||
userapi.Wtm = Wtm;
|
||||
var rv = userapi.GetFrameworkGroupsTree() as OkObjectResult;
|
||||
List<TreeSelectListItem> users = new List<TreeSelectListItem>();
|
||||
if (rv != null && rv.Value is string && rv.Value != null)
|
||||
{
|
||||
users = System.Text.Json.JsonSerializer.Deserialize<List<TreeSelectListItem>>(rv.Value.ToString());
|
||||
}
|
||||
else if (rv != null && rv.Value is List<TreeSelectListItem> c)
|
||||
{
|
||||
users = c;
|
||||
}
|
||||
return JsonMore(users);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user