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,350 @@
/*
*所有关于Sys_Dashboard类的业务代码应在此处编写
*可使用repository.调用常用方法获取EF/Dapper等信息
*如果需要事务请使用repository.DbContextBeginTransaction
*也可使用DBServerProvider.手动获取数据库相关信息
*用户信息、权限、角色等使用UserContext.Current操作
*Sys_DashboardService对增、删、改查、导入、导出、审核业务代码扩展参照ServiceFunFilter
*/
using VolPro.Core.BaseProvider;
using VolPro.Core.Extensions.AutofacManager;
using VolPro.Entity.DomainModels;
using System.Linq;
using VolPro.Core.Utilities;
using System.Linq.Expressions;
using VolPro.Core.Extensions;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.AspNetCore.Http;
using VolPro.Sys.IRepositories;
using System.Threading.Tasks;
using System;
using System.Collections.Generic;
using VolPro.Core.DBManager;
using System.Data;
using VolPro.Core.Services;
using VolPro.Core.ManageUser;
using VolPro.Core.Configuration;
using VolPro.Core.DbSqlSugar;
using SqlSugar;
using VolPro.Core.Dashboard;
namespace VolPro.Sys.Services
{
public partial class Sys_DashboardService
{
private readonly IHttpContextAccessor _httpContextAccessor;
private readonly ISys_DashboardRepository _repository;//访问数据库
[ActivatorUtilitiesConstructor]
public Sys_DashboardService(
ISys_DashboardRepository dbRepository,
IHttpContextAccessor httpContextAccessor
)
: base(dbRepository)
{
_httpContextAccessor = httpContextAccessor;
_repository = dbRepository;
//多租户会用到这init代码其他情况可以不用
//base.Init(dbRepository);
GetAllCacheData();
}
public override PageGridData<Sys_Dashboard> GetPageData(PageDataOptions options)
{
QueryRelativeExpression = (ISugarQueryable<Sys_Dashboard> query) =>
{
if (!UserContext.Current.IsSuperAdmin && AppSetting.UseDynamicShareDB)
{
query = query.Where(x => x.DbServiceId == UserContext.CurrentServiceId);
}
return query;
};
return base.GetPageData(options);
}
WebResponseContent webResponse = new WebResponseContent();
public override WebResponseContent Add(SaveModel saveDataModel)
{
AddOnExecuting = (Sys_Dashboard dashboard, object list) =>
{
dashboard.DashboardId = Guid.NewGuid();
dashboard.DashboardCode = dashboard.DashboardId.ToString();
dashboard.DbServiceId = UserContext.CurrentServiceId;
dashboard.TenancyId = UserContext.CurrentServiceId.ToString();
return webResponse.OK();
};
var result = base.Add(saveDataModel);
if (result.Status)
{
RemoveCache();
}
return result;
}
public override WebResponseContent Update(SaveModel saveModel)
{
var result = base.Update(saveModel);
if (result.Status)
{
RemoveCache();
}
return result;
}
public override WebResponseContent Del(object[] keys, bool delList = true)
{
RemoveCache();
return base.Del(keys, delList);
}
/// <summary>
/// 编译、预览、查看获取全部配置
/// </summary>
/// <param name="id"></param>
/// <param name="view"></param>
/// <returns></returns>
public async Task<object> GetLayoutData(Guid id, bool view)
{
var data = await repository.FindAsIQueryable(x => x.DashboardId == id).FirstOrDefaultAsync();
return data;
}
/// <summary>
/// 获取每项sql数据
/// </summary>
/// <param name="id"></param>
/// <param name="view"></param>
/// <returns></returns>
public async Task<object> GetItemData(List<SearchParameters> filters, Guid id, string itemId, DateTime? date1, DateTime? date2, string filterType)
{
var info = GetAllCacheData().Where(x => x.DashboardId == id).FirstOrDefault();
if (info == null)
{
return null;
}
var item = info.DashboardItems.Where(x => x.ItemId == itemId).FirstOrDefault();
if (item == null)
{
return null;
}
return await ExecSql(filters, item.Sql, item.DbService, item.IsProc, date1, date2, filterType);
}
private async Task<object> ExecSql(List<SearchParameters> filters, string sql, string dbService, bool isProc, DateTime? date1, DateTime? date2, string filterType)
{
if (date1 == null && date2 == null && !string.IsNullOrEmpty(filterType))
{
switch (filterType)
{
case "今天":
date1 = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day);
date2 = DateTime.Now;
break;
case "近7天":
date1 = DateTime.Today.AddDays(-6);
date2 = DateTime.Now;
break;
case "本月":
date1 = new DateTime(DateTime.Now.Year, DateTime.Now.Month, 1);
date2 = DateTime.Now.AddDays(1); ;
break;
case "近1月":
date1 = DateTime.Today.AddMonths(-1).AddDays(1);
date2 = DateTime.Now.AddMonths(1);
break;
case "近半年":
date1 = DateTime.Today.AddMonths(-6).AddMonths(1);
date2 = DateTime.Now.AddMonths(1);
break;
case "近一年":
date1 = DateTime.Today.AddYears(-1).AddMonths(1);
date2 = DateTime.Now.AddMonths(1);
break;
default:
break;
}
}
try
{
sql = FilterSql(sql);
if (date1 == null)
{
date1 = DateTime.Now.AddYears(-20);
}
if (date2 == null)
{
date2 = DateTime.Now.AddDays(2);
}
var ado = DbManger.GetConnection(dbService).Ado;
if (isProc)
{
ado = ado.UseStoredProcedure();
}
var parameters = new List<SugarParameter>(){
new SugarParameter("@date1",date1),
new SugarParameter("@date2",date2)
};
if (filters != null)
{
foreach (var item in filters)
{
string value = item.Value;
if (value == "null")
{
value = "";
}
//if (isProc && item.DisplayType == "like")
//{
//}
parameters.Add(new SugarParameter(item.Name, value));
}
}
IDashboardFilterMetaData filter = new DashboardFilter();
var res = filter.OnActionExecuting(sql, parameters, dbService, isProc, date1, date2, filterType);
var result = await ado.SqlQueryAsync<object>(res.sql, res.parameters);
return result;
}
catch (Exception ex)
{
string message = $"sql执行{(isProc ? "" : "")}异常,{sql},{ex.Message + ex.InnerException + ex.StackTrace}";
Logger.Error(message);
throw new Exception(message);
}
}
/// <summary>
/// 编译执行sql
/// </summary>
/// <param name="id"></param>
/// <param name="view"></param>
/// <returns></returns>
public async Task<object> ExecSql(Dictionary<string, string> dic)
{
List<SearchParameters> filters = null;
if (dic.TryGetValue("filters", out string value) && !string.IsNullOrEmpty(value))
{
filters = value.DeserializeObject<List<SearchParameters>>();
}
return await ExecSql(
filters,
dic["sql"],
GetValue(dic, "db"),
GetValue(dic, "isProc") == "1",
GetValue(dic, "date1").GetDateTime(),
GetValue(dic, "date2").GetDateTime(),
GetValue(dic, "filterType"));
}
private string[] illegalKeywords = { " delete ", " drop ", " truncate ", " update ", " insert ", " alter ", " create ", " grant ", " revoke ", " exec ", " execute ", " shutdown " };
private string FilterSql(string sql)
{
foreach (string keyword in illegalKeywords)
{
sql = sql.Replace(keyword, "", StringComparison.OrdinalIgnoreCase);
}
return sql;
}
/// <summary>
/// 当前服务器的菜单版本
/// </summary>
private static string _DashboardVersionn = "";
private const string _DashboardCacheKey = "DashboardKey";
private static List<DashboardInfo> sysDashboards = new List<DashboardInfo>();
private static object _DashboardObj = new object();
private string GetValue(Dictionary<string, string> dic, string key)
{
if (!dic.TryGetValue(key, out string vlaue))
{
return null;
}
return vlaue?.ToString();
}
private string GetObjectValue(Dictionary<string, object> dic, string key)
{
if (!dic.TryGetValue(key, out object vlaue))
{
return null;
}
return vlaue?.ToString();
}
private void RemoveCache()
{
CacheContext.Remove(_DashboardCacheKey);
}
/// <summary>
/// 获取配置
/// </summary>
/// <returns></returns>
private List<DashboardInfo> GetAllCacheData()
{
string _cacheVersion = CacheContext.Get(_DashboardCacheKey);
if (_DashboardVersionn != "" && _DashboardVersionn == _cacheVersion)
{
return sysDashboards ?? new List<DashboardInfo>();
}
lock (_DashboardObj)
{
if (_DashboardVersionn != "" && sysDashboards != null && _DashboardVersionn == _cacheVersion) return sysDashboards;
//2020.12.27增加菜单界面上不显示,但可以分配权限
sysDashboards = repository.FindAsIQueryable(x => true).ToList().Serialize().DeserializeObject<List<DashboardInfo>>();
foreach (var item in sysDashboards)
{
if (string.IsNullOrEmpty(item.Options))
{
item.DashboardItems = new List<DashboardItem>();
}
else
{
item.DashboardItems = item.Options.DeserializeObject<List<Dictionary<string, object>>>()
.Select(dic => new DashboardItem()
{
ItemId = GetObjectValue(dic, "i"),
Sql = GetObjectValue(dic, "sql"),
DbService = GetObjectValue(dic, "db"),
IsProc = GetObjectValue(dic, "isProc") == "1"
}).ToList();
}
}
string cacheVersion = CacheContext.Get(_DashboardCacheKey);
//if (string.IsNullOrEmpty(cacheVersion))
//{
cacheVersion = DateTime.Now.ToString("yyyyMMddHHMMsss");
CacheContext.Add(_DashboardCacheKey, cacheVersion);
//}
//else
//{
_DashboardVersionn = cacheVersion;
//}
}
return sysDashboards;
}
}
public class DashboardInfo : Sys_Dashboard
{
public List<DashboardItem> DashboardItems;
}
public class DashboardItem
{
public string ItemId { get; set; }
public string Sql { get; set; }
public string DbService { get; set; }
public bool IsProc { get; set; }
}
}

View File

@@ -0,0 +1,22 @@
/*
*Authorjxx
*Contact283591387@qq.com
*代码由框架生成,此处任何更改都可能导致被代码生成器覆盖
*所有业务编写全部应在Partial文件夹下Sys_DashboardService与ISys_DashboardService中编写
*/
using VolPro.Sys.IRepositories;
using VolPro.Sys.IServices;
using VolPro.Core.BaseProvider;
using VolPro.Core.Extensions.AutofacManager;
using VolPro.Entity.DomainModels;
namespace VolPro.Sys.Services
{
public partial class Sys_DashboardService : ServiceBase<Sys_Dashboard, ISys_DashboardRepository>
, ISys_DashboardService, IDependency
{
public static ISys_DashboardService Instance
{
get { return AutofacContainerModule.GetService<ISys_DashboardService>(); } }
}
}

View File

@@ -0,0 +1,188 @@
/*
*所有关于Sys_DbService类的业务代码应在此处编写
*可使用repository.调用常用方法获取EF/Dapper等信息
*如果需要事务请使用repository.DbContextBeginTransaction
*也可使用DBServerProvider.手动获取数据库相关信息
*用户信息、权限、角色等使用UserContext.Current操作
*Sys_DbServiceService对增、删、改查、导入、导出、审核业务代码扩展参照ServiceFunFilter
*/
using VolPro.Core.BaseProvider;
using VolPro.Core.Extensions.AutofacManager;
using VolPro.Entity.DomainModels;
using System.Linq;
using VolPro.Core.Utilities;
using System.Linq.Expressions;
using VolPro.Core.Extensions;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.AspNetCore.Http;
using VolPro.Sys.IRepositories;
using VolPro.Core.CacheManager;
using VolPro.Core.Configuration;
using System;
using VolPro.Core.Services;
using VolPro.Core.DBManager;
using VolPro.Core.Dapper;
using VolPro.Core.DbSqlSugar;
namespace VolPro.Sys.Services
{
public partial class Sys_DbServiceService
{
private readonly IHttpContextAccessor _httpContextAccessor;
private readonly ISys_DbServiceRepository _repository;//访问数据库
[ActivatorUtilitiesConstructor]
public Sys_DbServiceService(
ISys_DbServiceRepository dbRepository,
IHttpContextAccessor httpContextAccessor
)
: base(dbRepository)
{
_httpContextAccessor = httpContextAccessor;
_repository = dbRepository;
//多租户会用到这init代码其他情况可以不用
//base.Init(dbRepository);
}
WebResponseContent webResponse = new WebResponseContent();
public override PageGridData<Sys_DbService> GetPageData(PageDataOptions options)
{
var data = base.GetPageData(options);
foreach (var item in data.rows)
{
item.Pwd = null;
}
return data;
}
public override WebResponseContent Add(SaveModel saveDataModel)
{
return DbCache.Reload(base.Add(saveDataModel));
}
public override WebResponseContent Update(SaveModel saveModel)
{
if (saveModel.MainData.TryGetValue("Pwd", out object value))
{
if (string.IsNullOrEmpty(value?.ToString()))
{
saveModel.MainData.Remove("Pwd");
}
}
return DbCache.Reload(base.Update(saveModel));
}
public override WebResponseContent Del(object[] keys, bool delList = true)
{
return DbCache.Reload(base.Del(keys, delList));
}
public WebResponseContent CreateDb(Guid id)
{
var item = DbCache.GetDbInfo(id);
try
{
if (item == null)
{
return webResponse.Error("请配置数据库名、ip地址、帐号与密码");
}
string connectionString=DbCache.InitConnection(item,"master");
var dapper = DBServerProvider.Db; //DBServerProvider.GetServiceDb(item.DbServiceId);//DBServerProvider.GetSqlDapper(item.DbServiceId.ToString());
string sql = " select name from sys.databases where name = @name";
var _dbName = dapper.ExecuteScalar(sql, new { name = item.DatabaseName });
if (_dbName != null && _dbName.ToString() != "")
{
return webResponse.Error($"【{ item.DatabaseName}】已存在");
}
sql = GetCopyDbSql(item.DatabaseName);
dapper.SetTimout(60 * 3).ExcuteNonQuery(sql, new { item.DatabaseName, id });
}
catch (Exception ex)
{
string message = $"创建数据库异常:ID:{item.DatabaseName},异常信息:{ex.Message}";
Console.WriteLine(message);
Logger.Error(message);
return webResponse.Error(message);
}
return webResponse.OK("创建成功");
}
private string GetCopyDbSql(string dbName)
{
string DBPath = AppSetting.GetSettingString("DBPath");
string DBBackPath = AppSetting.GetSettingString("DBBackPath");
string DB_Empty = "DB_Empty";
string sql = @$"USE [master]
CREATE DATABASE [{dbName}]
CONTAINMENT = NONE
ON PRIMARY
( NAME = N'{dbName}', FILENAME = N'{DBPath}\{dbName}.mdf' , SIZE = 5120KB , FILEGROWTH = 1024KB )
LOG ON
( NAME = N'{dbName}_log', FILENAME = N'{DBPath}\{dbName}_log.ldf' , SIZE = 2048KB , FILEGROWTH = 10%)
ALTER DATABASE [{dbName}] SET COMPATIBILITY_LEVEL = 110
ALTER DATABASE [{dbName}] SET ANSI_NULL_DEFAULT OFF
ALTER DATABASE [{dbName}] SET ANSI_NULLS OFF
ALTER DATABASE [{dbName}] SET ANSI_PADDING OFF
ALTER DATABASE [{dbName}] SET ANSI_WARNINGS OFF
ALTER DATABASE [{dbName}] SET ARITHABORT OFF
ALTER DATABASE [{dbName}] SET AUTO_CLOSE OFF
ALTER DATABASE [{dbName}] SET AUTO_CREATE_STATISTICS ON
ALTER DATABASE [{dbName}] SET AUTO_SHRINK OFF
ALTER DATABASE [{dbName}] SET AUTO_UPDATE_STATISTICS ON
ALTER DATABASE [{dbName}] SET CURSOR_CLOSE_ON_COMMIT OFF
ALTER DATABASE [{dbName}] SET CURSOR_DEFAULT GLOBAL
ALTER DATABASE [{dbName}] SET CONCAT_NULL_YIELDS_NULL OFF
ALTER DATABASE [{dbName}] SET NUMERIC_ROUNDABORT OFF
ALTER DATABASE [{dbName}] SET QUOTED_IDENTIFIER OFF
ALTER DATABASE [{dbName}] SET RECURSIVE_TRIGGERS OFF
ALTER DATABASE [{dbName}] SET DISABLE_BROKER
ALTER DATABASE [{dbName}] SET AUTO_UPDATE_STATISTICS_ASYNC OFF
ALTER DATABASE [{dbName}] SET DATE_CORRELATION_OPTIMIZATION OFF
ALTER DATABASE [{dbName}] SET PARAMETERIZATION SIMPLE
ALTER DATABASE [{dbName}] SET READ_COMMITTED_SNAPSHOT OFF
ALTER DATABASE [{dbName}] SET READ_WRITE
ALTER DATABASE [{dbName}] SET RECOVERY FULL
ALTER DATABASE [{dbName}] SET MULTI_USER
ALTER DATABASE [{dbName}] SET PAGE_VERIFY CHECKSUM
ALTER DATABASE [{dbName}] SET TARGET_RECOVERY_TIME = 0 SECONDS
IF NOT EXISTS (SELECT name FROM sys.filegroups WHERE is_default=1 AND name = N'PRIMARY') ALTER DATABASE [{dbName}] MODIFY FILEGROUP [PRIMARY] DEFAULT
USE [master]
--备份数据库
BACKUP DATABASE [DB_Empty] TO DISK = N'{DBBackPath}\DB_Empty.bak' WITH COPY_ONLY, NOFORMAT, INIT,
NAME = N'{DB_Empty}', SKIP, NOREWIND, NOUNLOAD, STATS = 10
DECLARE @tomdf NVARCHAR(50)=N'{DBPath}\{dbName}.mdf'
DECLARE @tolog NVARCHAR(50)=N'{DBPath}\{dbName}.ldf'
RESTORE DATABASE [{dbName}] FROM DISK = N'{DBBackPath}\{DB_Empty}.bak' WITH FILE = 1,
MOVE N'{DB_Empty}' TO @tomdf, MOVE N'{DB_Empty}_log' TO @tolog, NOUNLOAD, REPLACE, STATS = 5;";
return sql;
}
}
}

View File

@@ -0,0 +1,27 @@
/*
*Authorjxx
*Contact283591387@qq.com
*代码由框架生成,此处任何更改都可能导致被代码生成器覆盖
*所有业务编写全部应在Partial文件夹下Sys_DbServiceService与ISys_DbServiceService中编写
*/
using VolPro.Sys.IRepositories;
using VolPro.Sys.IServices;
using VolPro.Core.BaseProvider;
using VolPro.Core.Extensions.AutofacManager;
using VolPro.Entity.DomainModels;
namespace VolPro.Sys.Services
{
public partial class Sys_DbServiceService : ServiceBase<Sys_DbService, ISys_DbServiceRepository>
, ISys_DbServiceService, IDependency
{
public Sys_DbServiceService(ISys_DbServiceRepository repository)
: base(repository)
{
Init(repository);
}
public static ISys_DbServiceService Instance
{
get { return AutofacContainerModule.GetService<ISys_DbServiceService>(); } }
}
}

View File

@@ -0,0 +1,41 @@
/*
*所有关于Sys_Group类的业务代码应在此处编写
*可使用repository.调用常用方法获取EF/Dapper等信息
*如果需要事务请使用repository.DbContextBeginTransaction
*也可使用DBServerProvider.手动获取数据库相关信息
*用户信息、权限、角色等使用UserContext.Current操作
*Sys_GroupService对增、删、改查、导入、导出、审核业务代码扩展参照ServiceFunFilter
*/
using VolPro.Core.BaseProvider;
using VolPro.Core.Extensions.AutofacManager;
using VolPro.Entity.DomainModels;
using System.Linq;
using VolPro.Core.Utilities;
using System.Linq.Expressions;
using VolPro.Core.Extensions;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.AspNetCore.Http;
using VolPro.Sys.IRepositories;
namespace VolPro.Sys.Services
{
public partial class Sys_GroupService
{
private readonly IHttpContextAccessor _httpContextAccessor;
private readonly ISys_GroupRepository _repository;//访问数据库
[ActivatorUtilitiesConstructor]
public Sys_GroupService(
ISys_GroupRepository dbRepository,
IHttpContextAccessor httpContextAccessor
)
: base(dbRepository)
{
_httpContextAccessor = httpContextAccessor;
_repository = dbRepository;
//多租户会用到这init代码其他情况可以不用
//base.Init(dbRepository);
}
}
}

View File

@@ -0,0 +1,27 @@
/*
*Authorjxx
*Contact283591387@qq.com
*代码由框架生成,此处任何更改都可能导致被代码生成器覆盖
*所有业务编写全部应在Partial文件夹下Sys_GroupService与ISys_GroupService中编写
*/
using VolPro.Sys.IRepositories;
using VolPro.Sys.IServices;
using VolPro.Core.BaseProvider;
using VolPro.Core.Extensions.AutofacManager;
using VolPro.Entity.DomainModels;
namespace VolPro.Sys.Services
{
public partial class Sys_GroupService : ServiceBase<Sys_Group, ISys_GroupRepository>
, ISys_GroupService, IDependency
{
public Sys_GroupService(ISys_GroupRepository repository)
: base(repository)
{
Init(repository);
}
public static ISys_GroupService Instance
{
get { return AutofacContainerModule.GetService<ISys_GroupService>(); } }
}
}

View File

