添加项目文件。

This commit is contained in:
zel
2025-03-05 19:42:01 +08:00
parent 659f1a2ad9
commit 47dcdeb55d
582 changed files with 242004 additions and 0 deletions

View File

@@ -0,0 +1,109 @@
using Microsoft.AspNetCore.Mvc;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using WaterCloud.Code;
using WaterCloud.Domain.SystemOrganize;
using WaterCloud.Service.SystemOrganize;
namespace WaterCloud.Web.Areas.SystemOrganize.Controllers
{
/// <summary>
/// 创 建:超级管理员
/// 日 期2020-06-01 09:44
/// 描 述:数据权限控制器类
/// </summary>
[Area("SystemOrganize")]
public class DataPrivilegeRuleController : BaseController
{
public DataPrivilegeRuleService _service { get; set; }
#region
[HandlerAjaxOnly]
[IgnoreAntiforgeryToken]
public async Task<ActionResult> GetGridJson(SoulPage<DataPrivilegeRuleEntity> pagination, string keyword)
{
if (string.IsNullOrEmpty(pagination.field))
{
pagination.field = "F_Id";
pagination.order = "desc";
}
var data = await _service.GetLookList(pagination, keyword);
return Content(pagination.setData(data).ToJson());
}
[HttpGet]
[HandlerAjaxOnly]
public async Task<ActionResult> GetListJson(string keyword)
{
var data = await _service.GetList(keyword);
return Content(data.ToJson());
}
[HttpGet]
[HandlerAjaxOnly]
public async Task<ActionResult> GetFormJson(string keyValue)
{
var data = await _service.GetLookForm(keyValue);
return Content(data.ToJson());
}
[HttpGet]
public virtual ActionResult RuleForm()
{
return View();
}
#endregion
#region
[HttpPost]
[HandlerAjaxOnly]
public async Task<ActionResult> SubmitForm(DataPrivilegeRuleEntity entity, string listData, string keyValue)
{
var filterList = JsonConvert.DeserializeObject<List<FilterList>>(listData);
foreach (var item in filterList)
{
if (!string.IsNullOrEmpty(item.Description))
{
entity.F_Description += item.Description + ",";
}
}
if (!string.IsNullOrEmpty(entity.F_Description))
{
entity.F_Description = entity.F_Description.Substring(0, entity.F_Description.Length - 1);
}
entity.F_PrivilegeRules = filterList.ToJson();
try
{
await _service.SubmitForm(entity, keyValue);
return await Success("操作成功。", "", keyValue);
}
catch (Exception ex)
{
return await Error(ex.Message, "", keyValue);
}
}
[HttpPost]
[HandlerAjaxOnly]
[HandlerAuthorize]
public async Task<ActionResult> DeleteForm(string keyValue)
{
try
{
await _service.DeleteForm(keyValue);
return await Success("操作成功。", "", keyValue, DbLogType.Delete);
}
catch (Exception ex)
{
return await Error(ex.Message, "", keyValue, DbLogType.Delete);
}
}
#endregion
}
}

View File

