Initial_commit_SecMPS_v2

This commit is contained in:
2026-05-15 23:22:48 +08:00
commit 23ea4fe05f
13830 changed files with 298675 additions and 0 deletions

View File

@@ -0,0 +1,256 @@
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
using VolPro.Core.Configuration;
using VolPro.Core.Enums;
using VolPro.Core.Extensions;
using VolPro.Core.Filters;
using VolPro.Core.Middleware;
using VolPro.Core.Services;
using VolPro.Core.Utilities;
using VolPro.Entity.DomainModels;
namespace VolPro.Core.Controllers.Basic
{
[JWTAuthorize, ApiController]
public class ApiBaseController<IServiceBase> : VolController
{
protected IServiceBase Service;
private WebResponseContent _baseWebResponseContent { get; set; }
public ApiBaseController()
{
}
public ApiBaseController(IServiceBase service)
{
Service = service;
}
public ApiBaseController(string projectName, string folder, string tablename, IServiceBase service)
{
Service = service;
}
[ActionLog("查询")]
[ApiActionPermission(ActionPermissionOptions.Search)]
[HttpPost, Route("GetPageData")]
public virtual ActionResult GetPageData([FromBody] PageDataOptions loadData)
{
return JsonNormal(InvokeService("GetPageData", new object[] { loadData }));
}
/// <summary>
/// 获取明细grid分页数据
/// </summary>
/// <param name="loadData"></param>
/// <returns></returns>
[ActionLog("明细查询")]
[ApiActionPermission(ActionPermissionOptions.Search)]
[HttpPost, Route("GetDetailPage")]
[ApiExplorerSettings(IgnoreApi = true)]
public virtual ActionResult GetDetailPage([FromBody] PageDataOptions loadData)
{
return Content(InvokeService("GetDetailPage", new object[] { loadData }).Serialize());
}
/// <summary>
/// 上传文件
/// </summary>
/// <param name="fileInput"></param>
/// <returns></returns>
[ActionLog("上传文件")]
[HttpPost, Route("Upload")]
//[ApiActionPermission(ActionPermissionOptions.Upload)]
[ApiActionPermission(ActionPermissionOptions.Upload| ActionPermissionOptions.Add | ActionPermissionOptions.Update)]
[ApiExplorerSettings(IgnoreApi = true)]
public virtual IActionResult Upload(IEnumerable<IFormFile> fileInput)
{
return Json(InvokeService("Upload", new object[] { fileInput }));
}
/// <summary>
/// 下载导入Excel模板
/// </summary>
/// <returns></returns>
[ActionLog("下载导入Excel模板")]
[HttpGet, Route("DownLoadTemplate")]
[ApiActionPermission(ActionPermissionOptions.Import)]
[ApiExplorerSettings(IgnoreApi = true)]
public virtual ActionResult DownLoadTemplate()
{
_baseWebResponseContent = InvokeService("DownLoadTemplate", new object[] { }) as WebResponseContent;
if (!_baseWebResponseContent.Status) return Json(_baseWebResponseContent);
byte[] fileBytes = System.IO.File.ReadAllBytes(_baseWebResponseContent.Data.ToString());
return File(
fileBytes,
System.Net.Mime.MediaTypeNames.Application.Octet,
Path.GetFileName(_baseWebResponseContent.Data.ToString())
);
}
/// <summary>
/// 导入表数据Excel
/// </summary>
/// <param name="fileInput"></param>
/// <returns></returns>
[ActionLog("导入Excel")]
[HttpPost, Route("Import")]
[ApiActionPermission(ActionPermissionOptions.Import)]
[ApiExplorerSettings(IgnoreApi = true)]
public virtual ActionResult Import(List<IFormFile> fileInput)
{
return Json(InvokeService("Import", new object[] { fileInput }));
}
/// <summary>
/// 导出文件,返回日期+文件名
/// </summary>
/// <param name="loadData"></param>
/// <returns></returns>
[ActionLog("导出Excel")]
[ApiActionPermission(ActionPermissionOptions.Export)]
[ApiExplorerSettings(IgnoreApi = true)]
[HttpPost, Route("Export")]
public virtual ActionResult Export([FromBody] PageDataOptions loadData)
{
var result = InvokeService("Export", new object[] { loadData }) as WebResponseContent;
return File(
System.IO.File.ReadAllBytes(result.Data.ToString().MapPath()),
System.Net.Mime.MediaTypeNames.Application.Octet,
Path.GetFileName(result.Data.ToString())
);
}
/// <summary>
/// 通过key删除文件
/// </summary>
/// <param name="keys"></param>
/// <returns></returns>
// [ActionLog("删除")]
[ApiActionPermission(ActionPermissionOptions.Delete)]
[HttpPost, Route("Del")]
[ApiExplorerSettings(IgnoreApi = true)]
public virtual ActionResult Del([FromBody] object[] keys)
{
_baseWebResponseContent = InvokeService("Del", new object[] { keys, true }) as WebResponseContent;
Logger.Info(LoggerType.Del, keys.Serialize(), _baseWebResponseContent.Status ? "Ok" : _baseWebResponseContent.Message);
return Json(_baseWebResponseContent);
}
/// <summary>
/// 审核
/// </summary>
/// <param name="keys"></param>
/// <returns></returns>
/// [ActionLog("审核")]
[ApiActionPermission(ActionPermissionOptions.Audit)]
[HttpPost, Route("Audit")]
[ApiExplorerSettings(IgnoreApi = true)]
public virtual ActionResult Audit([FromBody] object[] id, int? auditStatus, string auditReason)
{
_baseWebResponseContent = InvokeService("Audit", new object[] { id, auditStatus, auditReason }) as WebResponseContent;
string msg = _baseWebResponseContent.Status ? ("Ok") : _baseWebResponseContent.Message;
Logger.Info($"审核:{id?.Serialize() + "," + (auditStatus ?? -1) + "," + auditReason};{msg}");
return Json(_baseWebResponseContent);
}
/// <summary>
/// 撤销、中目审核
/// </summary>
/// <param name="keys"></param>
/// <returns></returns>
[ApiActionPermission(Enums.ActionPermissionOptions.CancelAudit)]
[HttpPost, Route("cancelAudit")]
[ApiExplorerSettings(IgnoreApi = true)]
public virtual ActionResult CancelAudit([FromBody] AntiData antiData, int status)
{
var res = InvokeService("CancelAudit", new object[] { antiData, status });
return Json(res);
}
/// <summary>
/// 催办
/// </summary>
/// <param name="keys"></param>
/// <returns></returns>
// [ApiActionPermission(Enums.ActionPermissionOptions.Audit)]
[HttpPost, Route("urgentAudit")]
[ApiExplorerSettings(IgnoreApi = true)]
public virtual ActionResult UrgentAudit([FromBody] object[] id)
{
var res = InvokeService("UrgentAudit", new object[] { id });
return Json(res);
}
/// <summary>
/// 反审核
/// </summary>
/// <param name="keys"></param>
/// <returns></returns>
/// [ActionLog("审核")]
[ApiActionPermission(ActionPermissionOptions.Audit)]
[HttpPost, Route("antiAudit")]
[ApiExplorerSettings(IgnoreApi = true)]
public virtual ActionResult AntiAudit([FromBody] AntiData antiData)
{
_baseWebResponseContent = InvokeService("AntiAudit", new object[] { antiData }) as WebResponseContent;
string msg = _baseWebResponseContent.Status ? ("Ok") : _baseWebResponseContent.Message;
Logger.Info($"反审核:{antiData.Serialize()};{msg}");
return Json(_baseWebResponseContent);
}
/// <summary>
/// 新增支持主子表
/// </summary>
/// <param name="saveDataModel"></param>
/// <returns></returns>
[ActionLog("新建")]
[ApiActionPermission(ActionPermissionOptions.Add)]
[HttpPost, Route("Add")]
[ApiExplorerSettings(IgnoreApi = true)]
public virtual ActionResult Add([FromBody] SaveModel saveModel)
{
_baseWebResponseContent = InvokeService("Add",
new Type[] { typeof(SaveModel) },
new object[] { saveModel }) as WebResponseContent;
Logger.Info(LoggerType.Add, null, _baseWebResponseContent.Status ? "Ok" : _baseWebResponseContent.Message);
_baseWebResponseContent.Data = _baseWebResponseContent.Data?.Serialize();
return Json(_baseWebResponseContent);
}
/// <summary>
/// 编辑支持主子表
/// [ModelBinder(BinderType =(typeof(ModelBinder.BaseModelBinder)))]可指定绑定modelbinder
/// </summary>
/// <param name="saveDataModel"></param>
/// <returns></returns>
[ActionLog("编辑")]
[ApiActionPermission(ActionPermissionOptions.Update)]
[HttpPost, Route("Update")]
[ApiExplorerSettings(IgnoreApi = true)]
public virtual ActionResult Update([FromBody] SaveModel saveModel)
{
_baseWebResponseContent = InvokeService("Update", new object[] { saveModel }) as WebResponseContent;
Logger.Info(LoggerType.Edit, null, _baseWebResponseContent.Status ? "Ok" : _baseWebResponseContent.Message);
_baseWebResponseContent.Data = _baseWebResponseContent.Data?.Serialize();
return Json(_baseWebResponseContent);
}
/// <summary>
/// 调用service方法
/// </summary>
/// <param name="methodName"></param>
/// <param name="parameters"></param>
/// <returns></returns>
private object InvokeService(string methodName, object[] parameters)
{
return Service.GetType().GetMethod(methodName).Invoke(Service, parameters);
}
/// <summary>
/// 调用service方法
/// </summary>
/// <param name="methodName"></param>
/// <param name="types">为要调用重载的方法参数类型new Type[] { typeof(SaveDataModel)</param>
/// <param name="parameters"></param>
/// <returns></returns>
private object InvokeService(string methodName, Type[] types, object[] parameters)
{
return Service.GetType().GetMethod(methodName, types).Invoke(Service, parameters);
}
}
}