@@ -0,0 +1,48 @@
/*
*所有关于Sys_Language类的业务代码应在此处编写
*可使用repository.调用常用方法获取EF/Dapper等信息
*如果需要事务请使用repository.DbContextBeginTransaction
*也可使用DBServerProvider.手动获取数据库相关信息
*用户信息、权限、角色等使用UserContext.Current操作
*Sys_LanguageService对增、删、改查、导入、导出、审核业务代码扩展参照ServiceFunFilter
*/
using VolPro.Core.BaseProvider;
using VolPro.Core.Extensions.AutofacManager;
using VolPro.Entity.DomainModels;
using System.Linq;
using VolPro.Core.Utilities;
using System.Linq.Expressions;
using VolPro.Core.Extensions;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.AspNetCore.Http;
using VolPro.Sys.IRepositories;
using VolPro.Core.Language;
namespace VolPro.Sys.Services
{
public partial class Sys_LanguageService
{
private readonly IHttpContextAccessor _httpContextAccessor;
private readonly ISys_LanguageRepository _repository;//访问数据库
[ActivatorUtilitiesConstructor]
public Sys_LanguageService(
ISys_LanguageRepository dbRepository,
IHttpContextAccessor httpContextAccessor
)
: base(dbRepository)
{
_httpContextAccessor = httpContextAccessor;
_repository = dbRepository;
//多租户会用到这init代码其他情况可以不用
//base.Init(dbRepository);
}
public WebResponseContent CreateLanguagePack()
{
repository.DbContext.CreateLanguagePack();
return WebResponseContent.Instance.OK("操作成功", true);
}
}
}

View File

@@ -0,0 +1,27 @@
/*
*Authorjxx
*Contact283591387@qq.com
*代码由框架生成,此处任何更改都可能导致被代码生成器覆盖
*所有业务编写全部应在Partial文件夹下Sys_LanguageService与ISys_LanguageService中编写
*/
using VolPro.Sys.IRepositories;
using VolPro.Sys.IServices;
using VolPro.Core.BaseProvider;
using VolPro.Core.Extensions.AutofacManager;
using VolPro.Entity.DomainModels;
namespace VolPro.Sys.Services
{
public partial class Sys_LanguageService : ServiceBase<Sys_Language, ISys_LanguageRepository>
, ISys_LanguageService, IDependency
{
public Sys_LanguageService(ISys_LanguageRepository repository)
: base(repository)
{
Init(repository);
}
public static ISys_LanguageService Instance
{
get { return AutofacContainerModule.GetService<ISys_LanguageService>(); } }
}
}

View File

@@ -0,0 +1,41 @@
/*
*所有关于Sys_ActionLog类的业务代码应在此处编写
*可使用repository.调用常用方法获取EF/Dapper等信息
*如果需要事务请使用repository.DbContextBeginTransaction
*也可使用DBServerProvider.手动获取数据库相关信息
*用户信息、权限、角色等使用UserContext.Current操作
*Sys_ActionLogService对增、删、改查、导入、导出、审核业务代码扩展参照ServiceFunFilter
*/
using VolPro.Core.BaseProvider;
using VolPro.Core.Extensions.AutofacManager;
using VolPro.Entity.DomainModels;
using System.Linq;
using VolPro.Core.Utilities;
using System.Linq.Expressions;
using VolPro.Core.Extensions;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.AspNetCore.Http;
using VolPro.Sys.IRepositories;
namespace VolPro.Sys.Services
{
public partial class Sys_ActionLogService
{
private readonly IHttpContextAccessor _httpContextAccessor;
private readonly ISys_ActionLogRepository _repository;//访问数据库
[ActivatorUtilitiesConstructor]
public Sys_ActionLogService(
ISys_ActionLogRepository dbRepository,
IHttpContextAccessor httpContextAccessor
)
: base(dbRepository)
{
_httpContextAccessor = httpContextAccessor;
_repository = dbRepository;
//多租户会用到这init代码其他情况可以不用
//base.Init(dbRepository);
}
}
}

View File

@@ -0,0 +1,22 @@
/*
*Authorjxx
*Contact283591387@qq.com
*代码由框架生成,此处任何更改都可能导致被代码生成器覆盖
*所有业务编写全部应在Partial文件夹下Sys_ActionLogService与ISys_ActionLogService中编写
*/
using VolPro.Sys.IRepositories;
using VolPro.Sys.IServices;
using VolPro.Core.BaseProvider;
using VolPro.Core.Extensions.AutofacManager;
using VolPro.Entity.DomainModels;
namespace VolPro.Sys.Services
{
public partial class Sys_ActionLogService : ServiceBase<Sys_ActionLog, ISys_ActionLogRepository>
, ISys_ActionLogService, IDependency
{
public static ISys_ActionLogService Instance
{
get { return AutofacContainerModule.GetService<ISys_ActionLogService>(); } }
}
}

View File

@@ -0,0 +1,41 @@
/*
*所有关于Sys_NotificationLog类的业务代码应在此处编写
*可使用repository.调用常用方法获取EF/Dapper等信息
*如果需要事务请使用repository.DbContextBeginTransaction
*也可使用DBServerProvider.手动获取数据库相关信息
*用户信息、权限、角色等使用UserContext.Current操作
*Sys_NotificationLogService对增、删、改查、导入、导出、审核业务代码扩展参照ServiceFunFilter
*/
using VolPro.Core.BaseProvider;
using VolPro.Core.Extensions.AutofacManager;
using VolPro.Entity.DomainModels;
using System.Linq;
using VolPro.Core.Utilities;
using System.Linq.Expressions;
using VolPro.Core.Extensions;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.AspNetCore.Http;
using VolPro.Sys.IRepositories;
namespace VolPro.Sys.Services
{
public partial class Sys_NotificationLogService
{
private readonly IHttpContextAccessor _httpContextAccessor;
private readonly ISys_NotificationLogRepository _repository;//访问数据库
[ActivatorUtilitiesConstructor]
public Sys_NotificationLogService(
ISys_NotificationLogRepository dbRepository,
IHttpContextAccessor httpContextAccessor
)
: base(dbRepository)
{
_httpContextAccessor = httpContextAccessor;
_repository = dbRepository;
//多租户会用到这init代码其他情况可以不用
//base.Init(dbRepository);
}
}
}

View File

@@ -0,0 +1,52 @@
/*
*所有关于Sys_Notification类的业务代码应在此处编写
*可使用repository.调用常用方法获取EF/Dapper等信息
*如果需要事务请使用repository.DbContextBeginTransaction
*也可使用DBServerProvider.手动获取数据库相关信息
*用户信息、权限、角色等使用UserContext.Current操作
*Sys_NotificationService对增、删、改查、导入、导出、审核业务代码扩展参照ServiceFunFilter
*/
using VolPro.Core.BaseProvider;
using VolPro.Core.Extensions.AutofacManager;
using VolPro.Entity.DomainModels;
using System.Linq;
using VolPro.Core.Utilities;
using System.Linq.Expressions;
using VolPro.Core.Extensions;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.AspNetCore.Http;
using VolPro.Sys.IRepositories;
using System.Net;
namespace VolPro.Sys.Services
{
public partial class Sys_NotificationService
{
private readonly IHttpContextAccessor _httpContextAccessor;
private readonly ISys_NotificationRepository _repository;//访问数据库
[ActivatorUtilitiesConstructor]
public Sys_NotificationService(
ISys_NotificationRepository dbRepository,
IHttpContextAccessor httpContextAccessor
)
: base(dbRepository)
{
_httpContextAccessor = httpContextAccessor;
_repository = dbRepository;
//多租户会用到这init代码其他情况可以不用
//base.Init(dbRepository);
}
public override WebResponseContent Add(SaveModel saveDataModel)
{
WebResponseContent webResponse = new WebResponseContent();
AddOnExecuting = (Sys_Notification noti, object list) =>
{
noti.PublishStatus = 0;
return webResponse.OK();
};
return base.Add(saveDataModel);
}
}
}

View File

@@ -0,0 +1,41 @@
/*
*所有关于Sys_NotificationTemplate类的业务代码应在此处编写
*可使用repository.调用常用方法获取EF/Dapper等信息
*如果需要事务请使用repository.DbContextBeginTransaction
*也可使用DBServerProvider.手动获取数据库相关信息
*用户信息、权限、角色等使用UserContext.Current操作
*Sys_NotificationTemplateService对增、删、改查、导入、导出、审核业务代码扩展参照ServiceFunFilter
*/
using VolPro.Core.BaseProvider;
using VolPro.Core.Extensions.AutofacManager;
using VolPro.Entity.DomainModels;
using System.Linq;
using VolPro.Core.Utilities;
using System.Linq.Expressions;
using VolPro.Core.Extensions;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.AspNetCore.Http;
using VolPro.Sys.IRepositories;
namespace VolPro.Sys.Services
{
public partial class Sys_NotificationTemplateService
{
private readonly IHttpContextAccessor _httpContextAccessor;
private readonly ISys_NotificationTemplateRepository _repository;//访问数据库
[ActivatorUtilitiesConstructor]
public Sys_NotificationTemplateService(
ISys_NotificationTemplateRepository dbRepository,
IHttpContextAccessor httpContextAccessor
)
: base(dbRepository)
{
_httpContextAccessor = httpContextAccessor;
_repository = dbRepository;
//多租户会用到这init代码其他情况可以不用
//base.Init(dbRepository);
}
}
}

View File

@@ -0,0 +1,22 @@
/*
*Authorjxx
*Contact283591387@qq.com
*代码由框架生成,此处任何更改都可能导致被代码生成器覆盖
*所有业务编写全部应在Partial文件夹下Sys_NotificationLogService与ISys_NotificationLogService中编写
*/
using VolPro.Sys.IRepositories;
using VolPro.Sys.IServices;
using VolPro.Core.BaseProvider;
using VolPro.Core.Extensions.AutofacManager;
using VolPro.Entity.DomainModels;
namespace VolPro.Sys.Services
{
public partial class Sys_NotificationLogService : ServiceBase<Sys_NotificationLog, ISys_NotificationLogRepository>
, ISys_NotificationLogService, IDependency
{
public static ISys_NotificationLogService Instance
{
get { return AutofacContainerModule.GetService<ISys_NotificationLogService>(); } }
}
}

View File

@@ -0,0 +1,22 @@
/*
*Authorjxx
*Contact283591387@qq.com
*代码由框架生成,此处任何更改都可能导致被代码生成器覆盖
*所有业务编写全部应在Partial文件夹下Sys_NotificationService与ISys_NotificationService中编写
*/
using VolPro.Sys.IRepositories;
using VolPro.Sys.IServices;
using VolPro.Core.BaseProvider;
using VolPro.Core.Extensions.AutofacManager;
using VolPro.Entity.DomainModels;
namespace VolPro.Sys.Services
{
public partial class Sys_NotificationService : ServiceBase<Sys_Notification, ISys_NotificationRepository>
, ISys_NotificationService, IDependency
{
public static ISys_NotificationService Instance
{
get { return AutofacContainerModule.GetService<ISys_NotificationService>(); } }
}
}

View File

@@ -0,0 +1,22 @@
/*
*Authorjxx
*Contact283591387@qq.com
*代码由框架生成,此处任何更改都可能导致被代码生成器覆盖
*所有业务编写全部应在Partial文件夹下Sys_NotificationTemplateService与ISys_NotificationTemplateService中编写
*/
using VolPro.Sys.IRepositories;
using VolPro.Sys.IServices;
using VolPro.Core.BaseProvider;
using VolPro.Core.Extensions.AutofacManager;
using VolPro.Entity.DomainModels;
namespace VolPro.Sys.Services
{
public partial class Sys_NotificationTemplateService : ServiceBase<Sys_NotificationTemplate, ISys_NotificationTemplateRepository>
, ISys_NotificationTemplateService, IDependency
{
public static ISys_NotificationTemplateService Instance
{
get { return AutofacContainerModule.GetService<ISys_NotificationTemplateService>(); } }
}
}

View File

@@ -0,0 +1,41 @@
/*
*所有关于Sys_QuartzLog类的业务代码应在此处编写
*可使用repository.调用常用方法获取EF/Dapper等信息
*如果需要事务请使用repository.DbContextBeginTransaction
*也可使用DBServerProvider.手动获取数据库相关信息
*用户信息、权限、角色等使用UserContext.Current操作
*Sys_QuartzLogService对增、删、改查、导入、导出、审核业务代码扩展参照ServiceFunFilter
*/
using VolPro.Core.BaseProvider;
using VolPro.Core.Extensions.AutofacManager;
using VolPro.Entity.DomainModels;
using System.Linq;
using VolPro.Core.Utilities;
using System.Linq.Expressions;
using VolPro.Core.Extensions;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.AspNetCore.Http;
using VolPro.Sys.IRepositories;
namespace VolPro.Sys.Services
{
public partial class Sys_QuartzLogService
{
private readonly IHttpContextAccessor _httpContextAccessor;
private readonly ISys_QuartzLogRepository _repository;//访问数据库
[ActivatorUtilitiesConstructor]
public Sys_QuartzLogService(
ISys_QuartzLogRepository dbRepository,
IHttpContextAccessor httpContextAccessor
)
: base(dbRepository)
{
_httpContextAccessor = httpContextAccessor;
_repository = dbRepository;
//多租户会用到这init代码其他情况可以不用
//base.Init(dbRepository);
}
}
}

View File

@@ -0,0 +1,140 @@
/*
*所有关于Sys_QuartzOptions类的业务代码应在此处编写
*可使用repository.调用常用方法获取EF/Dapper等信息
*如果需要事务请使用repository.DbContextBeginTransaction
*也可使用DBServerProvider.手动获取数据库相关信息
*用户信息、权限、角色等使用UserContext.Current操作
*Sys_QuartzOptionsService对增、删、改查、导入、导出、审核业务代码扩展参照ServiceFunFilter
*/
using VolPro.Core.BaseProvider;
using VolPro.Core.Extensions.AutofacManager;
using VolPro.Entity.DomainModels;
using System.Linq;
using VolPro.Core.Utilities;
using System.Linq.Expressions;
using VolPro.Core.Extensions;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.AspNetCore.Http;
using VolPro.Sys.IRepositories;
using VolPro.Core.Quartz;
using Quartz;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
namespace VolPro.Sys.Services
{
public partial class Sys_QuartzOptionsService
{
private readonly IHttpContextAccessor _httpContextAccessor;
private readonly ISys_QuartzOptionsRepository _repository;//访问数据库
private readonly ISchedulerFactory _schedulerFactory;
[ActivatorUtilitiesConstructor]
public Sys_QuartzOptionsService(
ISys_QuartzOptionsRepository dbRepository,
IHttpContextAccessor httpContextAccessor,
ISchedulerFactory schedulerFactory
)
: base(dbRepository)
{
_httpContextAccessor = httpContextAccessor;
_repository = dbRepository;
_schedulerFactory = schedulerFactory;
//多租户会用到这init代码其他情况可以不用
//base.Init(dbRepository);
}
public override PageGridData<Sys_QuartzOptions> GetPageData(PageDataOptions options)
{
var result= base.GetPageData(options);
return result;
}
WebResponseContent webResponse = new WebResponseContent();
public override WebResponseContent Add(SaveModel saveDataModel)
{
AddOnExecuting = (Sys_QuartzOptions options, object list) =>
{
options.Status = (int)TriggerState.Paused;
return webResponse.OK();
};
Sys_QuartzOptions ops = null;
AddOnExecuted = (Sys_QuartzOptions options, object list) =>
{
ops = options;
return webResponse.OK();
};
var result= base.Add(saveDataModel);
if (result.Status)
{
ops.AddJob(_schedulerFactory).GetAwaiter().GetResult();
}
return result;
}
public override WebResponseContent Del(object[] keys, bool delList = true)
{
var ids = keys.Select(s => (Guid)(s.GetGuid())).ToArray();
repository.FindAsIQueryable(x => ids.Contains(x.Id)).ToList().ForEach(options =>
{
_schedulerFactory.Remove(options).GetAwaiter().GetResult();
});
return base.Del(keys, delList);
}
public override WebResponseContent Update(SaveModel saveModel)
{
UpdateOnExecuted = (Sys_QuartzOptions options, object addList, object updateList, List<object> delKeys) =>
{
_schedulerFactory.Update(options).GetAwaiter().GetResult();
return webResponse.OK();
};
return base.Update(saveModel);
}
/// <summary>
/// 手动执行一次
/// </summary>
/// <param name="taskOptions"></param>
/// <returns></returns>
public async Task<object> Run(Sys_QuartzOptions taskOptions)
{
return await _schedulerFactory.Run(taskOptions);
}
/// <summary>
/// 开启任务
/// </summary>
/// <param name="schedulerFactory"></param>
/// <param name="taskOptions"></param>
/// <returns></returns>
public async Task<object> Start(Sys_QuartzOptions taskOptions)
{
var result = await _schedulerFactory.Start(taskOptions);
if (taskOptions.Status != (int)TriggerState.Normal)
{
taskOptions.Status = (int)TriggerState.Normal;
_repository.Update(taskOptions, x => new { x.Status }, true);
}
return result;
}
/// <summary>
/// 暂停任务
/// </summary>
/// <param name="schedulerFactory"></param>
/// <param name="taskOptions"></param>
/// <returns></returns>
public async Task<object> Pause(Sys_QuartzOptions taskOptions)
{
// var result = await _schedulerFactory.Remove(taskOptions);
var result = await _schedulerFactory.Pause(taskOptions);
taskOptions.Status = (int)TriggerState.Paused;
_repository.Update(taskOptions, x => new { x.Status }, true);
return result;
}
}
}

View File

@@ -0,0 +1,27 @@
/*
*Authorjxx
*Contact283591387@qq.com
*代码由框架生成,此处任何更改都可能导致被代码生成器覆盖
*所有业务编写全部应在Partial文件夹下Sys_QuartzLogService与ISys_QuartzLogService中编写
*/
using VolPro.Sys.IRepositories;
using VolPro.Sys.IServices;
using VolPro.Core.BaseProvider;
using VolPro.Core.Extensions.AutofacManager;
using VolPro.Entity.DomainModels;
namespace VolPro.Sys.Services
{
public partial class Sys_QuartzLogService : ServiceBase<Sys_QuartzLog, ISys_QuartzLogRepository>
, ISys_QuartzLogService, IDependency
{
public Sys_QuartzLogService(ISys_QuartzLogRepository repository)
: base(repository)
{
Init(repository);
}
public static ISys_QuartzLogService Instance
{
get { return AutofacContainerModule.GetService<ISys_QuartzLogService>(); } }
}
}

View File

@@ -0,0 +1,27 @@
/*
*Authorjxx
*Contact283591387@qq.com
*代码由框架生成,此处任何更改都可能导致被代码生成器覆盖
*所有业务编写全部应在Partial文件夹下Sys_QuartzOptionsService与ISys_QuartzOptionsService中编写
*/
using VolPro.Sys.IRepositories;
using VolPro.Sys.IServices;
using VolPro.Core.BaseProvider;
using VolPro.Core.Extensions.AutofacManager;
using VolPro.Entity.DomainModels;
namespace VolPro.Sys.Services
{
public partial class Sys_QuartzOptionsService : ServiceBase<Sys_QuartzOptions, ISys_QuartzOptionsRepository>
, ISys_QuartzOptionsService, IDependency
{
public Sys_QuartzOptionsService(ISys_QuartzOptionsRepository repository)
: base(repository)
{
Init(repository);
}
public static ISys_QuartzOptionsService Instance
{
get { return AutofacContainerModule.GetService<ISys_QuartzOptionsService>(); } }
}
}

View File

@@ -0,0 +1,76 @@
/*
*所有关于Sys_CodeRule类的业务代码应在此处编写
*可使用repository.调用常用方法获取EF/Dapper等信息
*如果需要事务请使用repository.DbContextBeginTransaction
*也可使用DBServerProvider.手动获取数据库相关信息
*用户信息、权限、角色等使用UserContext.Current操作
*Sys_CodeRuleService对增、删、改查、导入、导出、审核业务代码扩展参照ServiceFunFilter
*/
using VolPro.Core.BaseProvider;
using VolPro.Core.Extensions.AutofacManager;
using VolPro.Entity.DomainModels;
using System.Linq;
using VolPro.Core.Utilities;
using System.Linq.Expressions;
using VolPro.Core.Extensions;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.AspNetCore.Http;
using VolPro.Sys.IRepositories;
using Microsoft.AspNetCore.Mvc.RazorPages;
using VolPro.Core.ManageUser;
namespace VolPro.Sys.Services
{
public partial class Sys_CodeRuleService
{
private readonly IHttpContextAccessor _httpContextAccessor;
private readonly ISys_CodeRuleRepository _repository;//访问数据库
[ActivatorUtilitiesConstructor]
public Sys_CodeRuleService(
ISys_CodeRuleRepository dbRepository,
IHttpContextAccessor httpContextAccessor
)
: base(dbRepository)
{
_httpContextAccessor = httpContextAccessor;
_repository = dbRepository;
//多租户会用到这init代码其他情况可以不用
//base.Init(dbRepository);
}
public override WebResponseContent Add(SaveModel saveDataModel)
{
AddOnExecuting = (Sys_CodeRule rule, object list) =>
{
rule.DbServiceId = UserContext.CurrentServiceId;
rule.TenancyId = UserContext.CurrentServiceId.ToString();
return WebResponseContent.Instance.OK();
};
var res = base.Add(saveDataModel);
if (res.Status)
{
IdentityCode.Init();
}
return res;
}
public override WebResponseContent Update(SaveModel saveModel)
{
var res = base.Update(saveModel);
if (res.Status)
{
IdentityCode.Init();
}
return res;
}
public override WebResponseContent Del(object[] keys, bool delList = true)
{
var res = base.Del(keys, delList);
IdentityCode.Init();
return res;
}
}
}

View File