@@ -0,0 +1,312 @@
/*******************************************************************************
* Copyright © 2020 WaterCloud.Framework 版权所有
* Author: WaterCloud
* Description: WaterCloud快速开发平台
* Website
*********************************************************************************/
using iTextSharp.text;
using iTextSharp.text.pdf;
using Microsoft.AspNetCore.Mvc;
using MiniExcelLibs;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net.Http.Headers;
using System.Threading.Tasks;
using WaterCloud.Code;
using WaterCloud.Domain.SystemOrganize;
using WaterCloud.Service.SystemOrganize;
namespace WaterCloud.Web.Areas.SystemOrganize.Controllers
{
[Area("SystemOrganize")]
public class DutyController : BaseController
{
public DutyService _service { get; set; }
public SystemSetService _setService { get; set; }
public virtual ActionResult Import()
{
return View();
}
[HandlerAjaxOnly]
[IgnoreAntiforgeryToken]
public async Task<ActionResult> GetGridJson(SoulPage<RoleExtend> pagination, string keyword)
{
if (string.IsNullOrEmpty(pagination.field))
{
pagination.field = "F_Id";
pagination.order = "desc";
}
var data = await _service.GetLookList(pagination, keyword);
return Content(pagination.setData(data).ToJson());
}
[HttpGet]
[HandlerAjaxOnly]
public async Task<ActionResult> GetListJson(string keyword)
{
var data = await _service.GetList(keyword);
return Content(data.ToJson());
}
[HttpGet]
[HandlerAjaxOnly]
public async Task<ActionResult> GetFormJson(string keyValue)
{
var data = await _service.GetLookForm(keyValue);
return Content(data.ToJson());
}
[HttpPost]
[HandlerAjaxOnly]
public async Task<ActionResult> CheckFile()
{
try
{
//获取文件参数,创建临时文件,使用完成就删除
var files = HttpContext.Request.Form.Files;
long size = files.Sum(f => f.Length);
if (size > 104857600)
{
throw new Exception("文件大小必须小于100M");
}
var file = files.First();
var fileName = ContentDispositionHeaderValue.Parse(file.ContentDisposition).FileName.Trim('"');
if (string.IsNullOrEmpty(fileName))
{
throw new Exception("文件不存在");
}
if (!FileHelper.IsExcel(fileName))
{
throw new Exception("请上传Excel");
}
string filePath = GlobalContext.HostingEnvironment.WebRootPath + $@"/" + "file" + $@"/";
fileName = Utils.CreateNo() + fileName.Substring(fileName.LastIndexOf("."));
string fileFullName = filePath + fileName;
if (!Directory.Exists(filePath))
{
Directory.CreateDirectory(filePath);
}
using (FileStream fs = System.IO.File.Create(fileFullName))
{
file.CopyTo(fs);
fs.Flush();
}
var data = await _service.CheckFile(fileFullName);
return Content(new { code = 0, msg = "操作成功", data = data }.ToJson());
}
catch (Exception ex)
{
return Content(new { code = 400, msg = "操作失败," + ex.Message }.ToJson());
}
}
[HttpPost]
[HandlerAjaxOnly]
public async Task<ActionResult> SubmitForm(RoleEntity roleEntity, string keyValue)
{
try
{
await _service.SubmitForm(roleEntity, keyValue);
return await Success("操作成功。", "", keyValue);
}
catch (Exception ex)
{
return await Error(ex.Message, "", keyValue);
}
}
[HttpPost]
[HandlerAjaxOnly]
[HandlerAuthorize]
public async Task<ActionResult> DeleteForm(string keyValue)
{
try
{
await _service.DeleteForm(keyValue);
return await Success("操作成功。", "", keyValue, DbLogType.Delete);
}
catch (Exception ex)
{
return await Error(ex.Message, "", keyValue, DbLogType.Delete);
}
}
[HttpPost]
[HandlerAjaxOnly]
public async Task<ActionResult> ImportForm(string listData)
{
var filterList = JsonConvert.DeserializeObject<List<RoleEntity>>(listData);
if (filterList == null || filterList.Count == 0)
{
return Error("导入数据不存在!");
}
if (filterList.Where(a => a.F_EnabledMark == false).Any())
{
return Error("导入数据存在错误!");
}
try
{
await _service.ImportForm(filterList);
return await Success("导入成功。", "", "");
}
catch (Exception ex)
{
return await Error("导入失败," + ex.Message, "", "");
}
}
[HttpGet]
public async Task<FileResult> Download()
{
return await Task.Run(() =>
{
string fileName = "岗位导入模板.xlsx";
string fileValue = "model";
string filePath = GlobalContext.HostingEnvironment.WebRootPath + $@"/" + fileValue + $@"/" + fileName;
if (!FileHelper.IsExistFile(filePath))
{
throw new Exception("文件不存在");
}
//定义并实例化一个内存流,以存放图片的字节数组。
MemoryStream ms = new MemoryStream();
//图片读入FileStream
FileStream f = new FileStream(filePath, FileMode.Open);
//把FileStream写入MemoryStream
ms.SetLength(f.Length);
f.Read(ms.GetBuffer(), 0, (int)f.Length);
ms.Flush();
f.Close();
var contentType = MimeMapping.GetMimeMapping(fileName);
return File(ms, contentType, fileName);
});
}
[HttpGet]
public async Task<FileResult> ExportExcel(string keyword = "")
{
var list = await _service.GetList(keyword);
string filename = "岗位信息" + DateTime.Now.ToString("yyyyMMdd_HHmmss") + ".xls";
var contentType = MimeMapping.GetMimeMapping(filename);
var values = new List<Dictionary<string, object>>();
var set = await _setService.GetForm(_service.currentuser.CompanyId);
for (int i = 0; i < list.Count; i++)
{
var dic = new Dictionary<string, object> ();
dic.Add("序号",i+1);
dic.Add("岗位编号", list[i].F_EnCode);
dic.Add("岗位名称", list[i].F_FullName);
dic.Add("归属公司", set.F_CompanyName);
dic.Add("有效状态", list[i].F_EnabledMark);
dic.Add("创建时间", list[i].F_CreatorTime);
dic.Add("备注", list[i].F_Description);
values.Add(dic);
}
var memoryStream = new MemoryStream();
memoryStream.SaveAs(values);
memoryStream.Seek(0, SeekOrigin.Begin);
return new FileStreamResult(memoryStream, contentType)
{
FileDownloadName = filename
};
}
[HttpGet]
public async Task<FileResult> Export(string keyword = "")
{
var list = await _service.GetList(keyword);
//生成pdf
string fileName = "岗位信息" + DateTime.Now.ToString("yyyyMMdd_HHmmss") + ".pdf";
//步骤1
Document Doc = new Document(PageSize.A4);
Doc.SetMargins(60, 60, 20, 40);
MemoryStream stream = new MemoryStream();
//步骤2
PdfWriter pdfWriter = PdfWriter.GetInstance(Doc, stream);
//步骤3
Doc.Open();
#region
BaseFont bfChinese;
bfChinese = BaseFont.CreateFont(GlobalContext.HostingEnvironment.WebRootPath + "/fonts/simsun.ttc,1", BaseFont.IDENTITY_H, BaseFont.NOT_EMBEDDED);
Font Font16 = new Font(bfChinese, 16);
Font Font14 = new Font(bfChinese, 14);
Font Font12 = new Font(bfChinese, 12);
Font Font12Bold = new Font(bfChinese, 12, Font.BOLD);
Font Font12Italic = new Font(bfChinese, 12, Font.BOLDITALIC);
Font Font10Bold = new Font(bfChinese, 10, Font.BOLD);
Paragraph parag;
//Chunk chunk;
PdfPTable table;
#endregion
#region
Doc.Open();
Doc.AddAuthor(_service.currentuser.UserName);
Doc.AddTitle("岗位信息");
#endregion
#region
parag = new Paragraph("岗位信息\r\n\r\n", Font16);
parag.Alignment = Element.ALIGN_CENTER;
Doc.Add(parag);
table = new PdfPTable(new float[] { 5, 5, 5, 5, 5, 5, 5 });
table.WidthPercentage = 100f;
table.AddCell(new Phrase("序号", Font12Bold));
table.AddCell(new Phrase("岗位编号", Font12Bold));
table.AddCell(new Phrase("岗位名称", Font12Bold));
table.AddCell(new Phrase("归属公司", Font12Bold));
table.AddCell(new Phrase("有效状态", Font12Bold));
table.AddCell(new Phrase("创建时间", Font12Bold));
table.AddCell(new Phrase("备注", Font12Bold));
Doc.Add(table);
int i = 0;
foreach (var item in list)
{
i++;
table = new PdfPTable(new float[] { 5, 5, 5, 5, 5, 5, 5 });
table.WidthPercentage = 100f;
table.AddCell(new Phrase(i.ToString(), Font12));
table.AddCell(new Phrase(item.F_EnCode != null ? item.F_EnCode.ToString() : "", Font12));
table.AddCell(new Phrase(item.F_FullName != null ? item.F_EnCode.ToString() : "", Font12));
var set = await _setService.GetForm(_service.currentuser.CompanyId);
table.AddCell(new Phrase(set != null ? set.F_CompanyName.ToString() : "", Font12));
table.AddCell(new Phrase(item.F_EnabledMark != true ? "无效" : "有效", Font12));
table.AddCell(new Phrase(item.F_CreatorTime != null ? ((DateTime)item.F_CreatorTime).ToString("yyyy-MM-dd") : "", Font12));
table.AddCell(new Phrase(item.F_Description, Font12));
Doc.Add(table);
}
table = new PdfPTable(new float[] { 35 });
table.WidthPercentage = 100f;
table.AddCell(new Phrase("合计:一共" + i + "项", Font12));
table.AddCell(new Phrase("", Font12));
Doc.Add(table);
Doc.Close();
#endregion
////页脚
//PDFFooter footer = new PDFFooter();
//footer.OnEndPage(pdfWriter, Doc);
Doc.Close();
var contentType = MimeMapping.GetMimeMapping(fileName);
FileResult fileResult = new FileContentResult(stream.ToArray(), contentType);
fileResult.FileDownloadName = fileName;
return fileResult;
}
}
}