View File

@@ -0,0 +1,168 @@
using Microsoft.AspNetCore.Mvc;
using SqlSugar;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using VolPro.Core.DBManager;
using VolPro.Core.DbSqlSugar;
using VolPro.Core.Extensions;
using VolPro.Entity.DomainModels;
namespace VolPro.Core.Controllers.Basic
{
public class ReportBaseController : VolController
{
private ReportOption _reportOptions = null;
protected ISqlSugarClient DbContext { get; set; }
protected ReportOption ReportOptions
{
get
{
if (_reportOptions == null)
{
string code = HttpContext.Request.Query["code"];
_reportOptions = DBServerProvider.DbContext.Set<Sys_ReportOptions>().Where(x => x.ReportCode == code)
.Select(s => new ReportOption()
{
ReportOptionsId = s.ReportOptionsId,
ReportCode = s.ReportCode,
DbService = s.DbService,
Sql = s.Options,
ParentId = s.ParentId,
ReportName = s.ReportName,
ReportType = s.ReportType,
FilePath = s.FilePath,
}).ToList().FirstOrDefault();
if (_reportOptions == null)
{
Console.Write($"模板[{code}]不存在");
}
else
{
DbContext = DbManger.GetConnection(_reportOptions.DbService);
}
}
return _reportOptions;
}
}
public ReportBaseController()
{
}
protected object Data = null;
[HttpGet, HttpPost, Route("getTemplateData")]
public virtual IActionResult GetTemplateData(string code)
{
if (ReportOptions == null)
{
return Error("模板不存在");
}
string filePath = ReportOptions.FilePath.MapPath(false);
string text = System.IO.File.ReadAllText(filePath);
Data = GetData(code);
if (Data != null)
{
return Success(null, new { text, data = Data });
}
if (Data == null && !string.IsNullOrEmpty(ReportOptions.Sql))
{
Data = DbContext.Ado.SqlQuery<object>(ReportOptions.Sql);
}
return Success(null, new { text, data = new { Table = Data } });
}
protected virtual object GetData(string code)
{
return null;
}
//[HttpGet, Route("getData")]
//public virtual async Task<IActionResult> GetData(string code)
//{
//}
}
public class ReportOption
{
[Key]
[Display(Name = "ReportOptionsId")]
[Column(TypeName = "uniqueidentifier")]
[Editable(true)]
[Required(AllowEmptyStrings = false)]
public Guid ReportOptionsId { get; set; }
/// <summary>
///报表名称
/// </summary>
[Display(Name = "报表名称")]
[MaxLength(100)]
[Column(TypeName = "nvarchar(100)")]
[Editable(true)]
[Required(AllowEmptyStrings = false)]
public string ReportName { get; set; }
/// <summary>
///报表编码
/// </summary>
[Display(Name = "报表编码")]
[MaxLength(100)]
[Column(TypeName = "nvarchar(100)")]
[Editable(true)]
[Required(AllowEmptyStrings = false)]
public string ReportCode { get; set; }
/// <summary>
///所在数据库
/// </summary>
[Display(Name = "所在数据库")]
[MaxLength(100)]
[Column(TypeName = "nvarchar(100)")]
[Editable(true)]
public string DbService { get; set; }
/// <summary>
///报表类型
/// </summary>
[Display(Name = "报表类型")]
[MaxLength(100)]
[Column(TypeName = "varchar(100)")]
[Editable(true)]
public string ReportType { get; set; }
/// <summary>
///父级id
/// </summary>
[Display(Name = "父级id")]
[Column(TypeName = "uniqueidentifier")]
[Editable(true)]
public Guid? ParentId { get; set; }
/// <summary>
///模板文件
/// </summary>
[Display(Name = "模板文件")]
[MaxLength(2000)]
[Column(TypeName = "nvarchar(2000)")]
[Editable(true)]
[Required(AllowEmptyStrings = false)]
public string FilePath { get; set; }
/// <summary>
///数据源sql
/// </summary>
[Display(Name = "数据源sql")]
[MaxLength(2000)]
[Column(TypeName = "nvarchar(2000)")]
[Editable(true)]
public string Sql { get; set; }
}
}