@@ -0,0 +1,22 @@
/*
*Authorjxx
*Contact283591387@qq.com
*代码由框架生成,此处任何更改都可能导致被代码生成器覆盖
*所有业务编写全部应在Partial文件夹下Sys_CodeRuleService与ISys_CodeRuleService中编写
*/
using VolPro.Sys.IRepositories;
using VolPro.Sys.IServices;
using VolPro.Core.BaseProvider;
using VolPro.Core.Extensions.AutofacManager;
using VolPro.Entity.DomainModels;
namespace VolPro.Sys.Services
{
public partial class Sys_CodeRuleService : ServiceBase<Sys_CodeRule, ISys_CodeRuleRepository>
, ISys_CodeRuleService, IDependency
{
public static ISys_CodeRuleService Instance
{
get { return AutofacContainerModule.GetService<ISys_CodeRuleService>(); } }
}
}

View File

@@ -0,0 +1,144 @@
/*
*所有关于Sys_Department类的业务代码应在此处编写
*可使用repository.调用常用方法获取EF/Dapper等信息
*如果需要事务请使用repository.DbContextBeginTransaction
*也可使用DBServerProvider.手动获取数据库相关信息
*用户信息、权限、角色等使用UserContext.Current操作
*Sys_DepartmentService对增、删、改查、导入、导出、审核业务代码扩展参照ServiceFunFilter
*/
using VolPro.Core.BaseProvider;
using VolPro.Core.Extensions.AutofacManager;
using VolPro.Entity.DomainModels;
using System.Linq;
using VolPro.Core.Utilities;
using System.Linq.Expressions;
using VolPro.Core.Extensions;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.AspNetCore.Http;
using VolPro.Sys.IRepositories;
using System.Collections.Generic;
using VolPro.Core.ManageUser;
using VolPro.Core.UserManager;
using SqlSugar;
using System;
using VolPro.Core.DbSqlSugar;
using VolPro.Sys.Repositories;
namespace VolPro.Sys.Services
{
public partial class Sys_DepartmentService
{
private readonly IHttpContextAccessor _httpContextAccessor;
private readonly ISys_DepartmentRepository _repository;//访问数据库
[ActivatorUtilitiesConstructor]
public Sys_DepartmentService(
ISys_DepartmentRepository dbRepository,
IHttpContextAccessor httpContextAccessor
)
: base(dbRepository)
{
_httpContextAccessor = httpContextAccessor;
_repository = dbRepository;
//多租户会用到这init代码其他情况可以不用
//base.Init(dbRepository);
}
public override PageGridData<Sys_Department> GetPageData(PageDataOptions options)
{
FilterData();
return base.GetPageData(options);
}
private void FilterData()
{
//限制 只能看自己部门及下级组织的数据
QueryRelativeExpression = (ISugarQueryable<Sys_Department> queryable) =>
{
if (UserContext.Current.IsSuperAdmin)
{
return queryable;
}
var deptIds = UserContext.Current.GetAllChildrenDeptIds();
return queryable.Where(x => deptIds.Contains(x.DepartmentId));
};
}
public override WebResponseContent Export(PageDataOptions pageData)
{
FilterData();
return base.Export(pageData);
}
WebResponseContent webResponse = new WebResponseContent();
public override WebResponseContent Add(SaveModel saveDataModel)
{
AddOnExecuting = (Sys_Department dept, object list) =>
{
dept.DbServiceId = UserContext.CurrentServiceId;
return webResponse.OK();
};
AddOnExecuted = (Sys_Department dept, object list) =>
{
//2023.12.01增加非理管员创建组织部门后台自动有此部门数据
if (!UserContext.Current.IsSuperAdmin && dept.ParentId == null)
{
Sys_UserDepartment userDepartment = new Sys_UserDepartment()
{
Id = Guid.NewGuid(),
DepartmentId = dept.DepartmentId,
CreateDate = DateTime.Now,
UserId = UserContext.Current.UserId,
Enable = 1,
Creator = UserContext.Current.UserTrueName
};
var userRepsitory = Sys_UserRepository.Instance;
string deptIds = userRepsitory.FindAsIQueryable(x => x.User_Id == UserContext.Current.UserId)
.Select(s => s.DeptIds).FirstOrDefault();
List<Guid> guids = new List<Guid>() { dept.DepartmentId };
if (!string.IsNullOrEmpty(deptIds))
{
guids.AddRange(deptIds.Split(",").Select(c => (Guid)c.GetGuid()));
}
userRepsitory.Update(new Sys_User
{
User_Id = UserContext.Current.UserId,
DeptIds = string.Join(",", guids.Distinct())
}, x => new { x.DeptIds });
repository.DbContext.Add(userDepartment);
repository.SaveChanges();
UserContext.Current.LogOut(UserContext.Current.UserId);
}
return webResponse.OK();
};
return base.Add(saveDataModel).Reload();
}
public override WebResponseContent Update(SaveModel saveModel)
{
if (!saveModel.MainData.ContainsKey("DbServiceId"))
{
saveModel.MainData["DbServiceId"] = UserContext.CurrentServiceId;
}
UpdateOnExecuting = (Sys_Department dept, object addList, object updateList, List<object> delKeys) =>
{
if (dept.ParentId == dept.DepartmentId)
{
return webResponse.Error("上级组织不能选择自己");
}
if (_repository.Exists(x => x.DepartmentId == dept.ParentId && x.ParentId == dept.DepartmentId))
{
return webResponse.Error("不能选择此上级组织");
}
return webResponse.OK();
};
return base.Update(saveModel).Reload();
}
public override WebResponseContent Del(object[] keys, bool delList = true)
{
return base.Del(keys, delList).Reload();
}
}
}

View File

@@ -0,0 +1,42 @@
using VolPro.Core.BaseProvider;
using VolPro.Core.Extensions.AutofacManager;
using VolPro.Entity.DomainModels;
using System.Linq;
using VolPro.Core.Extensions;
using System.Collections.Generic;
using VolPro.Core.Enums;
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.DependencyInjection;
using VolPro.Sys.IRepositories;
namespace VolPro.Sys.Services
{
public partial class Sys_DictionaryListService
{
private readonly IHttpContextAccessor _httpContextAccessor;
private readonly ISys_DictionaryListRepository _repository;//访问数据库
[ActivatorUtilitiesConstructor]
public Sys_DictionaryListService(
ISys_DictionaryListRepository dbRepository,
IHttpContextAccessor httpContextAccessor
)
: base(dbRepository)
{
_httpContextAccessor = httpContextAccessor;
_repository = dbRepository;
}
public override PageGridData<Sys_DictionaryList> GetPageData(PageDataOptions pageData)
{
base.OrderByExpression = x => new Dictionary<object, QueryOrderBy>() { {
x.OrderNo,QueryOrderBy.Desc
},
{
x.DicList_ID,QueryOrderBy.Asc
}
};
return base.GetPageData(pageData);
}
}
}

View File

@@ -0,0 +1,312 @@
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.DependencyInjection;
using SqlSugar;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using VolPro.Core.BaseProvider;
using VolPro.Core.Const;
using VolPro.Core.DBManager;
using VolPro.Core.DbSqlSugar;
using VolPro.Core.Enums;
using VolPro.Core.Extensions;
using VolPro.Core.Infrastructure;
using VolPro.Core.Utilities;
using VolPro.Entity.DomainModels;
using VolPro.Sys.IRepositories;
namespace VolPro.Sys.Services
{
public partial class Sys_DictionaryService
{
private readonly IHttpContextAccessor _httpContextAccessor;
private readonly ISys_DictionaryRepository _repository;//访问数据库
[ActivatorUtilitiesConstructor]
public Sys_DictionaryService(
ISys_DictionaryRepository dbRepository,
IHttpContextAccessor httpContextAccessor
)
: base(dbRepository)
{
_httpContextAccessor = httpContextAccessor;
_repository = dbRepository;
}
protected override void Init(IRepository<Sys_Dictionary> repository)
{
}
/// <summary>
/// 代码生成器获取所有字典项编号(超级管理权限)
/// </summary>
/// <returns></returns>
public async Task<List<string>> GetBuilderDictionary()
{
return await repository.FindAsync(x => 1 == 1, s => s.DicNo);
}
public List<Sys_Dictionary> Dictionaries
{
get { return DictionaryManager.Dictionaries; }
}
public object GetVueDictionary(string[] dicNos)
{
if (dicNos == null || dicNos.Count() == 0) return new string[] { };
var dicConfig = DictionaryManager.GetDictionaries(dicNos, false).Select(s => new
{
dicNo = s.DicNo,
config = s.Config,
dbSql = s.DbSql,
s.DBServer,
list = s.Sys_DictionaryList.OrderByDescending(o => o.OrderNo)
.Select(list => new { key = list.DicValue, value = list.DicName })
}).ToList();
object GetSourceData(string dicNo, string dbSql, object data,string DBServer)
{
// 2020.05.01增加根据用户信息加载字典数据源sql
dbSql = DictionaryHandler.GetCustomDBSql(dicNo, dbSql);
if (string.IsNullOrEmpty(dbSql))
{
return data as object;
}
return DbManger.GetConnection(DBServer).QueryList<object>(dbSql, null);
}
return dicConfig.Select(item => new
{
item.dicNo,
item.config,
data = GetSourceData(item.dicNo, item.dbSql, item.list,item.DBServer)
}).ToList();
}
/// <summary>
/// 通过远程搜索
/// </summary>
/// <param name="dicNo"></param>
/// <param name="value"></param>
/// <returns></returns>
public object GetSearchDictionary(string dicNo, string value)
{
if (string.IsNullOrEmpty(dicNo) || string.IsNullOrEmpty(value))
{
return null;
}
// 2020.05.01增加根据用户信息加载字典数据源sql
string sql = Dictionaries.Where(x => x.DicNo == dicNo).FirstOrDefault()?.DbSql;
sql = DictionaryHandler.GetCustomDBSql(dicNo, sql);
if (string.IsNullOrEmpty(sql))
{
return null;
}
sql = $"SELECT * FROM ({sql}) AS t WHERE value LIKE @value";
return repository.SqlSugarClient.Ado.SqlQuery<object>(sql, new { value = "%" + value + "%" });
}
/// <summary>
/// 表单设置为远程查询重置或第一次添加表单时获取字典的key、value
/// </summary>
/// <param name="dicNo"></param>
/// <param name="value"></param>
/// <returns></returns>
public async Task<object> GetRemoteDefaultKeyValue(string dicNo, string key)
{
return await Task.FromResult(1);
//if (string.IsNullOrEmpty(dicNo) || string.IsNullOrEmpty(key))
//{
// return null;
//}
//string sql = Dictionaries.Where(x => x.DicNo == dicNo).FirstOrDefault()?.DbSql;
//if (string.IsNullOrEmpty(sql))
//{
// return null;
//}
//sql = $"SELECT * FROM ({sql}) AS t WHERE t.key = @key";
//return await Task.FromResult(repository.DapperContext.QueryFirst<object>(sql, new { key }));
}
/// <summary>
/// table加载数据后刷新当前table数据的字典项(适用字典数据量比较大的情况)
/// </summary>
/// <param name="keyData"></param>
/// <returns></returns>
public object GetTableDictionary(Dictionary<string, object[]> keyData)
{
// 2020.08.06增加pgsql获取数据源
if (DBType.Name == DbCurrentType.PgSql.ToString())
{
return GetPgSqlTableDictionary(keyData);
}
var dicInfo = Dictionaries.Where(x => keyData.ContainsKey(x.DicNo) && !string.IsNullOrEmpty(x.DbSql))
.Select(x => new { x.DicNo, x.DbSql })
.ToList();
List<object> list = new List<object>();
string keySql = DBType.Name == DbCurrentType.MySql.ToString() ? "t.key" : "t.[key]";
dicInfo.ForEach(x =>
{
if (keyData.TryGetValue(x.DicNo, out object[] data))
{
// 2020.05.01增加根据用户信息加载字典数据源sql
string sql = DictionaryHandler.GetCustomDBSql(x.DicNo, x.DbSql);
sql = $"SELECT * FROM ({sql}) AS t WHERE " +
$"{keySql}" +
$" in @data";
list.Add(new { key = x.DicNo, data = repository.SqlSugarClient.Ado.SqlQuery<object>(sql, new { data }) });
}
});
return list;
}
/// <summary>
/// 2020.08.06增加pgsql获取数据源
/// </summary>
/// <param name="keyData"></param>
/// <returns></returns>
public object GetPgSqlTableDictionary(Dictionary<string, object[]> keyData)
{
var dicInfo = Dictionaries.Where(x => keyData.ContainsKey(x.DicNo) && !string.IsNullOrEmpty(x.DbSql))
.Select(x => new { x.DicNo, x.DbSql })
.ToList();
List<object> list = new List<object>();
dicInfo.ForEach(x =>
{
if (keyData.TryGetValue(x.DicNo, out object[] data))
{
string sql = DictionaryHandler.GetCustomDBSql(x.DicNo, x.DbSql);
sql = $"SELECT * FROM ({sql}) AS t WHERE t.key=any(@data)";
list.Add(new { key = x.DicNo, data = repository.SqlSugarClient.QueryList<object>(sql, new { data = data.Select(s => s.ToString()).ToList() }) });
}
});
return list;
}
public override PageGridData<Sys_Dictionary> GetPageData(PageDataOptions pageData)
{
//增加查询条件
base.QueryRelativeExpression = (ISugarQueryable<Sys_Dictionary> fun) =>
{
return fun.Where(x => 1 == 1);
};
return base.GetPageData(pageData);
}
public override WebResponseContent Update(SaveModel saveDataModel)
{
if (saveDataModel.MainData.DicKeyIsNullOrEmpty("DicNo")
|| saveDataModel.MainData.DicKeyIsNullOrEmpty("Dic_ID"))
return base.Add(saveDataModel);
//判断修改的字典编号是否在其他ID存在
string dicNo = saveDataModel.MainData["DicNo"].ToString().Trim();
if (base.repository.Exists(x => x.DicNo == dicNo && x.Dic_ID != saveDataModel.MainData["Dic_ID"].GetInt()))
return new WebResponseContent().Error($"字典编号:{ dicNo}已存在。!");
base.UpdateOnExecuting = (Sys_Dictionary dictionary, object addList, object editList, List<object> obj) =>
{
List<Sys_DictionaryList> listObj = new List<Sys_DictionaryList>();
if (addList!=null)
{
listObj.AddRange(addList as List<Sys_DictionaryList>);
}
if (editList != null)
{
listObj.AddRange(editList as List<Sys_DictionaryList>);
}
WebResponseContent _responseData = CheckKeyValue(listObj);
if (!_responseData.Status) return _responseData;
dictionary.DbSql = SqlFilters(dictionary.DbSql);
return new WebResponseContent(true);
};
return RemoveCache(base.Update(saveDataModel));
}
private WebResponseContent CheckKeyValue(List<Sys_DictionaryList> dictionaryLists)
{
WebResponseContent webResponse = new WebResponseContent();
if (dictionaryLists == null || dictionaryLists.Count == 0) return webResponse.OK();
if (dictionaryLists.GroupBy(g => g.DicName).Any(x => x.Count() > 1))
return webResponse.Error("【字典项名称】不能有重复的值");
if (dictionaryLists.GroupBy(g => g.DicValue).Any(x => x.Count() > 1))
return webResponse.Error("【字典项Key】不能有重复的值");
return webResponse.OK();
}
private static string SqlFilters(string source)
{
if (string.IsNullOrEmpty(source)) return source;
// source = source.Replace("'", "''");
source = Regex.Replace(source, " -", "", RegexOptions.IgnoreCase);
//去除执行SQL语句的命令关键字
source = Regex.Replace(source, " insert", "", RegexOptions.IgnoreCase);
// source = Regex.Replace(source, "sys.", "", RegexOptions.IgnoreCase);
source = Regex.Replace(source, " update", "", RegexOptions.IgnoreCase);
source = Regex.Replace(source, " delete ", "", RegexOptions.IgnoreCase);
source = Regex.Replace(source, " drop ", "", RegexOptions.IgnoreCase);
source = Regex.Replace(source, " truncate ", "", RegexOptions.IgnoreCase);
source = Regex.Replace(source, " declare ", "", RegexOptions.IgnoreCase);
source = Regex.Replace(source, " xp_cmdshell ", "", RegexOptions.IgnoreCase);
source = Regex.Replace(source, "/add", "", RegexOptions.IgnoreCase);
source = Regex.Replace(source, "net user", "", RegexOptions.IgnoreCase);
//去除执行存储过程的命令关键字
source = Regex.Replace(source, " exec ", "", RegexOptions.IgnoreCase);
source = Regex.Replace(source, " execute ", "", RegexOptions.IgnoreCase);
//去除系统存储过程或扩展存储过程关键字
source = Regex.Replace(source, " xp_ ", "x p_", RegexOptions.IgnoreCase);
source = Regex.Replace(source, " sp_ ", "s p_", RegexOptions.IgnoreCase);
//防止16进制注入
source = Regex.Replace(source, "0x", "0 x", RegexOptions.IgnoreCase);
return source;
}
public override WebResponseContent Add(SaveModel saveDataModel)
{
if (saveDataModel.MainData.DicKeyIsNullOrEmpty("DicNo")) return base.Add(saveDataModel);
string dicNo = saveDataModel.MainData["DicNo"].ToString();
if (base.repository.Exists(x => x.DicNo == dicNo))
return new WebResponseContent().Error("字典编号:" + dicNo + "已存在");
base.AddOnExecuting = (Sys_Dictionary dic, object obj) =>
{
WebResponseContent _responseData = CheckKeyValue(obj as List<Sys_DictionaryList>);
if (!_responseData.Status) return _responseData;
dic.DbSql = SqlFilters(dic.DbSql);
return new WebResponseContent(true);
};
return RemoveCache(base.Add(saveDataModel));
}
public override WebResponseContent Del(object[] keys, bool delList = false)
{
//delKeys删除的key
base.DelOnExecuting = (object[] delKeys) =>
{
return new WebResponseContent(true);
};
//true将子表数据同时删除
return RemoveCache(base.Del(keys, true));
}
private WebResponseContent RemoveCache(WebResponseContent webResponse)
{
if (webResponse.Status)
{
CacheContext.Remove(DictionaryManager.Key);
}
return webResponse;
}
}
}

View File