View File

@@ -0,0 +1,82 @@
/*******************************************************************************
* Copyright © 2020 WaterCloud.Framework 版权所有
* Author: WaterCloud
* Description: WaterCloud快速开发平台
* Website
*********************************************************************************/
using Microsoft.AspNetCore.Mvc;
using System;
using System.Threading.Tasks;
using WaterCloud.Code;
using WaterCloud.Domain.SystemOrganize;
using WaterCloud.Service.SystemOrganize;
namespace WaterCloud.Web.Areas.SystemOrganize.Controllers
{
[Area("SystemOrganize")]
public class NoticeController : BaseController
{
public NoticeService _service { get; set; }
[HandlerAjaxOnly]
[IgnoreAntiforgeryToken]
public async Task<ActionResult> GetGridJson(SoulPage<NoticeEntity> pagination, string keyword)
{
if (string.IsNullOrEmpty(pagination.field))
{
pagination.field = "F_Id";
pagination.order = "desc";
}
var data = await _service.GetLookList(pagination, keyword);
return Content(pagination.setData(data).ToJson());
}
[HttpGet]
[HandlerAjaxOnly]
public async Task<ActionResult> GetListJson(string keyword)
{
var data = await _service.GetList(keyword);
return Content(data.ToJson());
}
[HttpGet]
[HandlerAjaxOnly]
public async Task<ActionResult> GetFormJson(string keyValue)
{
var data = await _service.GetLookForm(keyValue);
return Content(data.ToJson());
}
[HttpPost]
[HandlerAjaxOnly]
public async Task<ActionResult> SubmitForm(NoticeEntity noticeEntity, string keyValue)
{
try
{
await _service.SubmitForm(noticeEntity, keyValue);
return await Success("操作成功。", "", keyValue);
}
catch (Exception ex)
{
return await Error(ex.Message, "", keyValue);
}
}
[HttpPost]
[HandlerAjaxOnly]
[HandlerAuthorize]
public async Task<ActionResult> DeleteForm(string keyValue)
{
try
{
await _service.DeleteForm(keyValue);
return await Success("操作成功。", "", keyValue, DbLogType.Delete);
}
catch (Exception ex)
{
return await Error(ex.Message, "", keyValue, DbLogType.Delete);
}
}
}
}