View File

@@ -0,0 +1,76 @@
using Microsoft.AspNetCore.Mvc;
using Newtonsoft.Json;
using System;
using VolPro.Core.Filters;
namespace VolPro.Core.Controllers.Basic
{
[JWTAuthorize, ApiController]
public class VolController : Controller
{
public VolController()
{
}
/// <summary>
/// 2020.11.21增加json原格式返回数据(默认是驼峰格式)
/// </summary>
/// <param name="data"></param>
/// <param name="serializerSettings"></param>
/// <returns></returns>
protected JsonResult JsonNormal(object data, JsonSerializerSettings serializerSettings = null, bool formateDate = true)
{
serializerSettings = serializerSettings ?? new JsonSerializerSettings();
serializerSettings.ContractResolver = null;
if (formateDate)
{
serializerSettings.DateFormatString = "yyyy-MM-dd HH:mm:ss";
}
serializerSettings.Converters.Add(new LongCovert());
return Json(data, serializerSettings);
}
protected IActionResult Success(string message)
{
return JsonNormal(new { status = true, message });
}
protected IActionResult Success(string message, object data)
{
return JsonNormal(new { status = true, message, data });
}
protected IActionResult Error(string message)
{
return JsonNormal(new { status = false, message });
}
protected IActionResult Error(string message, object data)
{
return JsonNormal(new { status = false, message, data });
}
}
public class LongCovert : JsonConverter
{
public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
{
if (reader.Value == null)
{
return null;
}
long.TryParse(reader.Value.ToString(), out long value);
return value;
}
public override bool CanConvert(Type objectType)
{
return typeof(long) == objectType || typeof(long?) == objectType;
}
public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
{
if (value == null)
{
writer.WriteNull();
return;
}
serializer.Serialize(writer, value.ToString());
}
}
}