@@ -0,0 +1,331 @@
using Microsoft.AspNetCore.Http;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.DependencyInjection;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using VolPro.Core.DbSqlSugar;
using VolPro.Core.Extensions;
using VolPro.Core.ManageUser;
using VolPro.Core.Services;
using VolPro.Core.Utilities;
using VolPro.Entity;
using VolPro.Entity.DomainModels;
using VolPro.Sys.IRepositories;
namespace VolPro.Sys.Services
{
public partial class Sys_MenuService
{
private readonly IHttpContextAccessor _httpContextAccessor;
private readonly ISys_MenuRepository _repository;//访问数据库
[ActivatorUtilitiesConstructor]
public Sys_MenuService(
ISys_MenuRepository dbRepository,
IHttpContextAccessor httpContextAccessor
)
: base(dbRepository)
{
_httpContextAccessor = httpContextAccessor;
_repository = dbRepository;
}
/// <summary>
/// 菜单静态化处理每次获取菜单时先比较菜单是否发生变化如果发生变化从数据库重新获取否则直接获取_menus菜单
/// </summary>
private static List<Sys_Menu> _menus { get; set; }
/// <summary>
/// 从数据库获取菜单时锁定的对象
/// </summary>
private static object _menuObj = new object();
/// <summary>
/// 当前服务器的菜单版本
/// </summary>
private static string _menuVersionn = "";
private const string _menuCacheKey = "inernalMenu";
/// <summary>
/// 编辑修改菜单时,获取所有菜单
/// </summary>
/// <returns></returns>
public async Task<object> GetMenu()
{
// DBServerProvider.SqlDapper.q
return await repository.FindAsIQueryable(x => true)
.OrderByDescending(a => a.OrderNo)
.ThenByDescending(q => q.ParentId)
.Select(a =>
new
{
id = a.Menu_Id,
parentId = a.ParentId,
name = a.MenuName,
a.Icon,
a.MenuType,
a.OrderNo
}).ToListAsync();
}
private List<Sys_Menu> GetAllMenu()
{
//每次比较缓存是否更新过,如果更新则重新获取数据
string _cacheVersion = CacheContext.Get(_menuCacheKey);
if (_menuVersionn != "" && _menuVersionn == _cacheVersion)
{
return _menus ?? new List<Sys_Menu>();
}
lock (_menuObj)
{
if (_menuVersionn != "" && _menus != null && _menuVersionn == _cacheVersion) return _menus;
//2020.12.27增加菜单界面上不显示,但可以分配权限
_menus = repository.FindAsIQueryable(x => x.Enable == 1 || x.Enable == 2)
.OrderByDescending(a => a.OrderNo)
.ThenByDescending(q => q.ParentId).ToList();
_menus.ForEach(x =>
{
// 2022.03.26增移动端加菜单类型
x.MenuType ??= 0;
if (!string.IsNullOrEmpty(x.Auth) && x.Auth.Length > 10)
{
try
{
x.Actions = x.Auth.DeserializeObject<List<Sys_Actions>>();
}
catch { }
}
if (x.Actions == null) x.Actions = new List<Sys_Actions>();
});
string cacheVersion = CacheContext.Get(_menuCacheKey);
if (string.IsNullOrEmpty(cacheVersion))
{
cacheVersion = DateTime.Now.ToString("yyyyMMddHHMMssfff");
CacheContext.Add(_menuCacheKey, cacheVersion);
}
else
{
_menuVersionn = cacheVersion;
}
}
return _menus;
}
/// <summary>
/// 获取当前用户有权限查看的菜单
/// </summary>
/// <returns></returns>
public List<Sys_Menu> GetCurrentMenuList()
{
var roleIds = UserContext.Current.RoleIds;
return GetUserMenuList(roleIds);
}
public List<Sys_Menu> GetUserMenuList(int[] roleId)
{
if (UserContext.IsRoleIdSuperAdmin(roleId))
{
return GetAllMenu();
}
List<int> menuIds = UserContext.Current.GetPermissions(roleId).Select(x => x.Menu_Id).ToList();
return GetAllMenu().Where(x => menuIds.Contains(x.Menu_Id)).ToList();
}
/// <summary>
/// 获取当前用户所有菜单与权限
/// </summary>
/// <returns></returns>
public async Task<object> GetCurrentMenuActionList()
{
return await GetMenuActionList(UserContext.Current.RoleIds);
}
/// <summary>
/// 根据角色ID获取菜单与权限
/// </summary>
/// <param name="roleIds"></param>
/// <returns></returns>
public async Task<object> GetMenuActionList(int[] roleIds)
{
//2020.12.27增加菜单界面上不显示,但可以分配权限
if (UserContext.IsRoleIdSuperAdmin(roleIds))
{
return await Task.Run(() => GetAllMenu()
.Where(c => c.MenuType == UserContext.MenuType)
.Select(x =>
new
{
id = x.Menu_Id,
name = x.MenuName,
url = x.Url,
parentId = x.ParentId,
icon = x.Icon,
x.Enable,
x.LinkType,
x.TableName, // 2022.03.26增移动端加菜单类型
permission = x.Actions.Select(s => s.Value).ToArray()
}).ToList());
}
var menu = from a in UserContext.Current.Permissions
join b in GetAllMenu().Where(c => c.MenuType == UserContext.MenuType)
on a.Menu_Id equals b.Menu_Id
orderby b.OrderNo descending
select new
{
id = a.Menu_Id,
name = b.MenuName,
url = b.Url,
parentId = b.ParentId,
icon = b.Icon,
b.Enable,
b.LinkType,
b.TableName, // 2022.03.26增移动端加菜单类型
permission = a.UserAuthArr
};
return menu.ToList();
}
/// <summary>
/// 新建或编辑菜单
/// </summary>
/// <param name="menu"></param>
/// <returns></returns>
public async Task<WebResponseContent> Save(Sys_Menu menu)
{
WebResponseContent webResponse = new WebResponseContent();
if (menu == null) return webResponse.Error("没有获取到提交的参数");
if (menu.Menu_Id > 0 && menu.Menu_Id == menu.ParentId) return webResponse.Error("父级ID不能是当前菜单的ID");
try
{
webResponse = menu.ValidationEntity(x => new { x.MenuName, x.TableName });
if (!webResponse.Status) return webResponse;
if (menu.TableName != "/" && menu.TableName != ".")
{
// 2022.03.26增移动端加菜单类型判断
Sys_Menu sysMenu = await repository.FindAsyncFirst(x => x.TableName == menu.TableName);
if (sysMenu != null)
{
sysMenu.MenuType ??= 0;
if (sysMenu.MenuType == menu.MenuType)
{
if ((menu.Menu_Id > 0 && sysMenu.Menu_Id != menu.Menu_Id)
|| menu.Menu_Id <= 0)
{
return webResponse.Error($"视图/表名【{menu.TableName}】已被其他菜单使用");
}
}
}
}
bool _changed = false;
if (menu.Menu_Id <= 0)
{
repository.AddWithSetIdentity(menu.SetCreateDefaultVal());
}
else
{
//2020.05.07新增禁止选择上级角色为自己
if (menu.Menu_Id == menu.ParentId)
{
return webResponse.Error($"父级id不能为自己");
}
if (repository.Exists(x => x.ParentId == menu.Menu_Id && menu.ParentId == x.Menu_Id))
{
return webResponse.Error($"不能选择此父级id选择的父级id与当前菜单形成依赖关系");
}
_changed = repository.FindAsIQueryable(c => c.Menu_Id == menu.Menu_Id).Select(s => s.Auth).FirstOrDefault() != menu.Auth;
repository.Update(menu.SetModifyDefaultVal(), p => new
{
p.ParentId,
p.MenuName,
p.Url,
p.Auth,
p.OrderNo,
p.Icon,
p.AuthData,
p.LinkType,
p.Enable,
p.MenuType,// 2022.03.26增移动端加菜单类型
p.TableName,
p.ModifyDate,
p.Modifier
});
}
await repository.SaveChangesAsync();
CacheContext.Add(_menuCacheKey, DateTime.Now.ToString("yyyyMMddHHMMssfff"));
if (_changed)
{
UserContext.Current.RefreshWithMenuActionChange(menu.Menu_Id);
}
_menus = null;
webResponse.OK("保存成功", menu);
}
catch (Exception ex)
{
webResponse.Error(ex.Message);
}
finally
{
Logger.Info($"表:{menu.TableName},菜单:{menu.MenuName},权限{menu.Auth},{(webResponse.Status ? "" : "")}{webResponse.Message}");
}
return webResponse;
}
public async Task<WebResponseContent> DelMenu(int menuId)
{
WebResponseContent webResponse = new WebResponseContent();
if (await repository.ExistsAsync(x => x.ParentId == menuId))
{
return webResponse.Error("当前菜单存在子菜单,请先删除子菜单!");
}
repository.Delete(new Sys_Menu()
{
Menu_Id = menuId
}, true);
CacheContext.Add(_menuCacheKey, DateTime.Now.ToString("yyyyMMddHHMMssfff"));
return webResponse.OK("删除成功");
}
/// <summary>
/// 编辑菜单时,获取菜单信息
/// </summary>
/// <param name="menuId"></param>
/// <returns></returns>
public async Task<object> GetTreeItem(int menuId)
{
var sysMenu = (await base.repository.FindAsync(x => x.Menu_Id == menuId))
.Select(
p => new
{
p.Menu_Id,
p.ParentId,
p.MenuName,
p.Url,
p.Auth,
p.OrderNo,
p.Icon,
p.AuthData,
p.LinkType,
p.Enable,
// 2022.03.26增移动端加菜单类型
MenuType = p.MenuType ?? 0,
p.CreateDate,
p.Creator,
p.TableName,
p.ModifyDate
}).FirstOrDefault();
return sysMenu;
}
}
}

View File

@@ -0,0 +1,98 @@
/*
*所有关于Sys_Post类的业务代码应在此处编写
*可使用repository.调用常用方法获取EF/Dapper等信息
*如果需要事务请使用repository.DbContextBeginTransaction
*也可使用DBServerProvider.手动获取数据库相关信息
*用户信息、权限、角色等使用UserContext.Current操作
*Sys_PostService对增、删、改查、导入、导出、审核业务代码扩展参照ServiceFunFilter
*/
using VolPro.Core.BaseProvider;
using VolPro.Core.Extensions.AutofacManager;
using VolPro.Entity.DomainModels;
using System.Linq;
using VolPro.Core.Utilities;
using System.Linq.Expressions;
using VolPro.Core.Extensions;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.AspNetCore.Http;
using VolPro.Sys.IRepositories;
using VolPro.Core.ManageUser;
using System.Collections.Generic;
using VolPro.Core.UserManager;
using VolPro.Core.Configuration;
using VolPro.Core.Tenancy;
using SqlSugar;
namespace VolPro.Sys.Services
{
public partial class Sys_PostService
{
private readonly IHttpContextAccessor _httpContextAccessor;
private readonly ISys_PostRepository _repository;//访问数据库
[ActivatorUtilitiesConstructor]
public Sys_PostService(
ISys_PostRepository dbRepository,
IHttpContextAccessor httpContextAccessor
)
: base(dbRepository)
{
_httpContextAccessor = httpContextAccessor;
_repository = dbRepository;
IsMultiTenancy = false;
//多租户会用到这init代码其他情况可以不用
//base.Init(dbRepository);
}
public override PageGridData<Sys_Post> GetPageData(PageDataOptions options)
{
FilterData();
return base.GetPageData(options);
}
public override WebResponseContent Export(PageDataOptions pageData)
{
FilterData();
return base.Export(pageData);
}
private void FilterData()
{
QueryRelativeExpression = (ISugarQueryable<Sys_Post> queryable) =>
{
if (AppSetting.UseDynamicShareDB)
{
return queryable.Where(x => x.DbServiceId == UserContext.CurrentServiceId);
}
return queryable.FilterTenancy();
};
}
WebResponseContent webResponse = new WebResponseContent();
public override WebResponseContent Add(SaveModel saveDataModel)
{
AddOnExecuting = (Sys_Post post, object list) =>
{
post.DbServiceId = UserContext.CurrentServiceId;
return webResponse.OK();
};
return base.Add(saveDataModel);
}
public override WebResponseContent Update(SaveModel saveModel)
{
UpdateOnExecuting = (Sys_Post post, object addList, object updateList, List<object> delKeys) =>
{
if (post.ParentId == post.PostId)
{
return webResponse.Error("上级岗位不能选择自己");
}
if (_repository.Exists(x => x.PostId == post.ParentId && x.ParentId == post.PostId))
{
return webResponse.Error("不能选择此上级岗位");
}
return webResponse.OK();
};
return base.Update(saveModel).Reload();
}
}
}

View File

@@ -0,0 +1,68 @@
/*
*所有关于Sys_PrintOptions类的业务代码应在此处编写
*可使用repository.调用常用方法获取EF/Dapper等信息
*如果需要事务请使用repository.DbContextBeginTransaction
*也可使用DBServerProvider.手动获取数据库相关信息
*用户信息、权限、角色等使用UserContext.Current操作
*Sys_PrintOptionsService对增、删、改查、导入、导出、审核业务代码扩展参照ServiceFunFilter
*/
using VolPro.Core.BaseProvider;
using VolPro.Core.Extensions.AutofacManager;
using VolPro.Entity.DomainModels;
using System.Linq;
using VolPro.Core.Utilities;
using System.Linq.Expressions;
using VolPro.Core.Extensions;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.AspNetCore.Http;
using VolPro.Sys.IRepositories;
using VolPro.Core.ManageUser;
using VolPro.Core.Configuration;
using SqlSugar;
namespace VolPro.Sys.Services
{
public partial class Sys_PrintOptionsService
{
private readonly IHttpContextAccessor _httpContextAccessor;
private readonly ISys_PrintOptionsRepository _repository;//访问数据库
[ActivatorUtilitiesConstructor]
public Sys_PrintOptionsService(
ISys_PrintOptionsRepository dbRepository,
IHttpContextAccessor httpContextAccessor
)
: base(dbRepository)
{
_httpContextAccessor = httpContextAccessor;
_repository = dbRepository;
//多租户会用到这init代码其他情况可以不用
//base.Init(dbRepository);
}
WebResponseContent webResponse = new WebResponseContent();
public override WebResponseContent Add(SaveModel saveDataModel)
{
AddOnExecuting = (Sys_PrintOptions print, object list) => {
print.DbService = UserContext.CurrentServiceId;
print.DbServiceId = UserContext.CurrentServiceId;
return webResponse.OK();
};
return base.Add(saveDataModel);
}
public override PageGridData<Sys_PrintOptions> GetPageData(PageDataOptions options)
{
QueryRelativeExpression = (ISugarQueryable<Sys_PrintOptions> query) =>
{
if (AppSetting.UseDynamicShareDB || !string.IsNullOrEmpty(AppSetting.TenancyField))
{
query = query.Where(x => x.DbServiceId == UserContext.CurrentServiceId);
}
return query;
};
return base.GetPageData(options);
}
}
}

View File

@@ -0,0 +1,41 @@
/*
*所有关于Sys_Region类的业务代码应在此处编写
*可使用repository.调用常用方法获取EF/Dapper等信息
*如果需要事务请使用repository.DbContextBeginTransaction
*也可使用DBServerProvider.手动获取数据库相关信息
*用户信息、权限、角色等使用UserContext.Current操作
*Sys_RegionService对增、删、改查、导入、导出、审核业务代码扩展参照ServiceFunFilter
*/
using VolPro.Core.BaseProvider;
using VolPro.Core.Extensions.AutofacManager;
using VolPro.Entity.DomainModels;
using System.Linq;
using VolPro.Core.Utilities;
using System.Linq.Expressions;
using VolPro.Core.Extensions;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.AspNetCore.Http;
using VolPro.Sys.IRepositories;
namespace VolPro.Sys.Services
{
public partial class Sys_RegionService
{
private readonly IHttpContextAccessor _httpContextAccessor;
private readonly ISys_RegionRepository _repository;//访问数据库
[ActivatorUtilitiesConstructor]
public Sys_RegionService(
ISys_RegionRepository dbRepository,
IHttpContextAccessor httpContextAccessor
)
: base(dbRepository)
{
_httpContextAccessor = httpContextAccessor;
_repository = dbRepository;
//多租户会用到这init代码其他情况可以不用
//base.Init(dbRepository);
}
}
}

View File

@@ -0,0 +1,60 @@
/*
*所有关于Sys_ReportOptions类的业务代码应在此处编写
*可使用repository.调用常用方法获取EF/Dapper等信息
*如果需要事务请使用repository.DbContextBeginTransaction
*也可使用DBServerProvider.手动获取数据库相关信息
*用户信息、权限、角色等使用UserContext.Current操作
*Sys_ReportOptionsService对增、删、改查、导入、导出、审核业务代码扩展参照ServiceFunFilter
*/
using VolPro.Core.BaseProvider;
using VolPro.Core.Extensions.AutofacManager;
using VolPro.Entity.DomainModels;
using System.Linq;
using VolPro.Core.Utilities;
using System.Linq.Expressions;
using VolPro.Core.Extensions;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.AspNetCore.Http;
using VolPro.Sys.IRepositories;
using System.Collections.Generic;
namespace VolPro.Sys.Services
{
public partial class Sys_ReportOptionsService
{
private readonly IHttpContextAccessor _httpContextAccessor;
private readonly ISys_ReportOptionsRepository _repository;//访问数据库
[ActivatorUtilitiesConstructor]
public Sys_ReportOptionsService(
ISys_ReportOptionsRepository dbRepository,
IHttpContextAccessor httpContextAccessor
)
: base(dbRepository)
{
_httpContextAccessor = httpContextAccessor;
_repository = dbRepository;
//多租户会用到这init代码其他情况可以不用
//base.Init(dbRepository);
}
public override WebResponseContent Add(SaveModel saveDataModel)
{
saveDataModel.MainData["ReportCode"] = new IdWorker().NextId().ToString();
return base.Add(saveDataModel);
}
WebResponseContent webResponse = new WebResponseContent();
public override WebResponseContent Upload(List<IFormFile> files)
{
if (!files.Any(x=>x.FileName.ToLower().EndsWith(".grf")))
{
return webResponse.Error("只能上传grf格式文件");
}
IsRoot = false;
UploadFolder = "ReportTemplate/";
return base.Upload(files);
}
}
}

View File

@@ -0,0 +1,410 @@
using Microsoft.AspNetCore.Http;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.DependencyInjection;
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Threading.Tasks;
using VolPro.Core;
using VolPro.Core.Extensions;
using VolPro.Core.ManageUser;
using VolPro.Core.Services;
using VolPro.Core.UserManager;
using VolPro.Core.Utilities;
using VolPro.Entity;
using VolPro.Entity.DomainModels;
using VolPro.Sys.IRepositories;
namespace VolPro.Sys.Services
{
public partial class Sys_RoleService
{
private readonly IHttpContextAccessor _httpContextAccessor;
private readonly ISys_RoleRepository _repository;//访问数据库
[ActivatorUtilitiesConstructor]
public Sys_RoleService(
ISys_RoleRepository dbRepository,
IHttpContextAccessor httpContextAccessor
)
: base(dbRepository)
{
_httpContextAccessor = httpContextAccessor;
_repository = dbRepository;
}
private WebResponseContent _responseContent = new WebResponseContent();
public override PageGridData<Sys_Role> GetPageData(PageDataOptions pageData)
{
//角色Id=1默认为超级管理员角色界面上不显示此角色
QueryRelativeExpression = (ISugarQueryable<Sys_Role> queryable) =>
{
if (UserContext.Current.IsSuperAdmin)
{
IsMultiTenancy = false;
return queryable;
}
List<int> roleIds = GetAllChildrenRoleIdAndSelf();
return queryable.Where(x => roleIds.Contains(x.Role_Id));
};
return base.GetPageData(pageData);
}
/// <summary>
/// 编辑权限时,获取当前用户的所有菜单权限
/// </summary>
/// <returns></returns>
public async Task<WebResponseContent> GetCurrentUserTreePermission()
{
return await GetUserTreePermission(UserContext.Current.RoleIds);
}
/// <summary>
/// 编辑权限时,获取指定角色的所有菜单权限
/// </summary>
/// <param name="roleIds"></param>
/// <returns></returns>
public async Task<WebResponseContent> GetUserTreePermission(int[] roleIds)
{
WebResponseContent webResponse = new WebResponseContent();
//if (!UserContext.IsRoleIdSuperAdmin(roleId) && !UserContext.Current.RoleId.Contains( roleId))
//{
// //if (!(await GetAllChildrenAsync(UserContext.Current.RoleId)).Exists(x => x.Id == roleId))
// //{
// // return webResponse.Error("没有权限获取此角色的权限信息");
// //}
//}
//获取用户权限
List<Permissions> permissions = UserContext.Current.GetPermissions(roleIds);
//权限用户权限查询所有的菜单信息
List<Sys_Menu> menus = await Task.Run(() => Sys_MenuService.Instance.GetUserMenuList(roleIds));
//获取当前用户权限如:(Add,Search)对应的显示文本信息如:Add添加Search:查询
var data = menus.Select(x => new UserPermissions
{
Id = x.Menu_Id,
Pid = x.ParentId,
Text = x.MenuName,
IsApp = x.MenuType == 1,
Actions = GetActions(x.Menu_Id, x.Actions, permissions, roleIds),
AuthMenuData = permissions.Where(c => c.Menu_Id == x.Menu_Id).Select(s => s.AuthMenuData).FirstOrDefault()
});
return webResponse.OK(null, data);
}
private List<Sys_Actions> GetActions(int menuId, List<Sys_Actions> menuActions, List<Permissions> permissions, int[] roleIds)
{
if (UserContext.IsRoleIdSuperAdmin(roleIds))
{
return menuActions;
}
return menuActions.Where(p => permissions
.Exists(w => menuId == w.Menu_Id
&& w.UserAuthArr.Contains(p.Value)))
.ToList();
}
private List<RoleNodes> rolesChildren = new List<RoleNodes>();
/// <summary>
/// 编辑权限时获取当前用户下的所有角色与当前用户的菜单权限
/// </summary>
/// <returns></returns>
public async Task<WebResponseContent> GetCurrentTreePermission()
{
_responseContent = await GetCurrentUserTreePermission();
var roleIds = UserContext.Current.RoleIds;
return _responseContent.OK(null, new
{
tree = _responseContent.Data,
roles = await GetAllChildrenAsync(roleIds)
});
}
private List<RoleNodes> roles = null;
/// <summary>
/// 获取当前角色下的所有角色包括自己的角色Id
/// </summary>
/// <returns></returns>
public List<int> GetAllChildrenRoleIdAndSelf()
{
var _roleIds = UserContext.Current.RoleIds;
List<int> roleIds = GetAllChildren(_roleIds).Select(x => x.Id).ToList();
roleIds.AddRange(_roleIds);
return roleIds;
}
/// <summary>
/// 获取当前角色下的所有角色
/// </summary>
/// <param name="roleId"></param>
/// <returns></returns>
public List<RoleNodes> GetAllChildren(int roleId)
{
roles = GetAllRoleQueryable().ToList();
return GetAllChildrenNodes(new int[] { roleId });
}
public List<RoleNodes> GetAllChildren(int[] roleIds)
{
roles = GetAllRoleQueryable().ToList();
return GetAllChildrenNodes(roleIds);
}
public async Task<List<RoleNodes>> GetAllChildrenAsync(int[] roleIds)
{
roles = await GetAllRoleQueryable().ToListAsync();
return GetAllChildrenNodes(roleIds);
}
private ISugarQueryable<RoleNodes> GetAllRoleQueryable()
{
return repository
.FindAsIQueryable(
x => x.Enable == 1 && x.Role_Id > 1)
.Select(
s => new RoleNodes()
{
Id = s.Role_Id,
ParentId = s.ParentId,
RoleName = s.RoleName
});
}
public async Task<List<int>> GetAllChildrenRoleIdAsync(int roleId)
{
return (await GetAllChildrenAsync(new int[] { roleId })).Select(x => x.Id).ToList();
}
public List<int> GetAllChildrenRoleId(int roleId)
{
return GetAllChildren(roleId).Select(x => x.Id).ToList();
}
public List<int> GetAllChildrenRoleId(int[] roleIds)
{
return GetAllChildrenNodes(roleIds).Select(x => x.Id).ToList();
}
private List<RoleNodes> GetAllChildrenNodes(int[] roleIds)
{
return RoleContext.GetAllChildren(roleIds);
}
/// <summary>
/// 保存角色权限
/// </summary>
/// <param name="userPermissions"></param>
/// <param name="roleId"></param>
/// <returns></returns>
public async Task<WebResponseContent> SavePermission(List<UserPermissions> userPermissions, int roleId)
{
string message = "";
try
{
UserInfo user = UserContext.Current.UserInfo;
if (!(await GetAllChildrenAsync(user.RoleIds)).Exists(x => x.Id == roleId))
return _responseContent.Error("没有权限修改此角色的权限信息");
//当前用户的权限
List<Permissions> permissions = UserContext.Current.Permissions;
List<int> originalMeunIds = new List<int>();
//被分配角色的权限
List<Sys_RoleAuth> roleAuths = await repository.FindAsync<Sys_RoleAuth>(x => x.Role_Id == roleId);
List<Sys_RoleAuth> updateAuths = new List<Sys_RoleAuth>();
foreach (UserPermissions x in userPermissions)
{
Permissions per = permissions.Where(p => p.Menu_Id == x.Id).FirstOrDefault();
//不能分配超过当前用户的权限
if (per == null) continue;
//per.UserAuthArr.Contains(a.Value)校验权限范围
string[] arr = x.Actions == null || x.Actions.Count == 0
? new string[0]
: x.Actions.Where(a => per.UserAuthArr.Contains(a.Value))
.Select(s => s.Value).ToArray();
//如果当前权限没有分配过设置Auth_Id默认为0表示新增的权限
var auth = roleAuths.Where(r => r.Menu_Id == x.Id).Select(s => new { s.Auth_Id, s.AuthValue, s.Menu_Id,s.AuthMenuData }).FirstOrDefault();
string newAuthValue = string.Join(",", arr);
//权限没有发生变化则不处理
if (auth == null || auth.AuthValue != newAuthValue || auth.AuthMenuData != x.AuthMenuData)
{
updateAuths.Add(new Sys_RoleAuth()
{
Role_Id = roleId,
Menu_Id = x.Id,
AuthValue = string.Join(",", arr),
AuthMenuData = x.AuthMenuData,
Auth_Id = auth == null ? 0 : auth.Auth_Id,
ModifyDate = DateTime.Now,
Modifier = user.UserTrueName,
CreateDate = DateTime.Now,
Creator = user.UserTrueName
});
}
else
{
originalMeunIds.Add(auth.Menu_Id);
}
}
//更新权限
repository.UpdateRange(updateAuths.Where(x => x.Auth_Id > 0), x => new
{
x.Menu_Id,
x.AuthValue,
x.AuthMenuData,
x.Modifier,
x.ModifyDate
});
//新增的权限
repository.AddRange(updateAuths.Where(x => x.Auth_Id <= 0).ToList());
//获取权限取消的权限
int[] authIds = roleAuths.Where(x => userPermissions.Select(u => u.Id)
.ToList().Contains(x.Menu_Id) || originalMeunIds.Contains(x.Menu_Id))
.Select(s => s.Auth_Id)
.ToArray();
List<Sys_RoleAuth> delAuths = roleAuths.Where(x => x.AuthValue != "" && !authIds.Contains(x.Auth_Id)).ToList();
delAuths.ForEach(x =>
{
x.AuthValue = "";
x.AuthMenuData = "";
});
//将取消的权限设置为""
repository.UpdateRange(delAuths, x => new
{
x.Menu_Id,
x.AuthValue,
x.AuthMenuData,
x.Modifier,
x.ModifyDate
});
int addCount = updateAuths.Where(x => x.Auth_Id <= 0).Count();
int updateCount = updateAuths.Where(x => x.Auth_Id > 0).Count();
await repository.SaveChangesAsync();
string _version = DateTime.Now.ToString("yyyyMMddHHMMssfff");
//标识缓存已更新
base.CacheContext.Add(roleId.GetRoleIdKey(), _version);
_responseContent.OK($"保存成功:新增加配菜单权限{addCount}条,更新菜单{updateCount}条,删除权限{delAuths.Count()}条");
}
catch (Exception ex)
{
message = "异常信息:" + ex.Message + ex.StackTrace +ex.InnerException+ ",";
Console.WriteLine(message);
}
finally
{
Logger.Info($"权限分配置:{message}{_responseContent.Message}");
}
return _responseContent;
}
public override WebResponseContent Add(SaveModel saveDataModel)
{
AddOnExecuting = (Sys_Role role, object obj) =>
{
if (!UserContext.Current.IsSuperAdmin && role.ParentId > 0 && !RoleContext.GetAllChildrenIds(UserContext.Current.RoleIds).Contains(role.ParentId))
{
return _responseContent.Error("不能添加此角色".Translator());
}
if (role.DbServiceId == null&&!UserContext.IsRoleIdSuperAdmin(role.Role_Id))
{
role.DbServiceId = UserContext.CurrentServiceId;
}
return ValidateRoleName(role, x => x.RoleName == role.RoleName);
};
return RemoveCache(base.Add(saveDataModel));
}
public override WebResponseContent Del(object[] keys, bool delList = true)
{
if (!UserContext.Current.IsSuperAdmin)
{
var roleIds = RoleContext.GetAllChildrenIds(UserContext.Current.RoleIds);
var _keys = keys.Select(s => s.GetInt());
if (_keys.Any(x => !roleIds.Contains(x)))
{
return _responseContent.Error("没有权限删除此角色");
}
}
return RemoveCache(base.Del(keys, delList));
}
private WebResponseContent ValidateRoleName(Sys_Role role, Expression<Func<Sys_Role, bool>> predicate)
{
//if (repository.Exists(predicate))
//{
// return _responseContent.Error("角色名【{$ts}】已存在,请设置其他角色名".TranslatorFormat(role.RoleName));
//}
return _responseContent.OK();
}
public override WebResponseContent Update(SaveModel saveModel)
{
UpdateOnExecuting = (Sys_Role role, object obj1, object obj2, List<object> obj3) =>
{
if (role.Role_Id==1)
{
role.ParentId = 0;
}
//2020.05.07新增禁止选择上级角色为自己
if (role.Role_Id == role.ParentId)
{
return _responseContent.Error($"上级角色不能选择自己".Translator());
}
if (repository.Exists(x => x.Role_Id == role.ParentId && x.ParentId == role.Role_Id))
{
return _responseContent.Error($"不能选择此上级角色,选择的上级角色与当前角色形成依赖关系".Translator());
}
if (!UserContext.Current.IsSuperAdmin)
{
var roleIds = RoleContext.GetAllChildrenIds(UserContext.Current.RoleIds);
if (role.ParentId > 0)
{
if (!roleIds.Contains(role.ParentId))
{
return _responseContent.Error($"不能选择此角色");
}
}
if (!roleIds.Contains(role.Role_Id))
{
return _responseContent.Error($"不能选择此角色");
}
return _responseContent.OK("");
}
return ValidateRoleName(role, x => x.RoleName == role.RoleName && x.Role_Id != role.Role_Id);
};
return RemoveCache(base.Update(saveModel));
}
private WebResponseContent RemoveCache(WebResponseContent webResponse)
{
if (webResponse.Status)
{
RoleContext.Refresh();
}
return webResponse;
}
}
public class UserPermissions
{
public int Id { get; set; }
public int Pid { get; set; }
public string Text { get; set; }
public bool IsApp { get; set; }
public List<Sys_Actions> Actions { get; set; }
/// <summary>
///菜单数据权限
/// </summary>
public string AuthMenuData { get; set; }
}
}