View File

@@ -0,0 +1,160 @@
/*******************************************************************************
* Copyright © 2020 WaterCloud.Framework 版权所有
* Author: WaterCloud
* Description: WaterCloud快速开发平台
* Website
*********************************************************************************/
using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using WaterCloud.Code;
using WaterCloud.Domain.SystemOrganize;
using WaterCloud.Service.SystemOrganize;
namespace WaterCloud.Web.Areas.SystemOrganize.Controllers
{
[Area("SystemOrganize")]
public class OrganizeController : BaseController
{
public OrganizeService _service { get; set; }
[HttpGet]
public virtual ActionResult AddForm()
{
return View();
}
[HttpGet]
[HandlerAjaxOnly]
public async Task<ActionResult> GetTreeSelectJson()
{
var data = await _service.GetList();
var treeList = new List<TreeSelectModel>();
foreach (OrganizeEntity item in data)
{
TreeSelectModel treeModel = new TreeSelectModel();
treeModel.id = item.F_Id;
treeModel.text = item.F_FullName;
treeModel.parentId = item.F_ParentId;
treeModel.data = item;
treeList.Add(treeModel);
}
return Content(treeList.TreeSelectJson());
}
[HttpGet]
[HandlerAjaxOnly]
public async Task<ActionResult> GetSelectJson()
{
var data = await _service.GetList();
data = data.Where(a => a.F_EnabledMark == true).ToList();
var treeList = new List<TreeSelectModel>();
foreach (OrganizeEntity item in data)
{
TreeSelectModel treeModel = new TreeSelectModel();
treeModel.id = item.F_Id;
treeModel.text = item.F_FullName;
treeModel.parentId = item.F_ParentId;
treeModel.data = item;
treeList.Add(treeModel);
}
return Content(treeList.TreeSelectJson());
}
[HttpGet]
[HandlerAjaxOnly]
public async Task<ActionResult> GetTreeJson()
{
var data = await _service.GetList();
var treeList = new List<TreeViewModel>();
foreach (OrganizeEntity item in data)
{
TreeViewModel tree = new TreeViewModel();
bool hasChildren = data.Count(t => t.F_ParentId == item.F_Id) == 0 ? false : true;
tree.id = item.F_Id;
tree.text = item.F_FullName;
tree.value = item.F_EnCode;
tree.parentId = item.F_ParentId;
tree.isexpand = true;
tree.complete = true;
tree.hasChildren = hasChildren;
treeList.Add(tree);
}
return Content(treeList.TreeViewJson());
}
[HttpGet]
[HandlerAjaxOnly]
public async Task<ActionResult> GetTreeGridJson(string keyword, string ids)
{
var data = await _service.GetLookList();
if (!string.IsNullOrEmpty(keyword))
{
data = data.TreeWhere(t => t.F_FullName.Contains(keyword));
}
if (!string.IsNullOrEmpty(ids))
{
var str = ids.Split(',');
foreach (var item in str)
{
if (data.Where(a => a.F_Id == item).Any())
{
var temp = data.Find(a => a.F_Id == item);
temp.LAY_CHECKED = true;
}
}
}
return Success(data.Count, data);
}
[HttpGet]
[HandlerAjaxOnly]
public async Task<ActionResult> GetFormJson(string keyValue)
{
var data = await _service.GetLookForm(keyValue);
return Content(data.ToJson());
}
[HttpPost]
[HandlerAjaxOnly]
public async Task<ActionResult> SubmitForm(OrganizeEntity organizeEntity, string keyValue)
{
try
{
if (organizeEntity.F_ParentId == "0")
{
organizeEntity.F_Layers = 1;
}
else
{
organizeEntity.F_Layers = (await _service.GetForm(organizeEntity.F_ParentId)).F_Layers + 1;
}
await _service.SubmitForm(organizeEntity, keyValue);
return await Success("操作成功。", "", keyValue);
}
catch (Exception ex)
{
return await Error(ex.Message, "", keyValue);
}
}
[HttpPost]
[HandlerAjaxOnly]
[HandlerAuthorize]
public async Task<ActionResult> DeleteForm(string keyValue)
{
try
{
await _service.DeleteForm(keyValue);
return await Success("操作成功。", "", keyValue, DbLogType.Delete);
}
catch (Exception ex)
{
return await Error(ex.Message, "", keyValue, DbLogType.Delete);
}
}
}
}

View File