View File

@@ -0,0 +1,23 @@
using Microsoft.AspNetCore.Mvc.Infrastructure;
using Microsoft.Extensions.Primitives;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
namespace VolPro.Core.Controllers.DynamicController
{
public class AddControllerChangeProvider : IActionDescriptorChangeProvider
{
public static AddControllerChangeProvider Instance { get; } = new AddControllerChangeProvider();
public CancellationTokenSource TokenSource { get; private set; }
public bool HasChanged { get; set; }
public IChangeToken GetChangeToken()
{
TokenSource = new CancellationTokenSource();
return new CancellationChangeToken(TokenSource.Token);
}
}
}

View File

@@ -0,0 +1,52 @@
using VolPro.Core.Configuration;
using VolPro.Core.Extensions;
using VolPro.Entity.SystemModels;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Mvc.ApplicationParts;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.Loader;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
namespace VolPro.Core.Controllers.DynamicController
{
public class ChangeActionService : IHostedService
{
private readonly ApplicationPartManager Part;
private readonly IWebHostEnvironment _environment;
public ChangeActionService(IServiceScopeFactory scope, IWebHostEnvironment env)
{
Part = scope.CreateScope().ServiceProvider.GetService<ApplicationPartManager>();
_environment = env;
}
public async Task StartAsync(CancellationToken cancellationToken)
{
//string rootPath = (_environment.ContentRootPath + "\\plugs").ReplacePath();
//foreach (var item in Directory.GetFiles(rootPath).Where(x => x.EndsWith(".dll")))
//{
// string path = ($"{item}").ReplacePath();
// //assemblyList.Add(Assembly.LoadFile(path));
// var assembly = AssemblyLoadContext.Default.LoadFromAssemblyPath(path);
// var assemblyPart = new AssemblyPart(assembly);
// Part.ApplicationParts.Add(assemblyPart);
//}
//AddControllerChangeProvider.Instance.HasChanged = true;
//AddControllerChangeProvider.Instance.TokenSource?.Cancel();
await Task.CompletedTask;
}
public async Task StopAsync(CancellationToken cancellationToken)
{
await Task.CompletedTask;
}
}
}