View File

@@ -0,0 +1,569 @@
using Microsoft.AspNetCore.Http;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Caching.Memory;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using VolPro.Core;
using VolPro.Core.Configuration;
using VolPro.Core.DbSqlSugar;
using VolPro.Core.Enums;
using VolPro.Core.Extensions;
using VolPro.Core.ManageUser;
using VolPro.Core.Services;
using VolPro.Core.UserManager;
using VolPro.Core.Utilities;
using VolPro.Entity.DomainModels;
using VolPro.Sys.IRepositories;
namespace VolPro.Sys.Services
{
public partial class Sys_UserService
{
private Microsoft.AspNetCore.Http.HttpContext _context;
private ISys_UserRepository _repository;
[ActivatorUtilitiesConstructor]
public Sys_UserService(IHttpContextAccessor httpContextAccessor, ISys_UserRepository repository)
: base(repository)
{
_context = httpContextAccessor.HttpContext;
_repository = repository;
}
WebResponseContent webResponse = new WebResponseContent();
public int GetUserNumber()
{
return _repository.Find(x => 1 == 1).Count;
}
public List<Sys_User> GetUserList()
{
return _repository.Find(x => 1 == 1).ToList<Sys_User>();
}
/// <summary>
/// WebApi登陆
/// </summary>
/// <param name="loginInfo"></param>
/// <param name="verificationCode"></param>
/// <returns></returns>
public async Task<WebResponseContent> Login(LoginInfo loginInfo, bool verificationCode = true)
{
WebResponseContent responseContent = new WebResponseContent();
string msg = string.Empty;
// 2020.06.12增加验证码
IMemoryCache memoryCache = _context.GetService<IMemoryCache>();
string cacheCode = (memoryCache.Get(loginInfo.UUID) ?? "").ToString();
if (string.IsNullOrEmpty(cacheCode))
{
return responseContent.Error("验证码已失效".Translator());
}
if (cacheCode.ToLower() != loginInfo.VerificationCode.ToLower())
{
memoryCache.Remove(loginInfo.UUID);
return responseContent.Error("验证码不正确".Translator());
}
try
{
Sys_User user = await repository.FindAsIQueryable(x => x.UserName == loginInfo.UserName)
.FirstOrDefaultAsync();
if (user == null || loginInfo.Password.Trim().EncryptDES(AppSetting.Secret.User) != (user.UserPwd ?? ""))
return webResponse.Error(ResponseType.LoginError);
int expir = UserContext.MenuType == 1 ? 43200 : AppSetting.ExpMinutes;
string token = JwtHelper.IssueJwt(new UserInfo()
{
User_Id = user.User_Id,
UserName = user.UserName,
Role_Id = user.Role_Id ?? 0
}, expir);
user.Token = token;
string accessToken = null;
if (AppSetting.FileAuth)
{
expir = expir + 30;
string dt = DateTime.Now.AddMinutes(expir).ToString("yyyy-MM-dd HH:mm");
accessToken = $"{user.User_Id}_{dt}".EncryptDES(AppSetting.Secret.User);
_context.GetService<Core.CacheManager.ICacheService>().Add(accessToken, dt, expir);
}
webResponse.Data = new { token, userName = user.UserTrueName, img = user.HeadImageUrl, accessToken };
repository.Update(user, x => x.Token, true);
UserContext.Current.LogOut(user.User_Id);
loginInfo.Password = string.Empty;
return webResponse.OK(ResponseType.LoginSuccess);
}
catch (Exception ex)
{
msg = ex.Message + ex.StackTrace;
if (_context.GetService<Microsoft.AspNetCore.Hosting.IWebHostEnvironment>().IsDevelopment())
{
throw new Exception(ex.Message + ex.StackTrace);
}
return webResponse.Error(ResponseType.ServerError);
}
finally
{
memoryCache.Remove(loginInfo.UUID);
Logger.Info(LoggerType.Login, loginInfo.Serialize(), webResponse.Message, msg);
}
}
/// <summary>
///当token将要过期时提前置换一个新的token
/// </summary>
/// <returns></returns>
public async Task<WebResponseContent> ReplaceToken()
{
await Task.CompletedTask;
return new WebResponseContent() { };
}
/// <summary>
/// 修改密码
/// </summary>
/// <param name="parameters"></param>
/// <returns></returns>
public async Task<WebResponseContent> ModifyPwd(string oldPwd, string newPwd)
{
oldPwd = oldPwd?.Trim();
newPwd = newPwd?.Trim();
string message = "";
WebResponseContent webResponse = new WebResponseContent();
try
{
if (string.IsNullOrEmpty(oldPwd)) return webResponse.Error("旧密码不能为空".Translator());
if (string.IsNullOrEmpty(newPwd)) return webResponse.Error("新密码不能为空".Translator());
if (newPwd.Length < 6) return webResponse.Error("密码不能少于6位".Translator());
int userId = UserContext.Current.UserId;
string userCurrentPwd = await base.repository.FindFirstAsync(x => x.User_Id == userId, s => s.UserPwd);
string _oldPwd = oldPwd.EncryptDES(AppSetting.Secret.User);
if (_oldPwd != userCurrentPwd) return webResponse.Error("旧密码不正确".Translator());
string _newPwd = newPwd.EncryptDES(AppSetting.Secret.User);
if (userCurrentPwd == _newPwd) return webResponse.Error("新密码不能与旧密码相同".Translator());
repository.Update(new Sys_User
{
User_Id = userId,
UserPwd = _newPwd,
LastModifyPwdDate = DateTime.Now
}, x => new { x.UserPwd, x.LastModifyPwdDate }, true);
webResponse.OK("密码修改成功".Translator());
}
catch (Exception ex)
{
message = ex.Message;
webResponse.Error("服务器处理出现异常".Translator());
}
finally
{
if (message == "")
{
Logger.OK(LoggerType.ApiModifyPwd, "密码修改成功".Translator());
}
else
{
Logger.Error(LoggerType.ApiModifyPwd, message);
}
}
return webResponse;
}
/// <summary>
/// 个人中心获取当前用户信息
/// </summary>
/// <returns></returns>
public async Task<WebResponseContent> GetCurrentUserInfo()
{
var data = await base.repository
.FindAsIQueryable(x => x.User_Id == UserContext.Current.UserId)
.Select(s => new
{
s.UserName,
s.UserTrueName,
// s.Address,
s.PhoneNo,
// s.Email,
s.Remark,
s.Gender,
// s.RoleName,
s.HeadImageUrl,
s.CreateDate
})
.FirstOrDefaultAsync();
return webResponse.OK(null, data);
}
/// <summary>
/// 设置固定排序方式及显示用户过滤
/// </summary>
/// <param name="pageData"></param>
/// <returns></returns>
public override PageGridData<Sys_User> GetPageData(PageDataOptions pageData)
{
////var roleId = new int[] {};
//////树形菜单传查询角色下所有用户
////if (pageData.Value != null)
////{
//// roleId = new int[] { pageData.Value.ToString().GetInt() };
////}
//QueryRelativeExpression = (ISugarQueryable<Sys_User> queryable) =>
//{
// //显示角色与子角色下的数据
// var serviceId = UserContext.CurrentServiceId;
// var roleIds = RoleContext.GetAllChildrenIds(UserContext.Current.RoleIds);
// var roleQuery = repository.DbContext.Set<Sys_UserRole>().Where(x => x.Enable == 1 && roleIds.Contains(x.RoleId));
// if (UserContext.Current.IsSuperAdmin)
// {
// return queryable;
// // return queryable.Where(x => x.User_Id == UserContext.Current.UserId || roleQuery.Any(c => c.RoleId == x.Role_Id));
// }
// return queryable.Where(x => roleQuery.Any(c => c.UserId == x.User_Id));
//};
//显示同一个数据库的用户
var data = base.GetPageData(pageData);
foreach (var item in data.rows)
{
item.Token = null;
}
return data;
}
/// <summary>
/// 新建用户,根据实际情况自行处理
/// </summary>
/// <param name="saveModel"></param>
/// <returns></returns>
public override WebResponseContent Add(SaveModel saveModel)
{
WebResponseContent responseData = new WebResponseContent();
base.AddOnExecute = (SaveModel userModel) =>
{
return responseData.OK();
};
///生成6位数随机密码
string pwd = 6.GenerateRandomNumber();
//在AddOnExecuting之前已经对提交的数据做过验证是否为空
base.AddOnExecuting = (Sys_User user, object obj) =>
{
user.UserName = user.UserName.Trim();
if (repository.Exists(x => x.UserName == user.UserName))
return responseData.Error("用户名已经被注册".Translator());
user.UserPwd = pwd.EncryptDES(AppSetting.Secret.User);
//设置默认头像
return responseData.OK();
};
base.AddOnExecuted = (Sys_User user, object list) =>
{
var roleIds = user.RoleIds?.Split(",").Select(s => s.GetInt()).Where(x => x > 1).ToArray();
SaveRole(roleIds, user.User_Id);
var deptIds = user.DeptIds?.Split(",").Select(s => s.GetGuid()).Where(x => x != null).Select(s => (Guid)s).ToArray();
SaveDepartment(deptIds, user.User_Id);
var postIds = user.PostId?.Split(",").Select(s => s.GetGuid()).Where(x => x != null).Select(s => (Guid)s).ToArray();
SavePost(postIds, user.User_Id);
return responseData.OK("用户新建成功.帐号{$ts}密码{$ts}".TranslatorFormat(user.UserName, pwd));
};
return base.Add(saveModel); ;
}
/// <summary>
/// 删除用户拦截过滤
/// 用户被删除后同时清空对应缓存
/// </summary>
/// <param name="keys"></param>
/// <param name="delList"></param>
/// <returns></returns>
public override WebResponseContent Del(object[] keys, bool delList = false)
{
base.DelOnExecuting = (object[] ids) =>
{
int[] userIds = ids.Select(x => Convert.ToInt32(x)).ToArray();
return new WebResponseContent().OK();
};
base.DelOnExecuted = (object[] userIds) =>
{
var objKeys = userIds.Select(x => x.GetInt().GetUserIdKey());
base.CacheContext.RemoveAll(objKeys);
return new WebResponseContent() { Status = true };
};
return base.Del(keys, delList);
}
/// <summary>
/// 保存角色
/// </summary>
/// <param name="roleIds"></param>
/// <param name="userId"></param>
public void SaveRole(int[] roleIds, int userId)
{
if (userId <= 0)
{
return;
}
if (roleIds == null)
{
roleIds = new int[] { };
}
//如果需要判断当前角色是否越权,再调用一下获取当前角色下的所有子角色判断即可
var roles = repository.DbContext.Set<Sys_UserRole>().Where(x => x.UserId == userId)
.Select(s => new { s.RoleId, s.Enable, s.Id })
.ToList();
////没有设置角色
//if (roleIds.Length == 0 && roles.Exists(x => x.Enable == 1))
//{
// return;
//}
UserInfo user = UserContext.Current.UserInfo;
//新设置的角色
var add = roleIds.Where(x => !roles.Exists(r => r.RoleId == x)).Select(s => new Sys_UserRole()
{
Id = Guid.NewGuid(),
RoleId = s,
UserId = userId,
Enable = 1,
CreateDate = DateTime.Now,
Creator = user.UserTrueName,
CreateID = user.User_Id
}).ToList();
//删除的角色
var update = roles.Where(x => !roleIds.Contains(x.RoleId) && x.Enable == 1).Select(s => new Sys_UserRole()
{
Id = s.Id,
Enable = 0,
ModifyDate = DateTime.Now,
Modifier = user.UserTrueName,
ModifyID = user.User_Id
}).ToList();
//之前设置过的角色重新分配
update.AddRange(roles.Where(x => roleIds.Contains(x.RoleId) && x.Enable != 1).Select(s => new Sys_UserRole()
{
Id = s.Id,
Enable = 1,
ModifyDate = DateTime.Now,
Modifier = user.UserTrueName,
ModifyID = user.User_Id
}).ToList());
repository.AddRange(add);
repository.UpdateRange(update, x => new { x.Enable, x.ModifyDate, x.Modifier, x.ModifyID });
repository.SaveChanges();
}
/// <summary>
/// 保存部门
/// </summary>
/// <param name="deptIds"></param>
/// <param name="userId"></param>
public void SaveDepartment(Guid[] deptIds, int userId)
{
if (userId <= 0)
{
return;
}
if (deptIds == null)
{
deptIds = new Guid[] { };
}
//如果需要判断当前角色是否越权,再调用一下获取当前部门下的所有子角色判断即可
var roles = repository.DbContext.Set<Sys_UserDepartment>().Where(x => x.UserId == userId)
.Select(s => new { s.DepartmentId, s.Enable, s.Id })
.ToList();
//没有设置部门
if (deptIds.Length == 0 && !roles.Exists(x => x.Enable == 1))
{
return;
}
UserInfo user = UserContext.Current.UserInfo;
//新设置的部门
var add = deptIds.Where(x => !roles.Exists(r => r.DepartmentId == x)).Select(s => new Sys_UserDepartment()
{
Id = Guid.NewGuid(),
DepartmentId = s,
UserId = userId,
Enable = 1,
CreateDate = DateTime.Now,
Creator = user.UserTrueName,
CreateID = user.User_Id
}).ToList();
//删除的部门
var update = roles.Where(x => !deptIds.Contains(x.DepartmentId) && x.Enable == 1).Select(s => new Sys_UserDepartment()
{
Id = s.Id,
Enable = 0,
ModifyDate = DateTime.Now,
Modifier = user.UserTrueName,
ModifyID = user.User_Id
}).ToList();
//之前设置过的部门重新分配
update.AddRange(roles.Where(x => deptIds.Contains(x.DepartmentId) && x.Enable != 1).Select(s => new Sys_UserDepartment()
{
Id = s.Id,
Enable = 1,
ModifyDate = DateTime.Now,
Modifier = user.UserTrueName,
ModifyID = user.User_Id
}).ToList());
repository.AddRange(add);
repository.UpdateRange(update, x => new { x.Enable, x.ModifyDate, x.Modifier, x.ModifyID });
repository.SaveChanges();
}
/// <summary>
/// 保存岗位
/// </summary>
/// <param name="postIds"></param>
/// <param name="userId"></param>
public void SavePost(Guid[] postIds, int userId)
{
if (userId <= 0)
{
return;
}
if (postIds == null)
{
postIds = new Guid[] { };
}
var roles = repository.DbContext.Set<Sys_UserPost>().Where(x => x.UserId == userId)
.Select(s => new { s.PostId, s.Enable, s.Id })
.ToList();
//没有设置部门
if (postIds.Length == 0 && !roles.Exists(x => x.Enable == 1))
{
return;
}
UserInfo user = UserContext.Current.UserInfo;
//新设置的部门
var add = postIds.Where(x => !roles.Exists(r => r.PostId == x)).Select(s => new Sys_UserPost()
{
Id = Guid.NewGuid(),
PostId = s,
UserId = userId,
Enable = 1,
CreateDate = DateTime.Now,
Creator = user.UserTrueName,
CreateID = user.User_Id
}).ToList();
//删除的部门
var update = roles.Where(x => !postIds.Contains(x.PostId) && x.Enable == 1).Select(s => new Sys_UserPost()
{
Id = s.Id,
Enable = 0,
ModifyDate = DateTime.Now,
Modifier = user.UserTrueName,
ModifyID = user.User_Id
}).ToList();
//之前设置过的部门重新分配
update.AddRange(roles.Where(x => postIds.Contains(x.PostId) && x.Enable != 1).Select(s => new Sys_UserPost()
{
Id = s.Id,
Enable = 1,
ModifyDate = DateTime.Now,
Modifier = user.UserTrueName,
ModifyID = user.User_Id
}).ToList());
repository.AddRange(add);
repository.UpdateRange(update, x => new { x.Enable, x.ModifyDate, x.Modifier, x.ModifyID });
repository.SaveChanges();
}
/// <summary>
/// 修改用户拦截过滤
///
/// </summary>
/// <param name="saveModel"></param>
/// <returns></returns>
public override WebResponseContent Update(SaveModel saveModel)
{
UserInfo userInfo = UserContext.Current.UserInfo;
base.UpdateOnExecuting = (Sys_User user, object obj1, object obj2, List<object> list) =>
{
var _user = repository.Find(x => x.User_Id == user.User_Id,
s => new { s.UserName, s.UserPwd })
.FirstOrDefault();
user.UserName = _user.UserName;
//Sys_User实体的UserPwd用户密码字段的属性不是编辑此处不会修改密码。但防止代码生成器将密码字段的修改成了可编辑造成密码被修改
user.UserPwd = _user.UserPwd;
return webResponse.OK();
};
//用户信息被修改后,将用户的缓存信息清除
base.UpdateOnExecuted = (Sys_User user, object obj1, object obj2, List<object> List) =>
{
base.CacheContext.Remove(user.User_Id.GetUserIdKey());
var roleIds = user.RoleIds?.Split(",").Select(s => s.GetInt()).Where(x => x > 1).ToArray();
SaveRole(roleIds, user.User_Id);
var deptIds = user.DeptIds?.Split(",").Select(s => s.GetGuid()).Where(x => x != null).Select(s => (Guid)s).ToArray();
SaveDepartment(deptIds, user.User_Id);
var postIds = user.PostId?.Split(",").Select(s => s.GetGuid()).Where(x => x != null).Select(s => (Guid)s).ToArray();
SavePost(postIds, user.User_Id);
return new WebResponseContent(true);
};
return base.Update(saveModel);
}
/// <summary>
/// 导出处理
/// </summary>
/// <param name="pageData"></param>
/// <returns></returns>
public override WebResponseContent Export(PageDataOptions pageData)
{
//限定只能导出当前角色能看到的所有用户
QueryRelativeExpression = (ISugarQueryable<Sys_User> queryable) =>
{
if (UserContext.Current.IsSuperAdmin) return queryable;
List<int> roleIds = Sys_RoleService
.Instance
.GetAllChildrenRoleId(UserContext.Current.RoleIds);
return queryable.Where(x => roleIds.Contains(x.Role_Id ?? 0) || x.User_Id == UserContext.Current.UserId);
};
base.ExportOnExecuting = (List<Sys_User> list, List<string> ignoreColumn) =>
{
if (!ignoreColumn.Contains("Role_Id"))
{
ignoreColumn.Add("Role_Id");
}
if (!ignoreColumn.Contains("RoleName"))
{
ignoreColumn.Remove("RoleName");
}
WebResponseContent responseData = new WebResponseContent(true);
return responseData;
};
return base.Export(pageData);
}
}
}