@@ -0,0 +1,177 @@
/*******************************************************************************
* Copyright © 2020 WaterCloud.Framework 版权所有
* Author: WaterCloud
* Description: WaterCloud快速开发平台
* Website
*********************************************************************************/
using Microsoft.AspNetCore.Mvc;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using WaterCloud.Code;
using WaterCloud.Domain.SystemManage;
using WaterCloud.Domain.SystemOrganize;
using WaterCloud.Service.SystemManage;
using WaterCloud.Service.SystemOrganize;
namespace WaterCloud.Web.Areas.SystemOrganize.Controllers
{
[Area("SystemOrganize")]
public class RoleAuthorizeController : BaseController
{
public RoleAuthorizeService _roleAuthorizeService { get; set; }
public ModuleService _moduleService { get; set; }
public ModuleButtonService _moduleButtonService { get; set; }
public ModuleFieldsService _moduleFieldsService { get; set; }
[HttpGet]
public async Task<ActionResult> GetPermissionTree(string roleId)
{
var current = _moduleService.currentuser;
string roleid = current.RoleId;
var moduledata = new List<ModuleEntity>();
var buttondata = new List<ModuleButtonEntity>();
var authorizedata = new List<RoleAuthorizeEntity>();
//隐藏系统菜单及字典管理
if (roleid == null && current.IsAdmin)
{
moduledata = await _moduleService.GetList();
buttondata = await _moduleButtonService.GetList();
moduledata = moduledata.Where(a => a.F_EnabledMark == true).ToList();
buttondata = buttondata.Where(a => a.F_EnabledMark == true).ToList();
}
else
{
var rolelist = roleid.Split(',');
foreach (var item in rolelist)
{
moduledata.AddRange(await _moduleService.GetListByRole(item));
buttondata.AddRange(await _moduleButtonService.GetListByRole(item));
}
moduledata = moduledata.GroupBy(p => p.F_Id).Select(q => q.First()).ToList();
buttondata = buttondata.GroupBy(p => p.F_Id).Select(q => q.First()).ToList();
}
if (!string.IsNullOrEmpty(roleId))
{
authorizedata = await _roleAuthorizeService.GetList(roleId);
}
var treeList = new List<TreeGridModel>();
foreach (ModuleEntity item in moduledata)
{
TreeGridModel tree = new TreeGridModel();
tree.id = item.F_Id;
tree.title = item.F_FullName;
tree.parentId = item.F_ParentId;
if (item.F_IsPublic == true)
{
tree.checkArr = "1";
tree.disabled = true;
}
else
{
tree.checkArr = authorizedata.Count(t => t.F_ItemId == item.F_Id) > 0 ? "1" : "0";
}
treeList.Add(tree);
}
foreach (ModuleButtonEntity item in buttondata)
{
TreeGridModel tree = new TreeGridModel();
tree.id = item.F_Id;
tree.title = item.F_FullName;
tree.parentId = item.F_ParentId == "0" ? item.F_ModuleId : item.F_ParentId;
if (item.F_IsPublic == true)
{
tree.checkArr = "1";
tree.disabled = true;
}
else
{
tree.checkArr = authorizedata.Count(t => t.F_ItemId == item.F_Id) > 0 ? "1" : "0";
}
treeList.Add(tree);
}
return DTreeResult(treeList.TreeList());
}
[HttpPost]
[IgnoreAntiforgeryToken]
public async Task<ActionResult> GetPermissionFieldsTree(string roleId, string moduleids)
{
var current = _moduleService.currentuser;
string roleid = current.RoleId;
var moduledata = new List<ModuleEntity>();
var fieldsdata = new List<ModuleFieldsEntity>();
var authorizedata = new List<RoleAuthorizeEntity>();
//隐藏系统菜单及字典管理
if (roleid == null && current.IsAdmin)
{
moduledata = await _moduleService.GetList();
fieldsdata = await _moduleFieldsService.GetList();
moduledata = moduledata.Where(a => a.F_EnabledMark == true).ToList();
fieldsdata = fieldsdata.Where(a => a.F_EnabledMark == true).ToList();
}
else
{
var rolelist = roleid.Split(',');
foreach (var item in rolelist)
{
moduledata.AddRange(await _moduleService.GetListByRole(item));
fieldsdata.AddRange(await _moduleFieldsService.GetListByRole(item));
}
moduledata = moduledata.GroupBy(p => p.F_Id).Select(q => q.First()).ToList();
fieldsdata = fieldsdata.GroupBy(p => p.F_Id).Select(q => q.First()).ToList();
}
moduledata = moduledata.Where(a => a.F_IsFields == true || (a.F_Layers < 3 && a.F_IsExpand == true)).ToList();
if (!string.IsNullOrEmpty(moduleids))
{
var list = moduleids.Split(',');
moduledata = moduledata.Where(a => list.Contains(a.F_Id) || a.F_IsPublic == true).ToList();
}
else
{
moduledata = moduledata.Where(a => a.F_IsPublic == true).ToList();
}
if (!string.IsNullOrEmpty(roleId))
{
authorizedata = await _roleAuthorizeService.GetList(roleId);
}
var treeList = new List<TreeGridModel>();
foreach (ModuleEntity item in moduledata)
{
TreeGridModel tree = new TreeGridModel();
tree.id = item.F_Id;
tree.title = item.F_FullName;
tree.parentId = item.F_ParentId;
if (item.F_IsPublic == true)
{
tree.checkArr = "1";
tree.disabled = true;
}
else
{
tree.checkArr = authorizedata.Count(t => t.F_ItemId == item.F_Id) > 0 ? "1" : "0";
}
treeList.Add(tree);
}
foreach (ModuleFieldsEntity item in fieldsdata)
{
TreeGridModel tree = new TreeGridModel();
tree.id = item.F_Id;
tree.title = item.F_FullName;
tree.parentId = item.F_ModuleId;
if (item.F_IsPublic == true)
{
tree.checkArr = "1";
tree.disabled = true;
}
else
{
tree.checkArr = authorizedata.Count(t => t.F_ItemId == item.F_Id) > 0 ? "1" : "0";
}
treeList.Add(tree);
}
return DTreeResult(treeList.TreeList());
}
}
}

View File

@@ -0,0 +1,117 @@
/*******************************************************************************
* Copyright © 2020 WaterCloud.Framework 版权所有
* Author: WaterCloud
* Description: WaterCloud快速开发平台
* Website
*********************************************************************************/
using Microsoft.AspNetCore.Mvc;
using System;
using System.Linq;
using System.Threading.Tasks;
using WaterCloud.Code;
using WaterCloud.Domain.SystemOrganize;
using WaterCloud.Service.SystemOrganize;
namespace WaterCloud.Web.Areas.SystemOrganize.Controllers
{
[Area("SystemOrganize")]
public class RoleController : BaseController
{
public RoleService _service { get; set; }
[HttpGet]
public virtual ActionResult AddForm()
{
return View();
}
[HttpGet]
[HandlerAjaxOnly]
public async Task<ActionResult> GetListJson(string keyword)
{
var data = await _service.GetList(keyword);
return Content(data.ToJson());
}
[HttpGet]
[HandlerAjaxOnly]
public async Task<ActionResult> GetSelectJson(string keyword, string ids)
{
var data = await _service.GetList(keyword);
data = data.Where(a => a.F_EnabledMark == true).ToList();
if (!string.IsNullOrEmpty(ids))
{
foreach (var item in ids.Split(','))
{
var temp = data.Find(a => a.F_Id == item);
if (temp != null)
{
temp.LAY_CHECKED = true;
}
}
}
return Success(data.Count, data);
}
[HandlerAjaxOnly]
[IgnoreAntiforgeryToken]
public async Task<ActionResult> GetGridJson(SoulPage<RoleExtend> pagination, string keyword)
{
if (string.IsNullOrEmpty(pagination.field))
{
pagination.field = "F_Id";
pagination.order = "desc";
}
var data = await _service.GetLookList(pagination, keyword);
return Content(pagination.setData(data).ToJson());
}
[HttpGet]
[HandlerAjaxOnly]
public async Task<ActionResult> GetFormJson(string keyValue)
{
var data = await _service.GetLookForm(keyValue);
return Content(data.ToJson());
}
[HttpPost]
[HandlerAjaxOnly]
public async Task<ActionResult> SubmitForm(RoleEntity roleEntity, string permissionbuttonIds, string permissionfieldsIds, string keyValue)
{
if (!string.IsNullOrEmpty(keyValue) && _service.currentuser.RoleId == keyValue)
{
return Error("操作失败,不能修改用户当前角色");
}
try
{
await _service.SubmitForm(roleEntity, string.IsNullOrEmpty(permissionbuttonIds) ? new string[0] : permissionbuttonIds.Split(','), string.IsNullOrEmpty(permissionfieldsIds) ? new string[0] : permissionfieldsIds.Split(','), keyValue);
return await Success("操作成功。", "", keyValue);
}
catch (Exception ex)
{
return await Error(ex.Message, "", keyValue);
}
}
[HttpPost]
[HandlerAjaxOnly]
[HandlerAuthorize]
public async Task<ActionResult> DeleteForm(string keyValue)
{
try
{
if (_service.currentuser.RoleId == keyValue)
{
return Error("操作失败,不能删除用户当前角色");
}
await _service.DeleteForm(keyValue);
return await Success("操作成功。", "", keyValue, DbLogType.Delete);
}
catch (Exception ex)
{
return await Error(ex.Message, "", keyValue, DbLogType.Delete);
}
}
}
}

View File