View File

@@ -0,0 +1,27 @@
/*
*Authorjxx
*Contact283591387@qq.com
*代码由框架生成,此处任何更改都可能导致被代码生成器覆盖
*所有业务编写全部应在Partial文件夹下Sys_DepartmentService与ISys_DepartmentService中编写
*/
using VolPro.Sys.IRepositories;
using VolPro.Sys.IServices;
using VolPro.Core.BaseProvider;
using VolPro.Core.Extensions.AutofacManager;
using VolPro.Entity.DomainModels;
namespace VolPro.Sys.Services
{
public partial class Sys_DepartmentService : ServiceBase<Sys_Department, ISys_DepartmentRepository>
, ISys_DepartmentService, IDependency
{
public Sys_DepartmentService(ISys_DepartmentRepository repository)
: base(repository)
{
Init(repository);
}
public static ISys_DepartmentService Instance
{
get { return AutofacContainerModule.GetService<ISys_DepartmentService>(); } }
}
}

View File

@@ -0,0 +1,27 @@
/*
*Authorjxx
*Contact283591387@qq.com
*代码由框架生成,此处任何更改都可能导致被代码生成器覆盖
*所有业务编写全部应在Partial文件夹下Sys_DictionaryListService与ISys_DictionaryListService中编写
*/
using VolPro.Sys.IRepositories;
using VolPro.Sys.IServices;
using VolPro.Core.BaseProvider;
using VolPro.Core.Extensions.AutofacManager;
using VolPro.Entity.DomainModels;
namespace VolPro.Sys.Services
{
public partial class Sys_DictionaryListService : ServiceBase<Sys_DictionaryList, ISys_DictionaryListRepository>
, ISys_DictionaryListService, IDependency
{
public Sys_DictionaryListService(ISys_DictionaryListRepository repository)
: base(repository)
{
Init(repository);
}
public static ISys_DictionaryListService Instance
{
get { return AutofacContainerModule.GetService<ISys_DictionaryListService>(); } }
}
}

View File

@@ -0,0 +1,28 @@
/*
*Authorjxx
*Contact283591387@qq.com
*Date2018-07-01
* 此代码由框架生成,请勿随意更改
*/
using VolPro.Sys.IRepositories;
using VolPro.Sys.IServices;
using VolPro.Core.BaseProvider;
using VolPro.Core.Extensions.AutofacManager;
using VolPro.Entity.DomainModels;
namespace VolPro.Sys.Services
{
public partial class Sys_DictionaryService : ServiceBase<Sys_Dictionary, ISys_DictionaryRepository>, ISys_DictionaryService, IDependency
{
public Sys_DictionaryService(ISys_DictionaryRepository repository)
: base(repository)
{
Init(repository);
}
public static ISys_DictionaryService Instance
{
get { return AutofacContainerModule.GetService<ISys_DictionaryService>(); }
}
}
}

View File

@@ -0,0 +1,22 @@
using VolPro.Sys.IRepositories;
using VolPro.Sys.IServices;
using VolPro.Core.BaseProvider;
using VolPro.Core.Extensions.AutofacManager;
using VolPro.Entity.DomainModels;
namespace VolPro.Sys.Services
{
public partial class Sys_LogService : ServiceBase<Sys_Log, ISys_LogRepository>, ISys_LogService, IDependency
{
public Sys_LogService(ISys_LogRepository repository)
: base(repository)
{
Init(repository);
}
public static ISys_LogService Instance
{
get { return AutofacContainerModule.GetService<ISys_LogService>(); }
}
}
}

View File

@@ -0,0 +1,22 @@
using VolPro.Sys.IRepositories;
using VolPro.Sys.IServices;
using VolPro.Core.BaseProvider;
using VolPro.Core.Extensions.AutofacManager;
using VolPro.Entity.DomainModels;
namespace VolPro.Sys.Services
{
public partial class Sys_MenuService : ServiceBase<Sys_Menu, ISys_MenuRepository>, ISys_MenuService, IDependency
{
public Sys_MenuService(ISys_MenuRepository repository)
: base(repository)
{
Init(repository);
}
public static ISys_MenuService Instance
{
get { return AutofacContainerModule.GetService<ISys_MenuService>(); }
}
}
}

View File

@@ -0,0 +1,22 @@
/*
*Authorjxx
*Contact283591387@qq.com
*代码由框架生成,此处任何更改都可能导致被代码生成器覆盖
*所有业务编写全部应在Partial文件夹下Sys_PostService与ISys_PostService中编写
*/
using VolPro.Sys.IRepositories;
using VolPro.Sys.IServices;
using VolPro.Core.BaseProvider;
using VolPro.Core.Extensions.AutofacManager;
using VolPro.Entity.DomainModels;
namespace VolPro.Sys.Services
{
public partial class Sys_PostService : ServiceBase<Sys_Post, ISys_PostRepository>
, ISys_PostService, IDependency
{
public static ISys_PostService Instance
{
get { return AutofacContainerModule.GetService<ISys_PostService>(); } }
}
}

View File

@@ -0,0 +1,27 @@
/*
*Authorjxx
*Contact283591387@qq.com
*代码由框架生成,此处任何更改都可能导致被代码生成器覆盖
*所有业务编写全部应在Partial文件夹下Sys_PrintOptionsService与ISys_PrintOptionsService中编写
*/
using VolPro.Sys.IRepositories;
using VolPro.Sys.IServices;
using VolPro.Core.BaseProvider;
using VolPro.Core.Extensions.AutofacManager;
using VolPro.Entity.DomainModels;
namespace VolPro.Sys.Services
{
public partial class Sys_PrintOptionsService : ServiceBase<Sys_PrintOptions, ISys_PrintOptionsRepository>
, ISys_PrintOptionsService, IDependency
{
public Sys_PrintOptionsService(ISys_PrintOptionsRepository repository)
: base(repository)
{
Init(repository);
}
public static ISys_PrintOptionsService Instance
{
get { return AutofacContainerModule.GetService<ISys_PrintOptionsService>(); } }
}
}

View File

@@ -0,0 +1,27 @@
/*
*Authorjxx
*Contact283591387@qq.com
*代码由框架生成,此处任何更改都可能导致被代码生成器覆盖
*所有业务编写全部应在Partial文件夹下Sys_RegionService与ISys_RegionService中编写
*/
using VolPro.Sys.IRepositories;
using VolPro.Sys.IServices;
using VolPro.Core.BaseProvider;
using VolPro.Core.Extensions.AutofacManager;
using VolPro.Entity.DomainModels;
namespace VolPro.Sys.Services
{
public partial class Sys_RegionService : ServiceBase<Sys_Region, ISys_RegionRepository>
, ISys_RegionService, IDependency
{
public Sys_RegionService(ISys_RegionRepository repository)
: base(repository)
{
Init(repository);
}
public static ISys_RegionService Instance
{
get { return AutofacContainerModule.GetService<ISys_RegionService>(); } }
}
}

View File

@@ -0,0 +1,27 @@
/*
*Authorjxx
*Contact283591387@qq.com
*代码由框架生成,此处任何更改都可能导致被代码生成器覆盖
*所有业务编写全部应在Partial文件夹下Sys_ReportOptionsService与ISys_ReportOptionsService中编写
*/
using VolPro.Sys.IRepositories;
using VolPro.Sys.IServices;
using VolPro.Core.BaseProvider;
using VolPro.Core.Extensions.AutofacManager;
using VolPro.Entity.DomainModels;
namespace VolPro.Sys.Services
{
public partial class Sys_ReportOptionsService : ServiceBase<Sys_ReportOptions, ISys_ReportOptionsRepository>
, ISys_ReportOptionsService, IDependency
{
public Sys_ReportOptionsService(ISys_ReportOptionsRepository repository)
: base(repository)
{
Init(repository);
}
public static ISys_ReportOptionsService Instance
{
get { return AutofacContainerModule.GetService<ISys_ReportOptionsService>(); } }
}
}

View File

@@ -0,0 +1,28 @@
/*
*Authorjxx
*Contact283591387@qq.com
*Date2018-07-01
* 此代码由框架生成,请勿随意更改
*/
using VolPro.Sys.IRepositories;
using VolPro.Sys.IServices;
using VolPro.Core.BaseProvider;
using VolPro.Core.Extensions.AutofacManager;
using VolPro.Entity.DomainModels;
namespace VolPro.Sys.Services
{
public partial class Sys_RoleService : ServiceBase<Sys_Role, ISys_RoleRepository>, ISys_RoleService, IDependency
{
public Sys_RoleService(ISys_RoleRepository repository)
: base(repository)
{
Init(repository);
}
public static ISys_RoleService Instance
{
get { return AutofacContainerModule.GetService<ISys_RoleService>(); }
}
}
}

View File

@@ -0,0 +1,28 @@
/*
*Authorjxx
*Contact283591387@qq.com
*Date2018-07-01
* 此代码由框架生成,请勿随意更改
*/
using VolPro.Sys.IRepositories;
using VolPro.Sys.IServices;
using VolPro.Core.BaseProvider;
using VolPro.Core.Extensions.AutofacManager;
using VolPro.Entity.DomainModels;
namespace VolPro.Sys.Services
{
public partial class Sys_UserService : ServiceBase<Sys_User, ISys_UserRepository>, ISys_UserService, IDependency
{
public Sys_UserService(ISys_UserRepository repository)
: base(repository)
{
Init(repository);
}
public static ISys_UserService Instance
{
get { return AutofacContainerModule.GetService<ISys_UserService>(); }
}
}
}

View File

@@ -0,0 +1,28 @@
/*
*Authorjxx
*Contact283591387@qq.com
*Date2018-07-01
* 此代码由框架生成,请勿随意更改
*/
using VolPro.Sys.IRepositories;
using VolPro.Sys.IServices;
using VolPro.Core.BaseProvider;
using VolPro.Core.Extensions.AutofacManager;
using VolPro.Entity.DomainModels;
namespace VolPro.Sys.Services
{
public partial class vSys_DictionaryService : ServiceBase<vSys_Dictionary, IvSys_DictionaryRepository>, IvSys_DictionaryService, IDependency
{
public vSys_DictionaryService(IvSys_DictionaryRepository repository)
: base(repository)
{
Init(repository);
}
public static IvSys_DictionaryService Instance
{
get { return AutofacContainerModule.GetService<IvSys_DictionaryService>(); }
}
}
}

View File

@@ -0,0 +1,184 @@
/*
*所有关于Sys_WorkFlow类的业务代码应在此处编写
*可使用repository.调用常用方法获取EF/Dapper等信息
*如果需要事务请使用repository.DbContextBeginTransaction
*也可使用DBServerProvider.手动获取数据库相关信息
*用户信息、权限、角色等使用UserContext.Current操作
*Sys_WorkFlowService对增、删、改查、导入、导出、审核业务代码扩展参照ServiceFunFilter
*/
using VolPro.Core.BaseProvider;
using VolPro.Core.Extensions.AutofacManager;
using VolPro.Entity.DomainModels;
using System.Linq;
using VolPro.Core.Utilities;
using System.Linq.Expressions;
using VolPro.Core.Extensions;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.AspNetCore.Http;
using VolPro.Sys.IRepositories;
using System.Collections.Generic;
using VolPro.Core.WorkFlow;
using System;
using VolPro.Sys.Repositories;
using VolPro.Core.DbSqlSugar;
using VolPro.Core.ManageUser;
using SqlSugar;
using VolPro.Core.Configuration;
using Azure;
namespace VolPro.Sys.Services
{
public partial class Sys_WorkFlowService
{
private readonly IHttpContextAccessor _httpContextAccessor;
private readonly ISys_WorkFlowRepository _repository;//访问数据库
private readonly ISys_WorkFlowStepRepository _stepRepository;
[ActivatorUtilitiesConstructor]
public Sys_WorkFlowService(
ISys_WorkFlowRepository dbRepository,
IHttpContextAccessor httpContextAccessor,
ISys_WorkFlowStepRepository stepRepository
)
: base(dbRepository)
{
_httpContextAccessor = httpContextAccessor;
_repository = dbRepository;
_stepRepository = stepRepository;
//多租户会用到这init代码其他情况可以不用
//base.Init(dbRepository);
}
WebResponseContent webResponse = new WebResponseContent();
public override PageGridData<Sys_WorkFlow> GetPageData(PageDataOptions options)
{
QueryRelativeExpression = (ISugarQueryable<Sys_WorkFlow> query) =>
{
//租户流程隔离显示
if (AppSetting.UseDynamicShareDB || !string.IsNullOrEmpty(AppSetting.TenancyField))
{
query = query.Where(x => x.DbServiceId == UserContext.CurrentServiceId);
}
return query;
};
return base.GetPageData(options);
}
public override WebResponseContent Add(SaveModel saveDataModel)
{
saveDataModel.MainData["Enable"] = 1;
AddOnExecuting = (Sys_WorkFlow workFlow, object list) =>
{
workFlow.DbServiceId = UserContext.CurrentServiceId;
workFlow.WorkFlow_Id = Guid.NewGuid();
webResponse = WorkFlowContainer.Instance.AddTable(workFlow, list as List<Sys_WorkFlowStep>);
if (!webResponse.Status)
{
return webResponse;
}
return webResponse.OK();
};
AddOnExecuted = (Sys_WorkFlow workFlow, object list) =>
{
return webResponse.OK();
};
return base.Add(saveDataModel);
}
public override WebResponseContent Import(List<IFormFile> files)
{
return base.Import(files);
}
public override WebResponseContent Update(SaveModel saveModel)
{
Sys_WorkFlow flow = null;
UpdateOnExecuting = (Sys_WorkFlow workFlow, object addList, object updateList, List<object> delKeys) =>
{
flow = workFlow;
//if ((flow.AuditingEdit ?? 0) == 0)
//{
// if (Sys_WorkFlowTableRepository.Instance.Exists(x => x.WorkFlow_Id == flow.WorkFlow_Id && (x.AuditStatus == (int)AuditStatus.审核中)))
// {
// return webResponse.Error("当前流程有审核中的数据,不能修改,可以修改,流程中的【审核中数据是否可以编辑】属性");
// }
//}
//新增的明细
List<Sys_WorkFlowStep> add = addList as List<Sys_WorkFlowStep>;
var stepsClone = add.Serialize().DeserializeObject<List<Sys_WorkFlowStep>>();
add.Clear();
var steps = _stepRepository.FindAsIQueryable(x => x.WorkFlow_Id == workFlow.WorkFlow_Id)
.Select(s => new { s.WorkStepFlow_Id, s.StepId })
.ToList();
//删除的节点
var delIds = steps.Where(x => !stepsClone.Any(c => c.StepId == x.StepId))
.Select(s => s.WorkStepFlow_Id).ToList();
delKeys.AddRange(delIds.Select(s => s as object));
//新增的节点
var newSteps = stepsClone.Where(x => !steps.Any(c => c.StepId == x.StepId))
.ToList();
foreach (var item in newSteps)
{
item.WorkStepFlow_Id = Guid.NewGuid();
}
add.AddRange(newSteps);
List<Sys_WorkFlowStep> update = updateList as List<Sys_WorkFlowStep>;
//修改的节点
var updateSteps = stepsClone.Where(x => steps.Any(c => c.StepId == x.StepId))
.ToList();
update.AddRange(updateSteps);
updateSteps.ForEach(x =>
{
x.WorkStepFlow_Id = steps.Where(c => c.StepId == x.StepId).Select(s => s.WorkStepFlow_Id).FirstOrDefault();
foreach (var item in saveModel.DetailData)
{
if (item["StepId"].ToString() == x.StepId)
{
item["WorkFlow_Id"] = workFlow.WorkFlow_Id;
item["WorkStepFlow_Id"] = x.WorkStepFlow_Id;
}
}
});
return webResponse.OK();
};
UpdateOnExecuted = (Sys_WorkFlow workFlow, object addList, object updateList, List<object> delKeys) =>
{
//repository.UpdateRange((List<Sys_WorkFlowStep>)updateList);
_stepRepository.DeleteWithKeys(delKeys.ToArray());
repository.SaveChanges();
WorkFlowManager.UpdateFlowData(workFlow, (List<Sys_WorkFlowStep>)addList);
return webResponse.OK();
};
webResponse = base.Update(saveModel);
if (webResponse.Status)
{
flow = repository.FindAsIQueryable(x => x.WorkFlow_Id == flow.WorkFlow_Id).Includes(x => x.Sys_WorkFlowStep).FirstOrDefault();
webResponse = WorkFlowContainer.Instance.AddTable(flow, flow.Sys_WorkFlowStep);
}
return webResponse;
}
public override WebResponseContent Del(object[] keys, bool delList = true)
{
webResponse = base.Del(keys, delList);
if (webResponse.Status)
{
WorkFlowContainer.DelRange(keys.Select(s => (Guid)s.GetGuid()).ToArray());
}
return webResponse;
}
}
}

View File

@@ -0,0 +1,43 @@
/*
*所有关于Sys_WorkFlowStep类的业务代码应在此处编写
*可使用repository.调用常用方法获取EF/Dapper等信息
*如果需要事务请使用repository.DbContextBeginTransaction
*也可使用DBServerProvider.手动获取数据库相关信息
*用户信息、权限、角色等使用UserContext.Current操作
*Sys_WorkFlowStepService对增、删、改查、导入、导出、审核业务代码扩展参照ServiceFunFilter
*/
using VolPro.Core.BaseProvider;
using VolPro.Core.Extensions.AutofacManager;
using VolPro.Entity.DomainModels;
using System.Linq;
using VolPro.Core.Utilities;
using System.Linq.Expressions;
using VolPro.Core.Extensions;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.AspNetCore.Http;
using VolPro.Sys.IRepositories;
namespace VolPro.Sys.Services
{
public partial class Sys_WorkFlowStepService
{
private readonly IHttpContextAccessor _httpContextAccessor;
private readonly ISys_WorkFlowStepRepository _repository;//访问数据库
[ActivatorUtilitiesConstructor]
public Sys_WorkFlowStepService(
ISys_WorkFlowStepRepository dbRepository,
IHttpContextAccessor httpContextAccessor
)
: base(dbRepository)
{
_httpContextAccessor = httpContextAccessor;
_repository = dbRepository;
//多租户会用到这init代码其他情况可以不用
//base.Init(dbRepository);
}
}
}

View File