@@ -0,0 +1,164 @@
using Microsoft.AspNetCore.Mvc;
using SqlSugar;
using System;
using System.Linq;
using System.Threading.Tasks;
using WaterCloud.Code;
using WaterCloud.Domain.SystemOrganize;
using WaterCloud.Service.SystemOrganize;
namespace WaterCloud.Web.Areas.SystemOrganize.Controllers
{
/// <summary>
/// 创 建:超级管理员
/// 日 期2020-06-12 13:50
/// 描 述:系统设置控制器类
/// </summary>
[Area("SystemOrganize")]
public class SystemSetController : BaseController
{
public SystemSetService _service { get; set; }
#region
[HttpGet]
[HandlerAuthorize]
[HandlerAdmin(false)]
public virtual ActionResult SetForm()
{
return View();
}
[HttpGet]
[HandlerAjaxOnly]
[HandlerAdmin]
public async Task<ActionResult> GetGridJson(Pagination pagination, string keyword)
{
if (string.IsNullOrEmpty(pagination.field))
{
pagination.order = "desc";
pagination.field = "F_Id";
}
//导出全部页使用
if (pagination.rows == 0 && pagination.page == 0)
{
pagination.rows = 99999999;
pagination.page = 1;
}
var data = await _service.GetLookList(pagination, keyword);
return Success(pagination.records, data);
}
[HttpGet]
[HandlerAjaxOnly]
public async Task<ActionResult> GetListJson(string keyword)
{
var data = await _service.GetList(keyword);
var currentuser = _service.currentuser;
if (currentuser.UserId == null)
{
return null;
}
else
{
data = data.Where(a => a.F_Id == _service.currentuser.CompanyId).ToList();
foreach (var item in data)
{
item.F_AdminAccount = null;
item.F_AdminPassword = null;
item.F_DBProvider = null;
item.F_DbString = null;
item.F_HostUrl = null;
item.F_PrincipalMan = null;
item.F_MobilePhone = null;
}
return Content(data.ToJson());
}
}
[HttpGet]
[HandlerAjaxOnly]
public ActionResult GetDbTypeJson()
{
var data = EnumHelper.EnumToList<DbType>();
return Content(data.ToJson());
}
[HttpGet]
[HandlerAjaxOnly]
[HandlerAdmin]
public async Task<ActionResult> GetFormJson(string keyValue)
{
var data = await _service.GetForm(keyValue);
return Content(data.ToJson());
}
[HttpGet]
[HandlerAjaxOnly]
[HandlerAdmin(false)]
public async Task<ActionResult> GetSetFormJson()
{
var data = await _service.GetForm(_service.currentuser.CompanyId);
return Content(data.ToJson());
}
#endregion
#region
[HttpPost]
[HandlerAjaxOnly]
[HandlerAdmin]
public async Task<ActionResult> SubmitForm(SystemSetEntity entity, string permissionbuttonIds, string permissionfieldsIds, string keyValue)
{
try
{
await _service.SubmitForm(entity, keyValue, string.IsNullOrEmpty(permissionbuttonIds) ? null : permissionbuttonIds.Split(','), string.IsNullOrEmpty(permissionfieldsIds) ? null : permissionfieldsIds.Split(','));
return await Success("操作成功。", "", keyValue);
}
catch (Exception ex)
{
return await Error(ex.Message, "", keyValue);
}
}
[HttpPost]
[HandlerAjaxOnly]
[HandlerAdmin(false)]
public async Task<ActionResult> SetSubmitForm(SystemSetEntity entity)
{
var keyValue = _service.currentuser.CompanyId;
try
{
entity.F_DeleteMark = false;
entity.F_EnabledMark = null;
entity.F_EndTime = null;
await _service.SubmitForm(entity, keyValue);
return await Success("操作成功。", "", keyValue);
}
catch (Exception ex)
{
return await Error(ex.Message, "", keyValue);
}
}
[HttpPost]
[HandlerAjaxOnly]
[HandlerAuthorize]
[HandlerAdmin]
public async Task<ActionResult> DeleteForm(string keyValue)
{
try
{
await _service.DeleteForm(keyValue);
return await Success("操作成功。", "", keyValue, DbLogType.Delete);
}
catch (Exception ex)
{
return await Error(ex.Message, "", keyValue, DbLogType.Delete);
}
}
#endregion
}
}

View File

@@ -0,0 +1,246 @@
/*******************************************************************************
* Copyright © 2020 WaterCloud.Framework 版权所有
* Author: WaterCloud
* Description: WaterCloud快速开发平台
* Website
*********************************************************************************/
using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using WaterCloud.Code;
using WaterCloud.Domain.SystemOrganize;
using WaterCloud.Service.SystemManage;
using WaterCloud.Service.SystemOrganize;
namespace WaterCloud.Web.Areas.SystemOrganize.Controllers
{
[Area("SystemOrganize")]
public class UserController : BaseController
{
public UserService _service { get; set; }
public UserLogOnService _userLogOnService { get; set; }
public ModuleService _moduleService { get; set; }
public RoleService _roleService { get; set; }
public OrganizeService _orgService { get; set; }
[HandlerAjaxOnly]
[IgnoreAntiforgeryToken]
public async Task<ActionResult> GetGridJson(SoulPage<UserExtend> pagination, string keyword)
{
if (string.IsNullOrEmpty(pagination.field))
{
pagination.field = "F_OrganizeId";
pagination.order = "asc";
}
var data = await _service.GetLookList(pagination, keyword);
return Content(pagination.setData(data).ToJson());
}
[HttpGet]
public virtual ActionResult AddForm()
{
return View();
}
[HttpGet]
[HandlerAjaxOnly]
public async Task<ActionResult> GetListJson(string keyword, string ids)
{
var data = await _service.GetList(keyword);
data = data.Where(a => a.F_EnabledMark == true).ToList();
if (!string.IsNullOrEmpty(ids))
{
foreach (var item in ids.Split(','))
{
var temp = data.Find(a => a.F_Id == item);
if (temp != null)
{
temp.LAY_CHECKED = true;
}
}
}
return Success(data.Count, data);
}
[HttpGet]
[HandlerAjaxOnly]
public async Task<ActionResult> GetFormJson(string keyValue)
{
var data = await _service.GetLookForm(keyValue);
return Content(data.ToJson());
}
[HttpGet]
[HandlerAjaxOnly]
public async Task<ActionResult> GetUserFormJson()
{
var data = await _service.GetFormExtend(_service.currentuser.UserId);
return Content(data.ToJson("yyyy-MM-dd"));
}
[HttpPost]
[HandlerAjaxOnly]
[HandlerLock]
public async Task<ActionResult> SubmitUserForm(string F_Account, string F_RealName, bool F_Gender, DateTime F_Birthday, string F_MobilePhone, string F_Email, string F_Description)
{
try
{
var userEntity = new UserEntity();
userEntity.F_Account = F_Account;
userEntity.F_RealName = F_RealName;
userEntity.F_Gender = F_Gender;
userEntity.F_Birthday = F_Birthday;
userEntity.F_MobilePhone = F_MobilePhone;
userEntity.F_Email = F_Email;
userEntity.F_Description = F_Description;
userEntity.F_Id = _service.currentuser.UserId;
await _service.SubmitUserForm(userEntity);
return await Success("操作成功。", "", userEntity.F_Id);
}
catch (Exception ex)
{
return await Error(ex.Message, "", _service.currentuser.UserId);
}
}
[HttpPost]
[HandlerAjaxOnly]
public async Task<ActionResult> SubmitForm(UserEntity userEntity, UserLogOnEntity userLogOnEntity, string keyValue)
{
if (string.IsNullOrEmpty(keyValue))
{
userEntity.F_IsAdmin = false;
userEntity.F_DeleteMark = false;
userEntity.F_IsBoss = false;
userEntity.F_CompanyId = _service.currentuser.CompanyId;
}
else
{
if (_service.currentuser.UserId == keyValue)
{
return Error("操作失败,不能修改用户自身");
}
}
try
{
await _service.SubmitForm(userEntity, userLogOnEntity, keyValue);
return await Success("操作成功。", "", keyValue);
}
catch (Exception ex)
{
return await Error(ex.Message, "", keyValue);
}
}
[HttpPost]
[HandlerAuthorize]
[HandlerAjaxOnly]
public async Task<ActionResult> DeleteForm(string keyValue)
{
try
{
if (_service.currentuser.UserId == keyValue)
{
return Error("操作失败,不能删除用户自身");
}
await _service.DeleteForm(keyValue);
return await Success("操作成功。", "", keyValue, DbLogType.Delete);
}
catch (Exception ex)
{
return await Error(ex.Message, "", keyValue, DbLogType.Delete);
}
}
[HttpGet]
public ActionResult RevisePassword()
{
return View();
}
[HttpPost]
[HandlerAjaxOnly]
public async Task<ActionResult> SubmitRevisePassword(string F_UserPassword, string keyValue)
{
try
{
await _userLogOnService.RevisePassword(F_UserPassword, keyValue);
return await Success("重置密码成功。", "", keyValue);
}
catch (Exception ex)
{
return await Error("重置密码失败," + ex.Message, "", keyValue);
}
}
[HttpGet]
public ActionResult ReviseSelfPassword()
{
return View();
}
[HttpPost]
[HandlerAjaxOnly]
public async Task<ActionResult> SubmitReviseSelfPassword(string F_UserPassword)
{
try
{
await _userLogOnService.ReviseSelfPassword(F_UserPassword, _service.currentuser.UserId);
return await Success("重置密码成功。", "", _service.currentuser.UserId);
}
catch (Exception ex)
{
return await Error("重置密码失败," + ex.Message, "", _service.currentuser.UserId);
}
}
[HttpPost]
[HandlerAjaxOnly]
[HandlerAuthorize]
public async Task<ActionResult> DisabledAccount(string keyValue)
{
try
{
UserEntity userEntity = new UserEntity();
userEntity.F_Id = keyValue;
userEntity.F_EnabledMark = false;
if (_service.currentuser.UserId == keyValue)
{
return Error("操作失败,不能修改用户自身");
}
await _service.UpdateForm(userEntity);
return await Success("账户禁用成功。", "", keyValue);
}
catch (Exception ex)
{
return await Error("账户禁用失败," + ex.Message, "", keyValue);
}
}
[HttpPost]
[HandlerAjaxOnly]
[HandlerAuthorize]
public async Task<ActionResult> EnabledAccount(string keyValue)
{
try
{
UserEntity userEntity = new UserEntity();
userEntity.F_Id = keyValue;
userEntity.F_EnabledMark = true;
if (_service.currentuser.UserId == keyValue)
{
return Error("操作失败,不能修改用户自身");
}
await _service.UpdateForm(userEntity);
return await Success("账户启用成功。", "", keyValue);
}
catch (Exception ex)
{
return await Error("账户启用失败," + ex.Message, "", keyValue);
}
}
}
}