@@ -0,0 +1,169 @@
/*
*所有关于Sys_WorkFlowTable类的业务代码应在此处编写
*可使用repository.调用常用方法获取EF/Dapper等信息
*如果需要事务请使用repository.DbContextBeginTransaction
*也可使用DBServerProvider.手动获取数据库相关信息
*用户信息、权限、角色等使用UserContext.Current操作
*Sys_WorkFlowTableService对增、删、改查、导入、导出、审核业务代码扩展参照ServiceFunFilter
*/
using VolPro.Core.BaseProvider;
using VolPro.Core.Extensions.AutofacManager;
using VolPro.Entity.DomainModels;
using System.Linq;
using VolPro.Core.Utilities;
using System.Linq.Expressions;
using VolPro.Core.Extensions;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.AspNetCore.Http;
using VolPro.Sys.IRepositories;
using VolPro.Core.ManageUser;
using VolPro.Core.WorkFlow;
using System;
using VolPro.Core.DBManager;
using System.Collections.Generic;
using SqlSugar;
namespace VolPro.Sys.Services
{
public partial class Sys_WorkFlowTableService
{
private readonly IHttpContextAccessor _httpContextAccessor;
private readonly ISys_WorkFlowTableRepository _repository;//访问数据库
private readonly ISys_WorkFlowTableStepRepository _stepRepository;//访问数据库
[ActivatorUtilitiesConstructor]
public Sys_WorkFlowTableService(
ISys_WorkFlowTableRepository dbRepository,
IHttpContextAccessor httpContextAccessor,
ISys_WorkFlowTableStepRepository stepRepository
)
: base(dbRepository)
{
_httpContextAccessor = httpContextAccessor;
_repository = dbRepository;
_stepRepository = stepRepository;
IsMultiTenancy = false;
}
/// <summary>
/// 待审核、审批中的数据
/// </summary>
/// <param name="queryable"></param>
/// <returns></returns>
private ISugarQueryable<Sys_WorkFlowTable> GetAuditQuery(ISugarQueryable<Sys_WorkFlowTable> queryable, bool all = false)
{
var user = UserContext.Current.UserInfo;
var deptIds = user.DeptIds.Select(s => s.ToString());
var roleIds = user.RoleIds.Select(s => s.ToString());
//显示当前用户的全部数据
if (all)
{
queryable = queryable.Where(x =>
SqlFunc.Subqueryable<Sys_WorkFlowTableStep>().Where(c =>
((c.StepType == (int)AuditType. && c.StepValue == user.User_Id.ToString()) ||
(c.StepType == (int)AuditType. && roleIds.Contains(c.StepValue)) ||
(c.StepType == (int)AuditType. && deptIds.Contains(c.StepValue)))
&& x.WorkFlowTable_Id == c.WorkFlowTable_Id
&& (x.CreateID == user.User_Id || x.CurrentStepId == c.StepId || c.AuditId == user.User_Id)
).Any());
return queryable;
}
string uid = user.User_Id.ToString();
//待审核、审批中的数据
queryable = queryable.Where(x =>
SqlFunc.Subqueryable<Sys_WorkFlowTableStep>().Where(c =>
(c.StepType == (int)AuditType. && c.StepValue == uid ||
(c.StepType == (int)AuditType. && roleIds.Contains(c.StepValue)) ||
(c.StepType == (int)AuditType. && deptIds.Contains(c.StepValue)))
&& x.WorkFlowTable_Id == c.WorkFlowTable_Id
&& x.CurrentStepId == c.StepId && (c.AuditStatus == null || c.AuditStatus == 0)
).Any());
queryable = queryable.Where(x => x.AuditStatus == (int)AuditStatus. || x.AuditStatus == (int)AuditStatus.);
return queryable;
}
public override PageGridData<Sys_WorkFlowTable> GetPageData(PageDataOptions options)
{
var user = UserContext.Current.UserInfo;
QueryRelativeExpression = (ISugarQueryable<Sys_WorkFlowTable> queryable) =>
{
int value = options.Value.GetInt();
switch (value)
{
//我的提交
case 50:
queryable = queryable.Where(x => x.CreateID == UserContext.Current.UserId);
break;
//我的审核
case 40:
queryable = queryable.Where(x => SqlFunc.Subqueryable<Sys_WorkFlowTableStep>()
.Where(c => c.AuditId == user.User_Id && x.WorkFlowTable_Id == c.WorkFlowTable_Id).Any());
break;
//抄送我的
case -2:
var deptIds = user.DeptIds.Select(s => s.ToString());
var roleIds = user.RoleIds.Select(s => s.ToString());
string uid = user.User_Id.ToString();
//待审核、审批中的数据
queryable = queryable.Where(x =>
SqlFunc.Subqueryable<Sys_WorkFlowTableStep>().Where(c =>
(c.StepType == (int)AuditType. && c.StepValue == uid ||
(c.StepType == (int)AuditType. && roleIds.Contains(c.StepValue)) ||
(c.StepType == (int)AuditType. && deptIds.Contains(c.StepValue)))
&& x.WorkFlowTable_Id == c.WorkFlowTable_Id
&& c.StepAttrType == StepType.cc.ToString()
&& SqlFunc.Subqueryable<Sys_WorkFlowTableStep>().Where(a => c.ParentId == a.StepId && x.WorkFlowTable_Id == a.WorkFlowTable_Id && a.AuditStatus == 1).Any()
).Any());
break;
case (int)AuditStatus.:
case (int)AuditStatus.:
queryable = GetAuditQuery(queryable);
break;
case (int)AuditStatus.:
case (int)AuditStatus.:
case (int)AuditStatus.:
queryable = queryable.Where(x => SqlFunc.Subqueryable<Sys_WorkFlowTableStep>()
.Where(c => c.AuditId == user.User_Id && x.WorkFlowTable_Id == c.WorkFlowTable_Id).Any());
if (value == (int)AuditStatus.)
{
queryable = queryable.Where(x => x.AuditStatus == (int)AuditStatus.);
}
else if (value == (int)AuditStatus.)
{
queryable = queryable.Where(x => x.AuditStatus == (int)AuditStatus.);
}
else
{
queryable = queryable.Where(x => x.AuditStatus == (int)AuditStatus.);
}
break;
default:
break;
}
queryable = queryable.Where(x => (x.AuditStatus != (int)AuditStatus.稿 && x.AuditStatus != (int)AuditStatus.));
if (value == -1 && !UserContext.Current.IsSuperAdmin)
{
queryable = GetAuditQuery(queryable, true);
}
return queryable;
};
//QueryRelativeExpression = (ISugarQueryable<Sys_WorkFlowTable> queryable) =>
//{
// var user = UserContext.Current.UserInfo;
// //显示当前用户需要审批的数据
// var deptIds = user.DeptIds.Select(s => s.ToString());
// queryable = queryable.Where(c =>
// SqlFunc.Subqueryable<Sys_WorkFlowTableStep>()
// .Where(x => c.WorkFlowTable_Id == x.WorkFlowTable_Id
// && ((x.StepType == (int)AuditType.用户审批 && x.StepValue == user.User_Id.ToString())
// || (x.StepType == (int)AuditType.角色审批 && user.RoleIds.Select(s => s.ToString()).Contains(x.StepValue))
// || (x.StepType == (int)AuditType.部门审批 && deptIds.Contains(x.StepValue)))
// )
// .Any());
// queryable = queryable.Where(x => (x.AuditStatus != (int)AuditStatus.草稿 && x.AuditStatus != (int)AuditStatus.待提交));
// return queryable;
//};
// }
return base.GetPageData(options);
}
}
}

View File

@@ -0,0 +1,41 @@
/*
*所有关于Sys_WorkFlowTableStep类的业务代码应在此处编写
*可使用repository.调用常用方法获取EF/Dapper等信息
*如果需要事务请使用repository.DbContextBeginTransaction
*也可使用DBServerProvider.手动获取数据库相关信息
*用户信息、权限、角色等使用UserContext.Current操作
*Sys_WorkFlowTableStepService对增、删、改查、导入、导出、审核业务代码扩展参照ServiceFunFilter
*/
using VolPro.Core.BaseProvider;
using VolPro.Core.Extensions.AutofacManager;
using VolPro.Entity.DomainModels;
using System.Linq;
using VolPro.Core.Utilities;
using System.Linq.Expressions;
using VolPro.Core.Extensions;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.AspNetCore.Http;
using VolPro.Sys.IRepositories;
namespace VolPro.Sys.Services
{
public partial class Sys_WorkFlowTableStepService
{
private readonly IHttpContextAccessor _httpContextAccessor;
private readonly ISys_WorkFlowTableStepRepository _repository;//访问数据库
[ActivatorUtilitiesConstructor]
public Sys_WorkFlowTableStepService(
ISys_WorkFlowTableStepRepository dbRepository,
IHttpContextAccessor httpContextAccessor
)
: base(dbRepository)
{
_httpContextAccessor = httpContextAccessor;
_repository = dbRepository;
//多租户会用到这init代码其他情况可以不用
//base.Init(dbRepository);
}
}
}

View File

@@ -0,0 +1,27 @@
/*
*Authorjxx
*Contact283591387@qq.com
*代码由框架生成,此处任何更改都可能导致被代码生成器覆盖
*所有业务编写全部应在Partial文件夹下Sys_WorkFlowService与ISys_WorkFlowService中编写
*/
using VolPro.Sys.IRepositories;
using VolPro.Sys.IServices;
using VolPro.Core.BaseProvider;
using VolPro.Core.Extensions.AutofacManager;
using VolPro.Entity.DomainModels;
namespace VolPro.Sys.Services
{
public partial class Sys_WorkFlowService : ServiceBase<Sys_WorkFlow, ISys_WorkFlowRepository>
, ISys_WorkFlowService, IDependency
{
public Sys_WorkFlowService(ISys_WorkFlowRepository repository)
: base(repository)
{
Init(repository);
}
public static ISys_WorkFlowService Instance
{
get { return AutofacContainerModule.GetService<ISys_WorkFlowService>(); } }
}
}

View File

@@ -0,0 +1,27 @@
/*
*Authorjxx
*Contact283591387@qq.com
*代码由框架生成,此处任何更改都可能导致被代码生成器覆盖
*所有业务编写全部应在Partial文件夹下Sys_WorkFlowStepService与ISys_WorkFlowStepService中编写
*/
using VolPro.Sys.IRepositories;
using VolPro.Sys.IServices;
using VolPro.Core.BaseProvider;
using VolPro.Core.Extensions.AutofacManager;
using VolPro.Entity.DomainModels;
namespace VolPro.Sys.Services
{
public partial class Sys_WorkFlowStepService : ServiceBase<Sys_WorkFlowStep, ISys_WorkFlowStepRepository>
, ISys_WorkFlowStepService, IDependency
{
public Sys_WorkFlowStepService(ISys_WorkFlowStepRepository repository)
: base(repository)
{
Init(repository);
}
public static ISys_WorkFlowStepService Instance
{
get { return AutofacContainerModule.GetService<ISys_WorkFlowStepService>(); } }
}
}

View File

@@ -0,0 +1,27 @@
/*
*Authorjxx
*Contact283591387@qq.com
*代码由框架生成,此处任何更改都可能导致被代码生成器覆盖
*所有业务编写全部应在Partial文件夹下Sys_WorkFlowTableService与ISys_WorkFlowTableService中编写
*/
using VolPro.Sys.IRepositories;
using VolPro.Sys.IServices;
using VolPro.Core.BaseProvider;
using VolPro.Core.Extensions.AutofacManager;
using VolPro.Entity.DomainModels;
namespace VolPro.Sys.Services
{
public partial class Sys_WorkFlowTableService : ServiceBase<Sys_WorkFlowTable, ISys_WorkFlowTableRepository>
, ISys_WorkFlowTableService, IDependency
{
public Sys_WorkFlowTableService(ISys_WorkFlowTableRepository repository)
: base(repository)
{
Init(repository);
}
public static ISys_WorkFlowTableService Instance
{
get { return AutofacContainerModule.GetService<ISys_WorkFlowTableService>(); } }
}
}

View File

@@ -0,0 +1,27 @@
/*
*Authorjxx
*Contact283591387@qq.com
*代码由框架生成,此处任何更改都可能导致被代码生成器覆盖
*所有业务编写全部应在Partial文件夹下Sys_WorkFlowTableStepService与ISys_WorkFlowTableStepService中编写
*/
using VolPro.Sys.IRepositories;
using VolPro.Sys.IServices;
using VolPro.Core.BaseProvider;
using VolPro.Core.Extensions.AutofacManager;
using VolPro.Entity.DomainModels;
namespace VolPro.Sys.Services
{
public partial class Sys_WorkFlowTableStepService : ServiceBase<Sys_WorkFlowTableStep, ISys_WorkFlowTableStepRepository>
, ISys_WorkFlowTableStepService, IDependency
{
public Sys_WorkFlowTableStepService(ISys_WorkFlowTableStepRepository repository)
: base(repository)
{
Init(repository);
}
public static ISys_WorkFlowTableStepService Instance
{
get { return AutofacContainerModule.GetService<ISys_WorkFlowTableStepService>(); } }
}
}

View File

@@ -0,0 +1,27 @@
/*
*Authorjxx
*Contact283591387@qq.com
*代码由框架生成,此处任何更改都可能导致被代码生成器覆盖
*所有业务编写全部应在Partial文件夹下FormCollectionObjectService与IFormCollectionObjectService中编写
*/
using VolPro.Sys.IRepositories;
using VolPro.Sys.IServices;
using VolPro.Core.BaseProvider;
using VolPro.Core.Extensions.AutofacManager;
using VolPro.Entity.DomainModels;
namespace VolPro.Sys.Services
{
public partial class FormCollectionObjectService : ServiceBase<FormCollectionObject, IFormCollectionObjectRepository>
, IFormCollectionObjectService, IDependency
{
public FormCollectionObjectService(IFormCollectionObjectRepository repository)
: base(repository)
{
Init(repository);
}
public static IFormCollectionObjectService Instance
{
get { return AutofacContainerModule.GetService<IFormCollectionObjectService>(); } }
}
}

View File

@@ -0,0 +1,27 @@
/*
*Authorjxx
*Contact283591387@qq.com
*代码由框架生成,此处任何更改都可能导致被代码生成器覆盖
*所有业务编写全部应在Partial文件夹下FormDesignOptionsService与IFormDesignOptionsService中编写
*/
using VolPro.Sys.IRepositories;
using VolPro.Sys.IServices;
using VolPro.Core.BaseProvider;
using VolPro.Core.Extensions.AutofacManager;
using VolPro.Entity.DomainModels;
namespace VolPro.Sys.Services
{
public partial class FormDesignOptionsService : ServiceBase<FormDesignOptions, IFormDesignOptionsRepository>
, IFormDesignOptionsService, IDependency
{
public FormDesignOptionsService(IFormDesignOptionsRepository repository)
: base(repository)
{
Init(repository);
}
public static IFormDesignOptionsService Instance
{
get { return AutofacContainerModule.GetService<IFormDesignOptionsService>(); } }
}
}

View File

@@ -0,0 +1,101 @@
/*
*所有关于FormCollectionObject类的业务代码应在此处编写
*可使用repository.调用常用方法获取EF/Dapper等信息
*如果需要事务请使用repository.DbContextBeginTransaction
*也可使用DBServerProvider.手动获取数据库相关信息
*用户信息、权限、角色等使用UserContext.Current操作
*FormCollectionObjectService对增、删、改查、导入、导出、审核业务代码扩展参照ServiceFunFilter
*/
using VolPro.Core.BaseProvider;
using VolPro.Core.Extensions.AutofacManager;
using VolPro.Entity.DomainModels;
using System.Linq;
using VolPro.Core.Utilities;
using System.Linq.Expressions;
using VolPro.Core.Extensions;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.AspNetCore.Http;
using VolPro.Sys.IRepositories;
using System.Collections.Generic;
using VolPro.Core.Configuration;
using VolPro.Core.Services;
using System;
using OfficeOpenXml;
using System.IO;
using OfficeOpenXml.Style;
using System.Drawing;
using VolPro.Core.DbSqlSugar;
namespace VolPro.Sys.Services
{
public partial class FormCollectionObjectService
{
private readonly IHttpContextAccessor _httpContextAccessor;
private readonly IFormCollectionObjectRepository _repository;//访问数据库
private readonly IFormDesignOptionsRepository _designOptionsRepository;
[ActivatorUtilitiesConstructor]
public FormCollectionObjectService(
IFormCollectionObjectRepository dbRepository,
IHttpContextAccessor httpContextAccessor,
IFormDesignOptionsRepository designOptionsRepository
)
: base(dbRepository)
{
_httpContextAccessor = httpContextAccessor;
_repository = dbRepository;
_designOptionsRepository = designOptionsRepository;
}
public override WebResponseContent Export(PageDataOptions pageData)
{
string path = null;
string fileName = null;
WebResponseContent webResponse = new WebResponseContent();
ExportOnExecuting = (List<FormCollectionObject> list, List<string> columns) =>
{
var formId = list[0].FormId;
var data = _designOptionsRepository.FindAsIQueryable(x => x.FormId == formId)
.Select(s => new { s.Title, s.FormConfig }).FirstOrDefault();
try
{
List<FormOptions> formObj = data.FormConfig.DeserializeObject<List<FormOptions>>();
List<Dictionary<string, object>> listDic = new List<Dictionary<string, object>>();
foreach (var item in list)
{
Dictionary<string, object> dic = new Dictionary<string, object>();
var formData = item.FormData.DeserializeObject<Dictionary<string, string>>();
dic.Add("标题", data.Title);
dic.Add("提交人", item.Creator);
dic.Add("提交时间", item.CreateDate.ToString("yyyy-MM-dd HH:mm:sss"));
foreach (var obj in formObj)
{
dic.Add(obj.Title, formData.Where(x => x.Key == obj.Field).Select(s => s.Value).FirstOrDefault());
}
listDic.Add(dic);
}
fileName = data.Title + ".xlsx";
path = EPPlusHelper.ExportGeneralExcel(listDic, fileName);
}
catch (Exception ex)
{
Logger.Error($"解析表单出错:{data.Title},表单配置:{data.FormConfig},{ex.Message}");
return webResponse.Error("获取表单出错");
}
webResponse.Code = "-1";
return webResponse.OK(null, path.EncryptDES(AppSetting.Secret.ExportFile));
};
return base.Export(pageData);
}
}
public class FormOptions
{
public string Field { get; set; }
public string Title { get; set; }
public string Type { get; set; }
}
}

View File

@@ -0,0 +1,46 @@
/*
*所有关于FormDesignOptions类的业务代码应在此处编写
*可使用repository.调用常用方法获取EF/Dapper等信息
*如果需要事务请使用repository.DbContextBeginTransaction
*也可使用DBServerProvider.手动获取数据库相关信息
*用户信息、权限、角色等使用UserContext.Current操作
*FormDesignOptionsService对增、删、改查、导入、导出、审核业务代码扩展参照ServiceFunFilter
*/
using VolPro.Core.BaseProvider;
using VolPro.Core.Extensions.AutofacManager;
using VolPro.Entity.DomainModels;
using System.Linq;
using VolPro.Core.Utilities;
using System.Linq.Expressions;
using VolPro.Core.Extensions;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.AspNetCore.Http;
using VolPro.Sys.IRepositories;
namespace VolPro.Sys.Services
{
public partial class FormDesignOptionsService
{
private readonly IHttpContextAccessor _httpContextAccessor;
private readonly IFormDesignOptionsRepository _repository;//访问数据库
[ActivatorUtilitiesConstructor]
public FormDesignOptionsService(
IFormDesignOptionsRepository dbRepository,
IHttpContextAccessor httpContextAccessor
)
: base(dbRepository)
{
_httpContextAccessor = httpContextAccessor;
_repository = dbRepository;
//多租户会用到这init代码其他情况可以不用
//base.Init(dbRepository);
}
public override PageGridData<FormDesignOptions> GetPageData(PageDataOptions options)
{
return base.GetPageData(options);
}
}
}

View File

@@ -0,0 +1,39 @@
/*
*所有关于Sys_FormWorkFlowApplyData类的业务代码应在此处编写
*可使用repository.调用常用方法获取EF/Dapper等信息
*如果需要事务请使用repository.DbContextBeginTransaction
*也可使用DBServerProvider.手动获取数据库相关信息
*用户信息、权限、角色等使用UserContext.Current操作
*Sys_FormWorkFlowApplyDataService对增、删、改查、导入、导出、审核业务代码扩展参照ServiceFunFilter
*/
using VolPro.Core.BaseProvider;
using VolPro.Core.Extensions.AutofacManager;
using VolPro.Entity.DomainModels;
using System.Linq;
using VolPro.Core.Utilities;
using System.Linq.Expressions;
using VolPro.Core.Extensions;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.AspNetCore.Http;
using VolPro.Sys.IRepositories;
namespace VolPro.Sys.Services
{
public partial class Sys_FormWorkFlowApplyDataService
{
private readonly IHttpContextAccessor _httpContextAccessor;
private readonly ISys_FormWorkFlowApplyDataRepository _repository;//访问数据库
[ActivatorUtilitiesConstructor]
public Sys_FormWorkFlowApplyDataService(
ISys_FormWorkFlowApplyDataRepository dbRepository,
IHttpContextAccessor httpContextAccessor
)
: base(dbRepository)
{
_httpContextAccessor = httpContextAccessor;
_repository = dbRepository;
}
}
}

View File

@@ -0,0 +1,162 @@
/*
*所有关于Sys_FormWorkFlowApply类的业务代码应在此处编写
*可使用repository.调用常用方法获取EF/Dapper等信息
*如果需要事务请使用repository.DbContextBeginTransaction
*也可使用DBServerProvider.手动获取数据库相关信息
*用户信息、权限、角色等使用UserContext.Current操作
*Sys_FormWorkFlowApplyService对增、删、改查、导入、导出、审核业务代码扩展参照ServiceFunFilter
*/
using Microsoft.AspNetCore.Http;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.DependencyInjection;
using SqlSugar;
using System.Linq;
using System.Linq.Expressions;
using VolPro.Core.BaseProvider;
using VolPro.Core.Extensions;
using VolPro.Core.Extensions.AutofacManager;
using VolPro.Core.ManageUser;
using VolPro.Core.Utilities;
using VolPro.Core.WorkFlow;
using VolPro.Entity.DomainModels;
using VolPro.Sys.IRepositories;
namespace VolPro.Sys.Services
{
public partial class Sys_FormWorkFlowApplyService
{
private readonly IHttpContextAccessor _httpContextAccessor;
private readonly ISys_FormWorkFlowApplyRepository _repository;//访问数据库
private readonly ISys_FormWorkFlowApplyStepRepository _stepRepository;//访问数据库
[ActivatorUtilitiesConstructor]
public Sys_FormWorkFlowApplyService(
ISys_FormWorkFlowApplyRepository dbRepository,
IHttpContextAccessor httpContextAccessor,
ISys_FormWorkFlowApplyStepRepository stepRepository
)
: base(dbRepository)
{
_httpContextAccessor = httpContextAccessor;
_stepRepository = stepRepository;
_repository = dbRepository;
}
private ISugarQueryable<Sys_FormWorkFlowApply> GetAuditQuery(ISugarQueryable<Sys_FormWorkFlowApply> queryable, bool all = false)
{
var user = UserContext.Current.UserInfo;
var deptIds = user.DeptIds.Select(s => s.ToString());
var roleIds = user.RoleIds.Select(s => s.ToString());
//显示当前用户的全部数据
if (all)
{
queryable = queryable.Where(x =>
SqlFunc.Subqueryable<Sys_FormWorkFlowApplyStep>().Where(c =>
((c.StepType == (int)AuditType. && c.StepValue == user.User_Id.ToString()) ||
(c.StepType == (int)AuditType. && roleIds.Contains(c.StepValue)) ||
(c.StepType == (int)AuditType. && deptIds.Contains(c.StepValue)))
&& x.FormWorkFlowApply_Id == c.FormWorkFlowApply_Id
&& (x.CreateID == user.User_Id || x.CurrentStepId == c.StepId || c.AuditId == user.User_Id)
).Any());
return queryable;
}
string uid = user.User_Id.ToString();
//待审核、审批中的数据
queryable = queryable.Where(x =>
SqlFunc.Subqueryable<Sys_FormWorkFlowApplyStep>().Where(c =>
(c.StepType == (int)AuditType. && c.StepValue == uid ||
(c.StepType == (int)AuditType. && roleIds.Contains(c.StepValue)) ||
(c.StepType == (int)AuditType. && deptIds.Contains(c.StepValue)))
&& x.FormWorkFlowApply_Id == c.FormWorkFlowApply_Id
&& x.CurrentStepId == c.StepId && (c.AuditStatus == null || c.AuditStatus == 0)
).Any());
queryable = queryable.Where(x => x.AuditStatus == (int)AuditStatus. || x.AuditStatus == (int)AuditStatus.);
return queryable;
}
public override PageGridData<Sys_FormWorkFlowApply> GetPageData(PageDataOptions options)
{
var user = UserContext.Current.UserInfo;
QueryRelativeExpression = (ISugarQueryable<Sys_FormWorkFlowApply> queryable) =>
{
int value = options.Value.GetInt();
switch (value)
{
//我的提交
case 50:
queryable = queryable.Where(x => x.CreateID == UserContext.Current.UserId);
break;
//我的审核
case 40:
queryable = queryable.Where(x => SqlFunc.Subqueryable<Sys_FormWorkFlowApplyStep>()
.Where(c => c.AuditId == user.User_Id && x.FormWorkFlowApply_Id == c.FormWorkFlowApply_Id).Any());
break;
//抄送我的
case -2:
var deptIds = user.DeptIds.Select(s => s.ToString());
var roleIds = user.RoleIds.Select(s => s.ToString());
string uid = user.User_Id.ToString();
//待审核、审批中的数据
queryable = queryable.Where(x =>
SqlFunc.Subqueryable<Sys_FormWorkFlowApplyStep>().Where(c =>
(c.StepType == (int)AuditType. && c.StepValue == uid ||
(c.StepType == (int)AuditType. && roleIds.Contains(c.StepValue)) ||
(c.StepType == (int)AuditType. && deptIds.Contains(c.StepValue)))
&& x.FormWorkFlowApply_Id == c.FormWorkFlowApply_Id
&& c.StepAttrType == StepType.cc.ToString()
&& SqlFunc.Subqueryable<Sys_FormWorkFlowApplyStep>().Where(a => c.ParentId == a.StepId && x.FormWorkFlowApply_Id == a.FormWorkFlowApply_Id && a.AuditStatus == 1).Any()
).Any());
break;
case (int)AuditStatus.:
case (int)AuditStatus.:
queryable = GetAuditQuery(queryable);
break;
case (int)AuditStatus.:
case (int)AuditStatus.:
case (int)AuditStatus.:
queryable = queryable.Where(x => SqlFunc.Subqueryable<Sys_FormWorkFlowApplyStep>()
.Where(c => c.AuditId == user.User_Id && x.FormWorkFlowApply_Id == c.FormWorkFlowApply_Id).Any());
if (value == (int)AuditStatus.)
{
queryable = queryable.Where(x => x.AuditStatus == (int)AuditStatus.);
}
else if (value == (int)AuditStatus.)
{
queryable = queryable.Where(x => x.AuditStatus == (int)AuditStatus.);
}
else
{
queryable = queryable.Where(x => x.AuditStatus == (int)AuditStatus.);
}
break;
default:
break;
}
queryable = queryable.Where(x => (x.AuditStatus != (int)AuditStatus.稿 && x.AuditStatus != (int)AuditStatus.));
if (value == -1 && !UserContext.Current.IsSuperAdmin)
{
queryable = GetAuditQuery(queryable, true);
}
return queryable;
};
//QueryRelativeExpression = (ISugarQueryable<Sys_WorkFlowTable> queryable) =>
//{
// var user = UserContext.Current.UserInfo;
// //显示当前用户需要审批的数据
// var deptIds = user.DeptIds.Select(s => s.ToString());
// queryable = queryable.Where(c =>
// SqlFunc.Subqueryable<Sys_WorkFlowTableStep>()
// .Where(x => c.FormWorkFlowApply_Id == x.FormWorkFlowApply_Id
// && ((x.StepType == (int)AuditType.用户审批 && x.StepValue == user.User_Id.ToString())
// || (x.StepType == (int)AuditType.角色审批 && user.RoleIds.Select(s => s.ToString()).Contains(x.StepValue))
// || (x.StepType == (int)AuditType.部门审批 && deptIds.Contains(x.StepValue)))
// )
// .Any());
// queryable = queryable.Where(x => (x.AuditStatus != (int)AuditStatus.草稿 && x.AuditStatus != (int)AuditStatus.待提交));
// return queryable;
//};
// }
return base.GetPageData(options);
}
}
}

View File

@@ -0,0 +1,39 @@
/*
*所有关于Sys_FormWorkFlowApplyStep类的业务代码应在此处编写
*可使用repository.调用常用方法获取EF/Dapper等信息
*如果需要事务请使用repository.DbContextBeginTransaction
*也可使用DBServerProvider.手动获取数据库相关信息
*用户信息、权限、角色等使用UserContext.Current操作
*Sys_FormWorkFlowApplyStepService对增、删、改查、导入、导出、审核业务代码扩展参照ServiceFunFilter
*/
using VolPro.Core.BaseProvider;
using VolPro.Core.Extensions.AutofacManager;
using VolPro.Entity.DomainModels;
using System.Linq;
using VolPro.Core.Utilities;
using System.Linq.Expressions;
using VolPro.Core.Extensions;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.AspNetCore.Http;
using VolPro.Sys.IRepositories;
namespace VolPro.Sys.Services
{
public partial class Sys_FormWorkFlowApplyStepService
{
private readonly IHttpContextAccessor _httpContextAccessor;
private readonly ISys_FormWorkFlowApplyStepRepository _repository;//访问数据库
[ActivatorUtilitiesConstructor]
public Sys_FormWorkFlowApplyStepService(
ISys_FormWorkFlowApplyStepRepository dbRepository,
IHttpContextAccessor httpContextAccessor
)
: base(dbRepository)
{
_httpContextAccessor = httpContextAccessor;
_repository = dbRepository;
}
}
}

View File

@@ -0,0 +1,39 @@
/*
*所有关于Sys_FormWorkFlowAuditLog类的业务代码应在此处编写
*可使用repository.调用常用方法获取EF/Dapper等信息
*如果需要事务请使用repository.DbContextBeginTransaction
*也可使用DBServerProvider.手动获取数据库相关信息
*用户信息、权限、角色等使用UserContext.Current操作
*Sys_FormWorkFlowAuditLogService对增、删、改查、导入、导出、审核业务代码扩展参照ServiceFunFilter
*/
using VolPro.Core.BaseProvider;
using VolPro.Core.Extensions.AutofacManager;
using VolPro.Entity.DomainModels;
using System.Linq;
using VolPro.Core.Utilities;
using System.Linq.Expressions;
using VolPro.Core.Extensions;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.AspNetCore.Http;
using VolPro.Sys.IRepositories;
namespace VolPro.Sys.Services
{
public partial class Sys_FormWorkFlowAuditLogService
{
private readonly IHttpContextAccessor _httpContextAccessor;
private readonly ISys_FormWorkFlowAuditLogRepository _repository;//访问数据库
[ActivatorUtilitiesConstructor]
public Sys_FormWorkFlowAuditLogService(
ISys_FormWorkFlowAuditLogRepository dbRepository,
IHttpContextAccessor httpContextAccessor
)
: base(dbRepository)
{
_httpContextAccessor = httpContextAccessor;
_repository = dbRepository;
}
}
}

View File

@@ -0,0 +1,130 @@
/*
*所有关于Sys_FormWorkFlow类的业务代码应在此处编写
*可使用repository.调用常用方法获取EF/Dapper等信息
*如果需要事务请使用repository.DbContextBeginTransaction
*也可使用DBServerProvider.手动获取数据库相关信息
*用户信息、权限、角色等使用UserContext.Current操作
*Sys_FormWorkFlowService对增、删、改查、导入、导出、审核业务代码扩展参照ServiceFunFilter
*/
using Microsoft.AspNetCore.Http;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.DependencyInjection;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Net;
using VolPro.Core.BaseProvider;
using VolPro.Core.Extensions;
using VolPro.Core.Extensions.AutofacManager;
using VolPro.Core.ManageUser;
using VolPro.Core.Utilities;
using VolPro.Core.WorkFlow;
using VolPro.Entity.DomainModels;
using VolPro.Sys.IRepositories;
namespace VolPro.Sys.Services
{
public partial class Sys_FormWorkFlowService
{
private readonly IHttpContextAccessor _httpContextAccessor;
private readonly ISys_FormWorkFlowRepository _repository;//访问数据库
private readonly ISys_FormWorkFlowStepRepository _stepRepository;//访问数据库
[ActivatorUtilitiesConstructor]
public Sys_FormWorkFlowService(
ISys_FormWorkFlowRepository dbRepository,
ISys_FormWorkFlowStepRepository stepRepository,
IHttpContextAccessor httpContextAccessor
)
: base(dbRepository)
{
_httpContextAccessor = httpContextAccessor;
_repository = dbRepository;
_stepRepository = stepRepository;
}
WebResponseContent webResponse = new WebResponseContent();
public override WebResponseContent Add(SaveModel saveDataModel)
{
AddOnExecuting = (Sys_FormWorkFlow workFlow, object list) =>
{
workFlow.DbServiceId = UserContext.CurrentServiceId;
return webResponse.OK();
};
return base.Add(saveDataModel);
}
List<Sys_FormWorkFlowStep> add;
List<Sys_FormWorkFlowStep> update;
public override WebResponseContent Update(SaveModel saveModel)
{
if (saveModel.Extra == null)
{
return base.Update(saveModel);
}
Sys_FormWorkFlow flow = null;
UpdateOnExecuting = (Sys_FormWorkFlow workFlow, object addList, object updateList, List<object> delKeys) =>
{
flow = workFlow;
//新增的明细
add = addList as List<Sys_FormWorkFlowStep>;
var stepsClone = add.Serialize().DeserializeObject<List<Sys_FormWorkFlowStep>>();
add.Clear();
var steps = _stepRepository.FindAsIQueryable(x => x.FormWorkFlow_Id == workFlow.FormWorkFlow_Id)
.Select(s => new { s.FormWorkStepFlow_Id, s.StepId })
.ToList();
//删除的节点
var delIds = steps.Where(x => !stepsClone.Any(c => c.StepId == x.StepId))
.Select(s => s.FormWorkStepFlow_Id).ToList();
delKeys.AddRange(delIds.Select(s => s as object));
//新增的节点
var newSteps = stepsClone.Where(x => !steps.Any(c => c.StepId == x.StepId))
.ToList();
foreach (var item in newSteps)
{
item.FormWorkStepFlow_Id = Guid.NewGuid();
}
add.AddRange(newSteps);
update = updateList as List<Sys_FormWorkFlowStep>;
//修改的节点
var updateSteps = stepsClone.Where(x => steps.Any(c => c.StepId == x.StepId))
.ToList();
update.AddRange(updateSteps);
updateSteps.ForEach(x =>
{
x.FormWorkStepFlow_Id = steps.Where(c => c.StepId == x.StepId).Select(s => s.FormWorkStepFlow_Id).FirstOrDefault();
foreach (var item in saveModel.DetailData)
{
if (item["StepId"].ToString() == x.StepId)
{
item["FormWorkFlow_Id"] = workFlow.FormWorkFlow_Id;
item["FormWorkStepFlow_Id"] = x.FormWorkStepFlow_Id;
}
}
});
return webResponse.OK();
};
UpdateOnExecuted = (Sys_FormWorkFlow workFlow, object addList, object updateList, List<object> delKeys) =>
{
repository.UpdateRange((List<Sys_FormWorkFlowStep>)updateList);
_stepRepository.DeleteWithKeys(delKeys.ToArray());
repository.SaveChanges();
// WorkFlowManager.UpdateFlowData(workFlow, (List<Sys_WorkFlowStep>)addList);
return webResponse.OK();
};
webResponse = base.Update(saveModel);
if (webResponse.Status)
{
//flow = repository.FindAsIQueryable(x => x.FormWorkFlow_Id == flow.FormWorkFlow_Id).Include(x => x.Sys_FormWorkFlowStep).FirstOrDefault();
//webResponse = WorkFlowContainer.Instance.AddTable(flow, flow.Sys_FormWorkFlowStep);
}
return webResponse;
}
}
}

View File

@@ -0,0 +1,39 @@
/*
*所有关于Sys_FormWorkFlowStep类的业务代码应在此处编写
*可使用repository.调用常用方法获取EF/Dapper等信息
*如果需要事务请使用repository.DbContextBeginTransaction
*也可使用DBServerProvider.手动获取数据库相关信息
*用户信息、权限、角色等使用UserContext.Current操作
*Sys_FormWorkFlowStepService对增、删、改查、导入、导出、审核业务代码扩展参照ServiceFunFilter
*/
using VolPro.Core.BaseProvider;
using VolPro.Core.Extensions.AutofacManager;
using VolPro.Entity.DomainModels;
using System.Linq;
using VolPro.Core.Utilities;
using System.Linq.Expressions;
using VolPro.Core.Extensions;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.AspNetCore.Http;
using VolPro.Sys.IRepositories;
namespace VolPro.Sys.Services
{
public partial class Sys_FormWorkFlowStepService
{
private readonly IHttpContextAccessor _httpContextAccessor;
private readonly ISys_FormWorkFlowStepRepository _repository;//访问数据库
[ActivatorUtilitiesConstructor]
public Sys_FormWorkFlowStepService(
ISys_FormWorkFlowStepRepository dbRepository,
IHttpContextAccessor httpContextAccessor
)
: base(dbRepository)
{
_httpContextAccessor = httpContextAccessor;
_repository = dbRepository;
}
}
}

View File

@@ -0,0 +1,22 @@
/*
*Authorjxx
*Contact283591387@qq.com
*代码由框架生成,此处任何更改都可能导致被代码生成器覆盖
*所有业务编写全部应在Partial文件夹下Sys_FormWorkFlowApplyDataService与ISys_FormWorkFlowApplyDataService中编写
*/
using VolPro.Sys.IRepositories;
using VolPro.Sys.IServices;
using VolPro.Core.BaseProvider;
using VolPro.Core.Extensions.AutofacManager;
using VolPro.Entity.DomainModels;
namespace VolPro.Sys.Services
{
public partial class Sys_FormWorkFlowApplyDataService : ServiceBase<Sys_FormWorkFlowApplyData, ISys_FormWorkFlowApplyDataRepository>
, ISys_FormWorkFlowApplyDataService, IDependency
{
public static ISys_FormWorkFlowApplyDataService Instance
{
get { return AutofacContainerModule.GetService<ISys_FormWorkFlowApplyDataService>(); } }
}
}

View File

@@ -0,0 +1,22 @@
/*
*Authorjxx
*Contact283591387@qq.com
*代码由框架生成,此处任何更改都可能导致被代码生成器覆盖
*所有业务编写全部应在Partial文件夹下Sys_FormWorkFlowApplyService与ISys_FormWorkFlowApplyService中编写
*/
using VolPro.Sys.IRepositories;
using VolPro.Sys.IServices;
using VolPro.Core.BaseProvider;
using VolPro.Core.Extensions.AutofacManager;
using VolPro.Entity.DomainModels;
namespace VolPro.Sys.Services
{
public partial class Sys_FormWorkFlowApplyService : ServiceBase<Sys_FormWorkFlowApply, ISys_FormWorkFlowApplyRepository>
, ISys_FormWorkFlowApplyService, IDependency
{
public static ISys_FormWorkFlowApplyService Instance
{
get { return AutofacContainerModule.GetService<ISys_FormWorkFlowApplyService>(); } }
}
}

View File

@@ -0,0 +1,22 @@
/*
*Authorjxx
*Contact283591387@qq.com
*代码由框架生成,此处任何更改都可能导致被代码生成器覆盖
*所有业务编写全部应在Partial文件夹下Sys_FormWorkFlowApplyStepService与ISys_FormWorkFlowApplyStepService中编写
*/
using VolPro.Sys.IRepositories;
using VolPro.Sys.IServices;
using VolPro.Core.BaseProvider;
using VolPro.Core.Extensions.AutofacManager;
using VolPro.Entity.DomainModels;
namespace VolPro.Sys.Services
{
public partial class Sys_FormWorkFlowApplyStepService : ServiceBase<Sys_FormWorkFlowApplyStep, ISys_FormWorkFlowApplyStepRepository>
, ISys_FormWorkFlowApplyStepService, IDependency
{
public static ISys_FormWorkFlowApplyStepService Instance
{
get { return AutofacContainerModule.GetService<ISys_FormWorkFlowApplyStepService>(); } }
}
}

View File

@@ -0,0 +1,22 @@
/*
*Authorjxx
*Contact283591387@qq.com
*代码由框架生成,此处任何更改都可能导致被代码生成器覆盖
*所有业务编写全部应在Partial文件夹下Sys_FormWorkFlowAuditLogService与ISys_FormWorkFlowAuditLogService中编写
*/
using VolPro.Sys.IRepositories;
using VolPro.Sys.IServices;
using VolPro.Core.BaseProvider;
using VolPro.Core.Extensions.AutofacManager;
using VolPro.Entity.DomainModels;
namespace VolPro.Sys.Services
{
public partial class Sys_FormWorkFlowAuditLogService : ServiceBase<Sys_FormWorkFlowAuditLog, ISys_FormWorkFlowAuditLogRepository>
, ISys_FormWorkFlowAuditLogService, IDependency
{
public static ISys_FormWorkFlowAuditLogService Instance
{
get { return AutofacContainerModule.GetService<ISys_FormWorkFlowAuditLogService>(); } }
}
}

View File

@@ -0,0 +1,22 @@
/*
*Authorjxx
*Contact283591387@qq.com
*代码由框架生成,此处任何更改都可能导致被代码生成器覆盖
*所有业务编写全部应在Partial文件夹下Sys_FormWorkFlowService与ISys_FormWorkFlowService中编写
*/
using VolPro.Sys.IRepositories;
using VolPro.Sys.IServices;
using VolPro.Core.BaseProvider;
using VolPro.Core.Extensions.AutofacManager;
using VolPro.Entity.DomainModels;
namespace VolPro.Sys.Services
{
public partial class Sys_FormWorkFlowService : ServiceBase<Sys_FormWorkFlow, ISys_FormWorkFlowRepository>
, ISys_FormWorkFlowService, IDependency
{
public static ISys_FormWorkFlowService Instance
{
get { return AutofacContainerModule.GetService<ISys_FormWorkFlowService>(); } }
}
}

View File

@@ -0,0 +1,22 @@
/*
*Authorjxx
*Contact283591387@qq.com
*代码由框架生成,此处任何更改都可能导致被代码生成器覆盖
*所有业务编写全部应在Partial文件夹下Sys_FormWorkFlowStepService与ISys_FormWorkFlowStepService中编写
*/
using VolPro.Sys.IRepositories;
using VolPro.Sys.IServices;
using VolPro.Core.BaseProvider;
using VolPro.Core.Extensions.AutofacManager;
using VolPro.Entity.DomainModels;
namespace VolPro.Sys.Services
{
public partial class Sys_FormWorkFlowStepService : ServiceBase<Sys_FormWorkFlowStep, ISys_FormWorkFlowStepRepository>
, ISys_FormWorkFlowStepService, IDependency
{
public static ISys_FormWorkFlowStepService Instance
{
get { return AutofacContainerModule.GetService<ISys_FormWorkFlowStepService>(); } }
}
}