diff --git a/ZR.Common/Cache/CacheHelper.cs b/Infrastructure/Cache/CacheHelper.cs similarity index 100% rename from ZR.Common/Cache/CacheHelper.cs rename to Infrastructure/Cache/CacheHelper.cs diff --git a/ZR.Common/Cache/RedisServer.cs b/Infrastructure/Cache/RedisServer.cs similarity index 100% rename from ZR.Common/Cache/RedisServer.cs rename to Infrastructure/Cache/RedisServer.cs diff --git a/ZR.Admin.WebApi/Controllers/BaseController.cs b/Infrastructure/Controllers/BaseController.cs similarity index 96% rename from ZR.Admin.WebApi/Controllers/BaseController.cs rename to Infrastructure/Controllers/BaseController.cs index bf44474..0332d49 100644 --- a/ZR.Admin.WebApi/Controllers/BaseController.cs +++ b/Infrastructure/Controllers/BaseController.cs @@ -1,11 +1,16 @@ -using Microsoft.AspNetCore.Mvc; +using Infrastructure.Extensions; +using Infrastructure.Model; +using Microsoft.AspNetCore.Hosting; +using Microsoft.AspNetCore.Mvc; using MiniExcelLibs; using Newtonsoft.Json; using Newtonsoft.Json.Serialization; +using System; +using System.Collections.Generic; +using System.IO; using System.Web; -using Io = System.IO; -namespace ZR.Admin.WebApi.Controllers +namespace Infrastructure.Controllers { public class BaseController : ControllerBase { @@ -60,7 +65,7 @@ namespace ZR.Admin.WebApi.Controllers { throw new CustomException(fileName + "文件不存在"); } - var stream = Io.File.OpenRead(path); //创建文件流 + var stream = System.IO.File.OpenRead(path); //创建文件流 Response.Headers.Add("Access-Control-Expose-Headers", "Content-Disposition"); return File(stream, "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", HttpUtility.UrlEncode(fileName)); diff --git a/Infrastructure/JsonConverterUtil.cs b/Infrastructure/Converter/JsonConverterUtil.cs similarity index 97% rename from Infrastructure/JsonConverterUtil.cs rename to Infrastructure/Converter/JsonConverterUtil.cs index 8897a67..bd32f10 100644 --- a/Infrastructure/JsonConverterUtil.cs +++ b/Infrastructure/Converter/JsonConverterUtil.cs @@ -2,7 +2,7 @@ using System.Text.Json; using System.Text.Json.Serialization; -namespace Infrastructure +namespace Infrastructure.Converter { public class JsonConverterUtil { diff --git a/Infrastructure/StringConverter.cs b/Infrastructure/Converter/StringConverter.cs similarity index 88% rename from Infrastructure/StringConverter.cs rename to Infrastructure/Converter/StringConverter.cs index c057b2f..0a0a05a 100644 --- a/Infrastructure/StringConverter.cs +++ b/Infrastructure/Converter/StringConverter.cs @@ -4,7 +4,7 @@ using System.Linq; using System.Text; using System.Text.Json; -namespace Infrastructure +namespace Infrastructure.Converter { /// /// Json任何类型读取到字符串属性 @@ -33,10 +33,10 @@ namespace Infrastructure writer.WriteStringValue(value); } /// - /// 非字符类型,返回原生内容 - /// - /// - /// + /// 非字符类型,返回原生内容 + /// + /// + /// private static string GetRawPropertyValue(Utf8JsonReader jsonReader) { ReadOnlySpan utf8Bytes = jsonReader.HasValueSequence ? diff --git a/Infrastructure/Enums/BusinessType.cs b/Infrastructure/Enums/BusinessType.cs index a4f09e1..1c1d150 100644 --- a/Infrastructure/Enums/BusinessType.cs +++ b/Infrastructure/Enums/BusinessType.cs @@ -54,5 +54,10 @@ /// 清空数据 /// CLEAN = 9, + + /// + /// 下载 + /// + DOWNLOAD = 10, } } diff --git a/ZR.Common/JnHelper.cs b/Infrastructure/Helper/JnHelper.cs similarity index 96% rename from ZR.Common/JnHelper.cs rename to Infrastructure/Helper/JnHelper.cs index 85e326b..5a42e6b 100644 --- a/ZR.Common/JnHelper.cs +++ b/Infrastructure/Helper/JnHelper.cs @@ -2,7 +2,7 @@ using System; using System.IO; -namespace ZR.Common +namespace Infrastructure.Helper { public class JnHelper { diff --git a/Infrastructure/JwtUtil.cs b/Infrastructure/JwtUtil.cs index f8787f7..bf6a71d 100644 --- a/Infrastructure/JwtUtil.cs +++ b/Infrastructure/JwtUtil.cs @@ -1,6 +1,5 @@ using Infrastructure.Extensions; using Infrastructure.Model; -using Infrastructure.WebExtensins; using Microsoft.AspNetCore.Http; using Microsoft.IdentityModel.Tokens; using Newtonsoft.Json; diff --git a/Infrastructure/Model/OptionsSetting.cs b/Infrastructure/Model/OptionsSetting.cs index 50097a6..552b781 100644 --- a/Infrastructure/Model/OptionsSetting.cs +++ b/Infrastructure/Model/OptionsSetting.cs @@ -15,6 +15,10 @@ namespace Infrastructure.Model /// 是否演示模式 /// public bool DemoMode { get; set; } + /// + /// 初始化db + /// + public bool InitDb { get; set; } public MailOptions MailOptions { get; set; } public Upload Upload { get; set; } public ALIYUN_OSS ALIYUN_OSS { get; set; } diff --git a/Infrastructure/WebExtensins/AppServiceExtensions.cs b/Infrastructure/WebExtensions/AppServiceExtensions.cs similarity index 100% rename from Infrastructure/WebExtensins/AppServiceExtensions.cs rename to Infrastructure/WebExtensions/AppServiceExtensions.cs diff --git a/ZR.Admin.WebApi/Extensions/CorsExtension.cs b/Infrastructure/WebExtensions/CorsExtension.cs similarity index 81% rename from ZR.Admin.WebApi/Extensions/CorsExtension.cs rename to Infrastructure/WebExtensions/CorsExtension.cs index cb3b1c4..37fc224 100644 --- a/ZR.Admin.WebApi/Extensions/CorsExtension.cs +++ b/Infrastructure/WebExtensions/CorsExtension.cs @@ -1,5 +1,12 @@ -namespace ZR.Admin.WebApi.Extensions +using Microsoft.Extensions.Configuration; +using Microsoft.Extensions.DependencyInjection; +using System; + +namespace Infrastructure { + /// + /// 跨域扩展 + /// public static class CorsExtension { /// diff --git a/ZR.Admin.WebApi/Extensions/EntityExtension.cs b/Infrastructure/WebExtensions/EntityExtension.cs similarity index 93% rename from ZR.Admin.WebApi/Extensions/EntityExtension.cs rename to Infrastructure/WebExtensions/EntityExtension.cs index 1a96758..61c9a77 100644 --- a/ZR.Admin.WebApi/Extensions/EntityExtension.cs +++ b/Infrastructure/WebExtensions/EntityExtension.cs @@ -1,7 +1,10 @@  +using Infrastructure.Extensions; +using Microsoft.AspNetCore.Http; +using System; using System.Reflection; -namespace ZR.Admin.WebApi.Extensions +namespace Infrastructure { public static class EntityExtension { diff --git a/Infrastructure/WebExtensins/HttpContextExtension.cs b/Infrastructure/WebExtensions/HttpContextExtension.cs similarity index 96% rename from Infrastructure/WebExtensins/HttpContextExtension.cs rename to Infrastructure/WebExtensions/HttpContextExtension.cs index e2730b3..23efa03 100644 --- a/Infrastructure/WebExtensins/HttpContextExtension.cs +++ b/Infrastructure/WebExtensions/HttpContextExtension.cs @@ -1,5 +1,4 @@ -using Infrastructure.Extensions; -using IPTools.Core; +using IPTools.Core; using Microsoft.AspNetCore.Http; using System; using System.Collections.Generic; @@ -10,7 +9,7 @@ using System.Text; using System.Text.RegularExpressions; using UAParser; -namespace Infrastructure.WebExtensins +namespace Infrastructure.Extensions { /// /// HttpContext扩展类 @@ -220,7 +219,8 @@ namespace Infrastructure.WebExtensins if (HttpMethods.IsPost(reqMethod) || HttpMethods.IsPut(reqMethod) || HttpMethods.IsDelete(reqMethod)) { param = context.GetBody(); - param = PwdRep().Replace(param, "***"); + string regex = "(?<=\"password\":\")[^\",]*"; + param = Regex.Replace(param, regex, "***"); } if (param.IsEmpty()) { @@ -228,9 +228,6 @@ namespace Infrastructure.WebExtensins } return param; } - - [GeneratedRegex("(?<=\"password\":\")[^\",]*")] - private static partial Regex PwdRep(); } } diff --git a/ZR.Admin.WebApi/Extensions/IPRateExtension.cs b/Infrastructure/WebExtensions/IPRateExtension.cs similarity index 88% rename from ZR.Admin.WebApi/Extensions/IPRateExtension.cs rename to Infrastructure/WebExtensions/IPRateExtension.cs index 8fabf81..2eccadf 100644 --- a/ZR.Admin.WebApi/Extensions/IPRateExtension.cs +++ b/Infrastructure/WebExtensions/IPRateExtension.cs @@ -1,6 +1,9 @@ using AspNetCoreRateLimit; +using Microsoft.Extensions.Configuration; +using Microsoft.Extensions.DependencyInjection; +using System; -namespace ZR.Admin.WebApi.Extensions +namespace ZR.Infrastructure.WebExtensions { public static class IPRateExtension { diff --git a/ZR.Admin.WebApi/Extensions/LogoExtension.cs b/Infrastructure/WebExtensions/LogoExtension.cs similarity index 86% rename from ZR.Admin.WebApi/Extensions/LogoExtension.cs rename to Infrastructure/WebExtensions/LogoExtension.cs index f08181f..c424b42 100644 --- a/ZR.Admin.WebApi/Extensions/LogoExtension.cs +++ b/Infrastructure/WebExtensions/LogoExtension.cs @@ -1,4 +1,7 @@ -using JinianNet.JNTemplate; +using Infrastructure.Helper; +using JinianNet.JNTemplate; +using Microsoft.Extensions.DependencyInjection; +using System; namespace Infrastructure { diff --git a/Infrastructure/Infrastructure.csproj b/Infrastructure/ZR.Infrastructure.csproj similarity index 75% rename from Infrastructure/Infrastructure.csproj rename to Infrastructure/ZR.Infrastructure.csproj index 57a874c..f96d4e0 100644 --- a/Infrastructure/Infrastructure.csproj +++ b/Infrastructure/ZR.Infrastructure.csproj @@ -8,18 +8,19 @@ - - - + + + + diff --git a/ZR.Admin.WebApi/Controllers/CommonController.cs b/ZR.Admin.WebApi/Controllers/CommonController.cs index 448896b..c30a4be 100644 --- a/ZR.Admin.WebApi/Controllers/CommonController.cs +++ b/ZR.Admin.WebApi/Controllers/CommonController.cs @@ -1,10 +1,9 @@ -using Infrastructure.Extensions; -using Microsoft.AspNetCore.Mvc; +using Microsoft.AspNetCore.Mvc; using Microsoft.Extensions.Options; using Newtonsoft.Json; -using ZR.Admin.WebApi.Extensions; using ZR.Admin.WebApi.Filters; using ZR.Model.System; +using ZR.Service.IService; using ZR.Service.System; using ZR.Service.System.IService; @@ -14,7 +13,6 @@ namespace ZR.Admin.WebApi.Controllers /// 公共模块 /// [Route("[controller]/[action]")] - [Tags("公共模块Common")] [ApiExplorerSettings(GroupName = "sys")] public class CommonController : BaseController { @@ -23,18 +21,22 @@ namespace ZR.Admin.WebApi.Controllers private IWebHostEnvironment WebHostEnvironment; private ISysFileService SysFileService; + private IHelloService HelloService; + public CommonController( IOptions options, IWebHostEnvironment webHostEnvironment, - ISysFileService fileService) + ISysFileService fileService, + IHelloService helloService) { WebHostEnvironment = webHostEnvironment; SysFileService = fileService; OptionsSetting = options.Value; + HelloService = helloService; } /// - /// hello + /// home /// /// [Route("/")] @@ -45,6 +47,18 @@ namespace ZR.Admin.WebApi.Controllers "如果觉得项目有用,打赏作者喝杯咖啡作为奖励\n☛☛http://www.izhaorui.cn/doc/support.html\n"); } + /// + /// hello + /// + /// + /// + [Route("/hello")] + [HttpGet] + public IActionResult Hello(string name) + { + return Ok(HelloService.SayHello(name)); + } + /// /// 企业消息测试 /// diff --git a/ZR.Admin.WebApi/Controllers/System/ArticleCategoryController.cs b/ZR.Admin.WebApi/Controllers/System/ArticleCategoryController.cs index 92836ca..5a81d8a 100644 --- a/ZR.Admin.WebApi/Controllers/System/ArticleCategoryController.cs +++ b/ZR.Admin.WebApi/Controllers/System/ArticleCategoryController.cs @@ -11,7 +11,6 @@ namespace ZR.Admin.WebApi.Controllers /// 文章目录Controller /// [Route("article/ArticleCategory")] - [Tags("文章目录")] [ApiExplorerSettings(GroupName = "article")] public class ArticleCategoryController : BaseController { diff --git a/ZR.Admin.WebApi/Controllers/System/ArticleController.cs b/ZR.Admin.WebApi/Controllers/System/ArticleController.cs index 55577ef..b111ace 100644 --- a/ZR.Admin.WebApi/Controllers/System/ArticleController.cs +++ b/ZR.Admin.WebApi/Controllers/System/ArticleController.cs @@ -13,7 +13,6 @@ namespace ZR.Admin.WebApi.Controllers /// [Verify] [Route("article")] - [Tags("文章管理")] [ApiExplorerSettings(GroupName = "article")] public class ArticleController : BaseController { @@ -89,7 +88,7 @@ namespace ZR.Admin.WebApi.Controllers var model = response.Adapt(); if (model.IsPublic == 0 && userId != model.UserId) { - return ToResponse(Infrastructure.ResultCode.CUSTOM_ERROR, "访问失败"); + return ToResponse(ResultCode.CUSTOM_ERROR, "访问失败"); } if (model != null) { diff --git a/ZR.Admin.WebApi/Controllers/System/CodeGeneratorController.cs b/ZR.Admin.WebApi/Controllers/System/CodeGeneratorController.cs index f2fa216..61fb659 100644 --- a/ZR.Admin.WebApi/Controllers/System/CodeGeneratorController.cs +++ b/ZR.Admin.WebApi/Controllers/System/CodeGeneratorController.cs @@ -1,5 +1,4 @@ -using Infrastructure.Extensions; -using Microsoft.AspNetCore.Mvc; +using Microsoft.AspNetCore.Mvc; using SqlSugar; using ZR.Admin.WebApi.Extensions; using ZR.Admin.WebApi.Filters; @@ -18,7 +17,6 @@ namespace ZR.Admin.WebApi.Controllers /// [Verify] [Route("tool/gen")] - [Tags("代码生成CodeGenerator")] [ApiExplorerSettings(GroupName = "sys")] public class CodeGeneratorController : BaseController { diff --git a/ZR.Admin.WebApi/Controllers/System/CommonLangController.cs b/ZR.Admin.WebApi/Controllers/System/CommonLangController.cs index ecbcf47..f0a3dc3 100644 --- a/ZR.Admin.WebApi/Controllers/System/CommonLangController.cs +++ b/ZR.Admin.WebApi/Controllers/System/CommonLangController.cs @@ -14,7 +14,6 @@ namespace ZR.Admin.WebApi.Controllers /// [Verify] [Route("system/CommonLang")] - [Tags("多语言配置CommonLang")] [ApiExplorerSettings(GroupName = "sys")] public class CommonLangController : BaseController { diff --git a/ZR.Admin.WebApi/Controllers/System/SysConfigController.cs b/ZR.Admin.WebApi/Controllers/System/SysConfigController.cs index 494eda4..51bae9c 100644 --- a/ZR.Admin.WebApi/Controllers/System/SysConfigController.cs +++ b/ZR.Admin.WebApi/Controllers/System/SysConfigController.cs @@ -14,7 +14,6 @@ namespace ZR.Admin.WebApi.Controllers /// [Verify] [Route("system/config")] - [Tags("系统配置SysConfig")] [ApiExplorerSettings(GroupName = "sys")] public class SysConfigController : BaseController { diff --git a/ZR.Admin.WebApi/Controllers/System/SysDeptController.cs b/ZR.Admin.WebApi/Controllers/System/SysDeptController.cs index 9c52a4b..2b53ac6 100644 --- a/ZR.Admin.WebApi/Controllers/System/SysDeptController.cs +++ b/ZR.Admin.WebApi/Controllers/System/SysDeptController.cs @@ -1,6 +1,5 @@ using Microsoft.AspNetCore.Mvc; using System.Collections; -using ZR.Admin.WebApi.Extensions; using ZR.Admin.WebApi.Filters; using ZR.Model.System; using ZR.Model.System.Dto; @@ -13,7 +12,6 @@ namespace ZR.Admin.WebApi.Controllers.System /// [Verify] [Route("system/dept")] - [Tags("部门管理SysDept")] [ApiExplorerSettings(GroupName = "sys")] public class SysDeptController : BaseController { diff --git a/ZR.Admin.WebApi/Controllers/System/SysDictDataController.cs b/ZR.Admin.WebApi/Controllers/System/SysDictDataController.cs index 4bb7124..05d7dac 100644 --- a/ZR.Admin.WebApi/Controllers/System/SysDictDataController.cs +++ b/ZR.Admin.WebApi/Controllers/System/SysDictDataController.cs @@ -1,5 +1,4 @@ using Microsoft.AspNetCore.Mvc; -using ZR.Admin.WebApi.Extensions; using ZR.Admin.WebApi.Filters; using ZR.Model; using ZR.Model.System; @@ -13,7 +12,6 @@ namespace ZR.Admin.WebApi.Controllers.System /// [Verify] [Route("system/dict/data")] - [Tags("字典数据SysDictData")] [ApiExplorerSettings(GroupName = "sys")] public class SysDictDataController : BaseController { diff --git a/ZR.Admin.WebApi/Controllers/System/SysDictTypeController.cs b/ZR.Admin.WebApi/Controllers/System/SysDictTypeController.cs index 8df1454..a978d22 100644 --- a/ZR.Admin.WebApi/Controllers/System/SysDictTypeController.cs +++ b/ZR.Admin.WebApi/Controllers/System/SysDictTypeController.cs @@ -13,7 +13,6 @@ namespace ZR.Admin.WebApi.Controllers.System /// [Verify] [Route("system/dict/type")] - [Tags("字典数据类型SysDictType")] [ApiExplorerSettings(GroupName = "sys")] public class SysDictTypeController : BaseController { diff --git a/ZR.Admin.WebApi/Controllers/System/SysFileController.cs b/ZR.Admin.WebApi/Controllers/System/SysFileController.cs index 635aa1e..b084c21 100644 --- a/ZR.Admin.WebApi/Controllers/System/SysFileController.cs +++ b/ZR.Admin.WebApi/Controllers/System/SysFileController.cs @@ -12,7 +12,6 @@ namespace ZR.Admin.WebApi.Controllers /// [Verify] [Route("tool/file")] - [Tags(" 文件存储SysFile")] [ApiExplorerSettings(GroupName = "sys")] public class SysFileController : BaseController { diff --git a/ZR.Admin.WebApi/Controllers/System/SysLoginController.cs b/ZR.Admin.WebApi/Controllers/System/SysLoginController.cs index 5321374..7e256cf 100644 --- a/ZR.Admin.WebApi/Controllers/System/SysLoginController.cs +++ b/ZR.Admin.WebApi/Controllers/System/SysLoginController.cs @@ -12,7 +12,6 @@ namespace ZR.Admin.WebApi.Controllers.System /// /// 登录 /// - [Tags("登录SysLogin")] [ApiExplorerSettings(GroupName = "sys")] public class SysLoginController : BaseController { @@ -160,7 +159,7 @@ namespace ZR.Admin.WebApi.Controllers.System /// [HttpPost("/register")] [AllowAnonymous] - [Log(Title = "注册", BusinessType = Infrastructure.Enums.BusinessType.INSERT)] + [Log(Title = "注册", BusinessType = BusinessType.INSERT)] public IActionResult Register([FromBody] RegisterDto dto) { SysConfig config = sysConfigService.GetSysConfigByKey("sys.account.register"); diff --git a/ZR.Admin.WebApi/Controllers/System/SysMenuController.cs b/ZR.Admin.WebApi/Controllers/System/SysMenuController.cs index 73c1e9b..a6cff1f 100644 --- a/ZR.Admin.WebApi/Controllers/System/SysMenuController.cs +++ b/ZR.Admin.WebApi/Controllers/System/SysMenuController.cs @@ -1,5 +1,4 @@ using Microsoft.AspNetCore.Mvc; -using ZR.Admin.WebApi.Extensions; using ZR.Admin.WebApi.Filters; using ZR.Model.System; using ZR.Model.System.Dto; @@ -12,7 +11,6 @@ namespace ZR.Admin.WebApi.Controllers.System /// [Verify] [Route("/system/menu")] - [Tags("菜单管理SysMenu")] [ApiExplorerSettings(GroupName = "sys")] public class SysMenuController : BaseController { diff --git a/ZR.Admin.WebApi/Controllers/System/SysNoticeController.cs b/ZR.Admin.WebApi/Controllers/System/SysNoticeController.cs index cb19c97..b150780 100644 --- a/ZR.Admin.WebApi/Controllers/System/SysNoticeController.cs +++ b/ZR.Admin.WebApi/Controllers/System/SysNoticeController.cs @@ -1,8 +1,6 @@ -using Infrastructure.Constant; -using Microsoft.AspNetCore.Mvc; +using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.SignalR; using SqlSugar; -using ZR.Admin.WebApi.Extensions; using ZR.Admin.WebApi.Filters; using ZR.Admin.WebApi.Hubs; using ZR.Model; @@ -17,7 +15,6 @@ namespace ZR.Admin.WebApi.Controllers.System /// [Verify] [Route("system/notice")] - [Tags("系统通知SysNotice")] [ApiExplorerSettings(GroupName = "sys")] public class SysNoticeController : BaseController { diff --git a/ZR.Admin.WebApi/Controllers/System/SysPostController.cs b/ZR.Admin.WebApi/Controllers/System/SysPostController.cs index cf142be..8e65053 100644 --- a/ZR.Admin.WebApi/Controllers/System/SysPostController.cs +++ b/ZR.Admin.WebApi/Controllers/System/SysPostController.cs @@ -1,7 +1,5 @@ -using Infrastructure.Extensions; -using Microsoft.AspNetCore.Mvc; +using Microsoft.AspNetCore.Mvc; using SqlSugar; -using ZR.Admin.WebApi.Extensions; using ZR.Admin.WebApi.Filters; using ZR.Model; using ZR.Model.System; @@ -14,7 +12,6 @@ namespace ZR.Admin.WebApi.Controllers.System /// [Verify] [Route("system/post")] - [Tags("岗位管理SysPost")] [ApiExplorerSettings(GroupName = "sys")] public class SysPostController : BaseController { diff --git a/ZR.Admin.WebApi/Controllers/System/SysProfileController.cs b/ZR.Admin.WebApi/Controllers/System/SysProfileController.cs index ac6cacd..ca2738a 100644 --- a/ZR.Admin.WebApi/Controllers/System/SysProfileController.cs +++ b/ZR.Admin.WebApi/Controllers/System/SysProfileController.cs @@ -1,5 +1,4 @@ using Microsoft.AspNetCore.Mvc; -using ZR.Admin.WebApi.Extensions; using ZR.Admin.WebApi.Filters; using ZR.Model.System; using ZR.Model.System.Dto; @@ -12,7 +11,6 @@ namespace ZR.Admin.WebApi.Controllers.System /// [Verify] [Route("system/user/profile")] - [Tags("个人中心SysProfile")] [ApiExplorerSettings(GroupName = "sys")] public class SysProfileController : BaseController { diff --git a/ZR.Admin.WebApi/Controllers/System/SysRoleController.cs b/ZR.Admin.WebApi/Controllers/System/SysRoleController.cs index 974ad2d..35954c3 100644 --- a/ZR.Admin.WebApi/Controllers/System/SysRoleController.cs +++ b/ZR.Admin.WebApi/Controllers/System/SysRoleController.cs @@ -1,5 +1,4 @@ using Microsoft.AspNetCore.Mvc; -using ZR.Admin.WebApi.Extensions; using ZR.Admin.WebApi.Filters; using ZR.Model; using ZR.Model.System; @@ -13,7 +12,6 @@ namespace ZR.Admin.WebApi.Controllers.System /// [Verify] [Route("system/role")] - [Tags("角色管理SysRole")] [ApiExplorerSettings(GroupName = "sys")] public class SysRoleController : BaseController { diff --git a/ZR.Admin.WebApi/Controllers/System/SysUserController.cs b/ZR.Admin.WebApi/Controllers/System/SysUserController.cs index 2041414..9242360 100644 --- a/ZR.Admin.WebApi/Controllers/System/SysUserController.cs +++ b/ZR.Admin.WebApi/Controllers/System/SysUserController.cs @@ -14,7 +14,6 @@ namespace ZR.Admin.WebApi.Controllers.System /// [Verify] [Route("system/user")] - [Tags("用户管理SysUser")] [ApiExplorerSettings(GroupName = "sys")] public class SysUserController : BaseController { diff --git a/ZR.Admin.WebApi/Controllers/System/SysUserRoleController.cs b/ZR.Admin.WebApi/Controllers/System/SysUserRoleController.cs index 8640b97..366e1c2 100644 --- a/ZR.Admin.WebApi/Controllers/System/SysUserRoleController.cs +++ b/ZR.Admin.WebApi/Controllers/System/SysUserRoleController.cs @@ -10,7 +10,6 @@ namespace ZR.Admin.WebApi.Controllers.System /// [Verify] [Route("system/userRole")] - [Tags("用户角色管理SysUserRole")] [ApiExplorerSettings(GroupName = "sys")] public class SysUserRoleController : BaseController { @@ -45,7 +44,7 @@ namespace ZR.Admin.WebApi.Controllers.System /// [HttpPost("create")] [ActionPermissionFilter(Permission = "system:roleusers:add")] - [Log(Title = "添加角色用户", BusinessType = Infrastructure.Enums.BusinessType.INSERT)] + [Log(Title = "添加角色用户", BusinessType = BusinessType.INSERT)] public IActionResult Create([FromBody] RoleUsersCreateDto roleUsersCreateDto) { var response = SysUserRoleService.InsertRoleUser(roleUsersCreateDto); @@ -60,7 +59,7 @@ namespace ZR.Admin.WebApi.Controllers.System /// [HttpPost("delete")] [ActionPermissionFilter(Permission = "system:roleusers:remove")] - [Log(Title = "删除角色用户", BusinessType = Infrastructure.Enums.BusinessType.DELETE)] + [Log(Title = "删除角色用户", BusinessType = BusinessType.DELETE)] public IActionResult Delete([FromBody] RoleUsersCreateDto roleUsersCreateDto) { return SUCCESS(SysUserRoleService.DeleteRoleUserByUserIds(roleUsersCreateDto.RoleId, roleUsersCreateDto.UserIds)); diff --git a/ZR.Admin.WebApi/Controllers/System/TasksController.cs b/ZR.Admin.WebApi/Controllers/System/TasksController.cs index 0f14d7a..d1e9ac9 100644 --- a/ZR.Admin.WebApi/Controllers/System/TasksController.cs +++ b/ZR.Admin.WebApi/Controllers/System/TasksController.cs @@ -1,8 +1,6 @@ -using Infrastructure.Extensions; -using Microsoft.AspNetCore.Mvc; +using Microsoft.AspNetCore.Mvc; using Quartz; using SqlSugar; -using ZR.Admin.WebApi.Extensions; using ZR.Admin.WebApi.Filters; using ZR.Model.System; using ZR.Model.System.Dto; @@ -16,7 +14,6 @@ namespace ZR.Admin.WebApi.Controllers /// [Verify] [Route("system/Tasks")] - [Tags("计划Tasks")] [ApiExplorerSettings(GroupName = "sys")] public class TasksController : BaseController { diff --git a/ZR.Admin.WebApi/Controllers/System/TasksLogController.cs b/ZR.Admin.WebApi/Controllers/System/TasksLogController.cs index b4cee25..02dee80 100644 --- a/ZR.Admin.WebApi/Controllers/System/TasksLogController.cs +++ b/ZR.Admin.WebApi/Controllers/System/TasksLogController.cs @@ -1,5 +1,4 @@ -using Infrastructure.Extensions; -using Microsoft.AspNetCore.Mvc; +using Microsoft.AspNetCore.Mvc; using SqlSugar; using ZR.Admin.WebApi.Filters; using ZR.Model; @@ -14,7 +13,6 @@ namespace ZR.Admin.WebApi.Controllers.System /// [Verify] [Route("/monitor/jobLog")] - [Tags("任务日志TasksLog")] [ApiExplorerSettings(GroupName = "sys")] public class TasksLogController : BaseController { diff --git a/ZR.Admin.WebApi/Controllers/System/monitor/MonitorController.cs b/ZR.Admin.WebApi/Controllers/System/monitor/MonitorController.cs index a7c959c..e350369 100644 --- a/ZR.Admin.WebApi/Controllers/System/monitor/MonitorController.cs +++ b/ZR.Admin.WebApi/Controllers/System/monitor/MonitorController.cs @@ -9,7 +9,6 @@ namespace ZR.Admin.WebApi.Controllers.monitor /// /// 系统监控 /// - [Tags("系统监控Monitor")] [ApiExplorerSettings(GroupName = "sys")] public class MonitorController : BaseController { diff --git a/ZR.Admin.WebApi/Controllers/System/monitor/SqlDiffLogController.cs b/ZR.Admin.WebApi/Controllers/System/monitor/SqlDiffLogController.cs index bcb8398..7550e92 100644 --- a/ZR.Admin.WebApi/Controllers/System/monitor/SqlDiffLogController.cs +++ b/ZR.Admin.WebApi/Controllers/System/monitor/SqlDiffLogController.cs @@ -11,7 +11,6 @@ namespace ZR.Admin.WebApi.Controllers /// [Verify] [Route("monitor/SqlDiffLog")] - [Tags("差异日志SqlDiffLog")] [ApiExplorerSettings(GroupName = "sys")] public class SqlDiffLogController : BaseController { diff --git a/ZR.Admin.WebApi/Controllers/System/monitor/SysLogininforController.cs b/ZR.Admin.WebApi/Controllers/System/monitor/SysLogininforController.cs index e613836..712f022 100644 --- a/ZR.Admin.WebApi/Controllers/System/monitor/SysLogininforController.cs +++ b/ZR.Admin.WebApi/Controllers/System/monitor/SysLogininforController.cs @@ -13,7 +13,6 @@ namespace ZR.Admin.WebApi.Controllers.monitor /// [Verify] [Route("/monitor/logininfor")] - [Tags("登录日志SysLogininfor")] [ApiExplorerSettings(GroupName = "sys")] public class SysLogininforController : BaseController { diff --git a/ZR.Admin.WebApi/Controllers/System/monitor/SysOperlogController.cs b/ZR.Admin.WebApi/Controllers/System/monitor/SysOperlogController.cs index e55588e..a30baeb 100644 --- a/ZR.Admin.WebApi/Controllers/System/monitor/SysOperlogController.cs +++ b/ZR.Admin.WebApi/Controllers/System/monitor/SysOperlogController.cs @@ -11,7 +11,6 @@ namespace ZR.Admin.WebApi.Controllers.monitor /// [Verify] [Route("/monitor/operlog")] - [Tags("操作日志SysOperlog")] [ApiExplorerSettings(GroupName = "sys")] public class SysOperlogController : BaseController { @@ -67,7 +66,7 @@ namespace ZR.Admin.WebApi.Controllers.monitor { if (!HttpContextExtension.IsAdmin(HttpContext)) { - return ToResponse(Infrastructure.ResultCode.CUSTOM_ERROR,"操作失败"); + return ToResponse(ResultCode.CUSTOM_ERROR,"操作失败"); } sysOperLogService.CleanOperLog(); diff --git a/ZR.Admin.WebApi/Controllers/System/monitor/SysUserOnlineController.cs b/ZR.Admin.WebApi/Controllers/System/monitor/SysUserOnlineController.cs index 80b3222..0705a37 100644 --- a/ZR.Admin.WebApi/Controllers/System/monitor/SysUserOnlineController.cs +++ b/ZR.Admin.WebApi/Controllers/System/monitor/SysUserOnlineController.cs @@ -7,9 +7,11 @@ using ZR.Model.System.Dto; namespace ZR.Admin.WebApi.Controllers.monitor { + /// + /// 在线用户 + /// [Verify] [Route("monitor/online")] - [Tags("在线用户SysUserOnline")] [ApiExplorerSettings(GroupName = "sys")] public class SysUserOnlineController : BaseController { diff --git a/ZR.Admin.WebApi/Controllers/WxOpenController.cs b/ZR.Admin.WebApi/Controllers/WxOpenController.cs index 2ed4987..53bbc10 100644 --- a/ZR.Admin.WebApi/Controllers/WxOpenController.cs +++ b/ZR.Admin.WebApi/Controllers/WxOpenController.cs @@ -1,5 +1,4 @@ -using Infrastructure.Extensions; -using Microsoft.AspNetCore.Mvc; +using Microsoft.AspNetCore.Mvc; using System.Web; namespace ZR.Admin.WebApi.Controllers @@ -11,9 +10,6 @@ namespace ZR.Admin.WebApi.Controllers [AllowAnonymous] public class WxOpenController : BaseController { - private NLog.Logger logger = NLog.LogManager.GetCurrentClassLogger(); - public WxOpenController() { } - /// /// 获取签名 /// diff --git a/ZR.Admin.WebApi/Extensions/SwaggerExtension.cs b/ZR.Admin.WebApi/Extensions/SwaggerExtension.cs index 4fc90af..a8a7336 100644 --- a/ZR.Admin.WebApi/Extensions/SwaggerExtension.cs +++ b/ZR.Admin.WebApi/Extensions/SwaggerExtension.cs @@ -75,6 +75,9 @@ namespace ZR.Admin.WebApi.Extensions //添加文档注释 var baseDir = AppContext.BaseDirectory; c.IncludeXmlComments(Path.Combine(baseDir, "ZR.Model.xml"), true); + c.IncludeXmlComments(Path.Combine(baseDir, "ZR.ServiceCore.xml"), true); + c.IncludeXmlComments(Path.Combine(baseDir, "ZR.Service.xml"), true); + c.IncludeXmlComments(Path.Combine(baseDir, "ZR.Admin.WebApi.xml"), true); var xmlFile = $"{Assembly.GetExecutingAssembly().GetName().Name}.xml"; var xmlPath = Path.Combine(baseDir, xmlFile); diff --git a/ZR.Admin.WebApi/GlobalUsing.cs b/ZR.Admin.WebApi/GlobalUsing.cs index 2bdf8f8..3a674ba 100644 --- a/ZR.Admin.WebApi/GlobalUsing.cs +++ b/ZR.Admin.WebApi/GlobalUsing.cs @@ -6,4 +6,5 @@ global using Infrastructure.Enums; global using Infrastructure.Model; global using Mapster; global using Infrastructure.Extensions; -global using Infrastructure.WebExtensins; \ No newline at end of file +global using Infrastructure.Controllers; +global using ZR.ServiceCore.Middleware; \ No newline at end of file diff --git a/ZR.Admin.WebApi/NLog.config b/ZR.Admin.WebApi/NLog.config index 9936650..ee505cc 100644 --- a/ZR.Admin.WebApi/NLog.config +++ b/ZR.Admin.WebApi/NLog.config @@ -80,8 +80,8 @@ - - + + diff --git a/ZR.Admin.WebApi/Program.cs b/ZR.Admin.WebApi/Program.cs index 985fd4f..d81365c 100644 --- a/ZR.Admin.WebApi/Program.cs +++ b/ZR.Admin.WebApi/Program.cs @@ -1,13 +1,15 @@ using AspNetCoreRateLimit; +using Infrastructure.Converter; using Microsoft.AspNetCore.Authentication.JwtBearer; using Microsoft.AspNetCore.DataProtection; using Microsoft.IdentityModel.Tokens; using System.Text.Json.Serialization; using ZR.Admin.WebApi.Extensions; -using ZR.Admin.WebApi.Filters; using ZR.Admin.WebApi.Hubs; -using ZR.Admin.WebApi.Middleware; using ZR.Common.Cache; +using ZR.Infrastructure.WebExtensions; +using ZR.ServiceCore.Middleware; +using ZR.ServiceCore.SqlSugar; var builder = WebApplication.CreateBuilder(args); @@ -83,7 +85,7 @@ builder.Services.AddMvc(options => options.JsonSerializerOptions.WriteIndented = true; options.JsonSerializerOptions.Converters.Add(new JsonConverterUtil.DateTimeConverter()); options.JsonSerializerOptions.Converters.Add(new JsonConverterUtil.DateTimeNullConverter()); - options.JsonSerializerOptions.Converters.Add(new Infrastructure.StringConverter()); + options.JsonSerializerOptions.Converters.Add(new StringConverter()); }); builder.Services.AddSwaggerConfig(); @@ -93,7 +95,7 @@ InternalApp.ServiceProvider = app.Services; InternalApp.Configuration = builder.Configuration; InternalApp.WebHostEnvironment = app.Environment; //初始化db -builder.Services.AddDb(builder.Configuration, app.Environment); +builder.Services.AddDb(app.Environment); //使用全局异常中间件 app.UseMiddleware(); diff --git a/ZR.Admin.WebApi/ZR.Admin.WebApi.csproj b/ZR.Admin.WebApi/ZR.Admin.WebApi.csproj index 32e0cbe..6ffe3d2 100644 --- a/ZR.Admin.WebApi/ZR.Admin.WebApi.csproj +++ b/ZR.Admin.WebApi/ZR.Admin.WebApi.csproj @@ -15,11 +15,9 @@ - - @@ -33,5 +31,11 @@ Always + + Never + + + Never + diff --git a/ZR.Admin.WebApi/appsettings.json b/ZR.Admin.WebApi/appsettings.json index de5b1cb..8ea797d 100644 --- a/ZR.Admin.WebApi/appsettings.json +++ b/ZR.Admin.WebApi/appsettings.json @@ -33,7 +33,7 @@ "RefreshTokenTime": 5,//分钟 "TokenType": "Bearer" }, - "InjectClass": [ "ZR.Repository", "ZR.Service", "ZR.Tasks" ], //自动注入类 + "InjectClass": [ "ZR.Repository", "ZR.Service", "ZR.Tasks", "ZR.ServiceCore" ], //自动注入类 "ShowDbLog": true, //是否打印db日志 "InitDb": false, //是否初始化db "DemoMode": false, //是否演示模式 @@ -130,6 +130,11 @@ "Endpoint": "((post)|(put)):*", "Period": "3s", "Limit": 1 + }, + { + "Endpoint": "*:*", + "Period": "5s", + "Limit": 3 } ] }, diff --git a/ZR.CodeGenerator/CodeGeneratorTool.cs b/ZR.CodeGenerator/CodeGeneratorTool.cs index 23378eb..feb82b7 100644 --- a/ZR.CodeGenerator/CodeGeneratorTool.cs +++ b/ZR.CodeGenerator/CodeGeneratorTool.cs @@ -1,5 +1,6 @@ using Infrastructure; using Infrastructure.Extensions; +using Infrastructure.Helper; using Infrastructure.Model; using JinianNet.JNTemplate; using SqlSugar; @@ -8,7 +9,6 @@ using System.Collections.Generic; using System.IO; using System.Linq; using ZR.CodeGenerator.Model; -using ZR.Common; using ZR.Model.System.Generate; namespace ZR.CodeGenerator diff --git a/ZR.CodeGenerator/ZR.CodeGenerator.csproj b/ZR.CodeGenerator/ZR.CodeGenerator.csproj index 56defcd..b825722 100644 --- a/ZR.CodeGenerator/ZR.CodeGenerator.csproj +++ b/ZR.CodeGenerator/ZR.CodeGenerator.csproj @@ -5,9 +5,9 @@ - + - + diff --git a/ZR.Common/ZR.Common.csproj b/ZR.Common/ZR.Common.csproj index 5ef68e6..9a9f2a7 100644 --- a/ZR.Common/ZR.Common.csproj +++ b/ZR.Common/ZR.Common.csproj @@ -6,14 +6,10 @@ - - - - - + diff --git a/ZR.Model/Models/README.txt b/ZR.Model/Models/README.txt deleted file mode 100644 index 39e9872..0000000 --- a/ZR.Model/Models/README.txt +++ /dev/null @@ -1 +0,0 @@ -此文件夹用于存放业务代码数据库实体类 \ No newline at end of file diff --git a/ZR.Model/ProteryConstant.cs b/ZR.Model/ProteryConstant.cs deleted file mode 100644 index 382c459..0000000 --- a/ZR.Model/ProteryConstant.cs +++ /dev/null @@ -1,9 +0,0 @@ -using System; - -namespace ZR.Model -{ - public enum ProteryConstant - { - NOTNULL = 0 - } -} diff --git a/ZR.Model/ZR.Model.csproj b/ZR.Model/ZR.Model.csproj index d69320e..14d4d43 100644 --- a/ZR.Model/ZR.Model.csproj +++ b/ZR.Model/ZR.Model.csproj @@ -12,4 +12,8 @@ + + + + diff --git a/ZR.Repository/ZR.Repository.csproj b/ZR.Repository/ZR.Repository.csproj index ff7433b..ec96982 100644 --- a/ZR.Repository/ZR.Repository.csproj +++ b/ZR.Repository/ZR.Repository.csproj @@ -5,15 +5,13 @@ - + - - diff --git a/ZR.Service/GlobalUsing.cs b/ZR.Service/GlobalUsing.cs index 57439d9..9845705 100644 --- a/ZR.Service/GlobalUsing.cs +++ b/ZR.Service/GlobalUsing.cs @@ -1 +1,4 @@ -global using System.Collections.Generic; \ No newline at end of file +global using System.Collections.Generic; +global using System; +global using SqlSugar; +global using Newtonsoft.Json; \ No newline at end of file diff --git a/ZR.Service/HelloService.cs b/ZR.Service/HelloService.cs new file mode 100644 index 0000000..9f8ef0f --- /dev/null +++ b/ZR.Service/HelloService.cs @@ -0,0 +1,59 @@ +using Infrastructure; +using Infrastructure.Attribute; +using SqlSugar.IOC; +using ZR.Model.System; +using ZR.Repository; +using ZR.Service.IService; +using ZR.Service.System.IService; + +namespace ZR.Service +{ + /// + /// 注意:下面的AppService不要漏了 + /// + [AppService(ServiceType = typeof(IHelloService), ServiceLifetime = LifeTime.Transient)] + public class HelloService : BaseService, IHelloService + { + /// + /// 引用User服务 + /// + private readonly ISysUserService userService; + + /// + /// + /// + /// + public HelloService(ISysUserService userService) + { + this.userService = userService; + } + /// + /// 数据库使用案例 + /// + /// + /// + public string SayHello(string name) + { + //构造函数式使用 + var user = JsonConvert.SerializeObject(userService.GetFirst(f => f.UserId == 1)); + Console.WriteLine(user); + + var postService = App.GetRequiredService(); + Console.WriteLine(JsonConvert.SerializeObject(postService.GetId(1))); + + BaseRepository deptRepo = new(); + Console.WriteLine(JsonConvert.SerializeObject(deptRepo.GetId(1))); + + var result = DbScoped.SugarScope.Queryable().Where(f => f.DictId == 1).First(); + Console.WriteLine(JsonConvert.SerializeObject(result)); + + //切换库 + //DbScoped.SugarScope.GetConnectionScope(2); + + GetFirst(x => x.CategoryId == 1); + Context.Queryable().First(f => f.UserId == 1); + + return "Hello:" + name; + } + } +} diff --git a/ZR.Service/IService/IHelloService.cs b/ZR.Service/IService/IHelloService.cs new file mode 100644 index 0000000..5bb9391 --- /dev/null +++ b/ZR.Service/IService/IHelloService.cs @@ -0,0 +1,17 @@ +using ZR.Model.System; + +namespace ZR.Service.IService +{ + /// + /// Hello接口 + /// + public interface IHelloService : IBaseService + { + /// + /// + /// + /// + /// + string SayHello(string name); + } +} diff --git a/ZR.Service/ZR.Service.csproj b/ZR.Service/ZR.Service.csproj index f03125b..bbb3ce1 100644 --- a/ZR.Service/ZR.Service.csproj +++ b/ZR.Service/ZR.Service.csproj @@ -2,11 +2,14 @@ net7.0 + enable + true + + + 1591 - - - + diff --git a/ZR.Service/BaseService.cs b/ZR.ServiceCore/BaseService.cs similarity index 100% rename from ZR.Service/BaseService.cs rename to ZR.ServiceCore/BaseService.cs diff --git a/ZR.Admin.WebApi/Filters/ActionPermissionFilter.cs b/ZR.ServiceCore/Filters/ActionPermissionFilter.cs similarity index 97% rename from ZR.Admin.WebApi/Filters/ActionPermissionFilter.cs rename to ZR.ServiceCore/Filters/ActionPermissionFilter.cs index 7df2c87..96d17ac 100644 --- a/ZR.Admin.WebApi/Filters/ActionPermissionFilter.cs +++ b/ZR.ServiceCore/Filters/ActionPermissionFilter.cs @@ -1,10 +1,12 @@ -using Microsoft.AspNetCore.Mvc; +using Infrastructure; +using Infrastructure.Model; +using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc.Filters; using ZR.Model.System; using ZR.Service.System; using ZR.Service.System.IService; -namespace ZR.Admin.WebApi.Filters +namespace ZR.ServiceCore.Middleware { /// /// API授权判断 diff --git a/ZR.Admin.WebApi/Filters/GlobalActionMonitor.cs b/ZR.ServiceCore/Filters/GlobalActionMonitor.cs similarity index 94% rename from ZR.Admin.WebApi/Filters/GlobalActionMonitor.cs rename to ZR.ServiceCore/Filters/GlobalActionMonitor.cs index 05a3729..77699a1 100644 --- a/ZR.Admin.WebApi/Filters/GlobalActionMonitor.cs +++ b/ZR.ServiceCore/Filters/GlobalActionMonitor.cs @@ -1,4 +1,8 @@ -using IPTools.Core; +using Infrastructure; +using Infrastructure.Attribute; +using Infrastructure.Model; +using IPTools.Core; +using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc.Controllers; using Microsoft.AspNetCore.Mvc.Filters; @@ -6,12 +10,12 @@ using NLog; using ZR.Model.System; using ZR.Service.System.IService; -namespace ZR.Admin.WebApi.Filters +namespace ZR.ServiceCore.Middleware { public class GlobalActionMonitor : ActionFilterAttribute { static readonly Logger logger = LogManager.GetCurrentClassLogger(); - private ISysOperLogService OperLogService; + private readonly ISysOperLogService OperLogService; public GlobalActionMonitor(ISysOperLogService operLogService) { OperLogService = operLogService; @@ -126,7 +130,7 @@ namespace ZR.Admin.WebApi.Filters } } - private LogAttribute? GetLogAttribute(ControllerActionDescriptor controllerActionDescriptor) + private LogAttribute GetLogAttribute(ControllerActionDescriptor controllerActionDescriptor) { var attribute = controllerActionDescriptor.MethodInfo.GetCustomAttributes(inherit: true) .FirstOrDefault(a => a.GetType().Equals(typeof(LogAttribute))); diff --git a/ZR.Admin.WebApi/Filters/VerifyAttribute.cs b/ZR.ServiceCore/Filters/VerifyAttribute.cs similarity index 79% rename from ZR.Admin.WebApi/Filters/VerifyAttribute.cs rename to ZR.ServiceCore/Filters/VerifyAttribute.cs index aa6b480..ec4d1ac 100644 --- a/ZR.Admin.WebApi/Filters/VerifyAttribute.cs +++ b/ZR.ServiceCore/Filters/VerifyAttribute.cs @@ -1,18 +1,21 @@ -using Microsoft.AspNetCore.Mvc; +using Infrastructure; +using Infrastructure.Model; +using Microsoft.AspNetCore.Authorization; +using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc.Controllers; using Microsoft.AspNetCore.Mvc.Filters; -using NLog; +using ZR.Common; +//本命名空间暂时先不改,改动比较大2023年9月2日 namespace ZR.Admin.WebApi.Filters { /// /// 授权校验访问 /// 如果跳过授权登录在Action 或controller加上 AllowAnonymousAttribute /// + [AttributeUsage(AttributeTargets.All)] public class VerifyAttribute : Attribute, IAuthorizationFilter { - static readonly Logger logger = LogManager.GetCurrentClassLogger(); - /// /// 只判断token是否正确,不判断权限 /// 如果需要判断权限的在Action上加上ApiActionPermission属性标识权限类别,ActionPermissionFilter作权限处理 @@ -32,7 +35,7 @@ namespace ZR.Admin.WebApi.Filters string ip = HttpContextExtension.GetClientUserIp(context.HttpContext); string url = context.HttpContext.Request.Path; var isAuthed = context.HttpContext.User.Identity.IsAuthenticated; - + string osType = context.HttpContext.Request.Headers["os"]; //使用jwt token校验2020-11-21 TokenModel loginUser = JwtUtil.GetLoginUser(context.HttpContext); if (loginUser != null) @@ -46,8 +49,13 @@ namespace ZR.Admin.WebApi.Filters if (!CacheHelper.Exists(CK) && ts.TotalMinutes < 5) { var newToken = JwtUtil.GenerateJwtToken(JwtUtil.AddClaims(loginUser)); - + CacheHelper.SetCache(CK, CK, 1); + //移动端不加下面这个获取不到自定义Header + if (osType != null) + { + context.HttpContext.Response.Headers.Add("Access-Control-Expose-Headers", "X-Refresh-Token"); + } context.HttpContext.Response.Headers.Add("X-Refresh-Token", newToken); } } diff --git a/ZR.ServiceCore/GlobalUsing.cs b/ZR.ServiceCore/GlobalUsing.cs new file mode 100644 index 0000000..bfff86a --- /dev/null +++ b/ZR.ServiceCore/GlobalUsing.cs @@ -0,0 +1,5 @@ +global using Newtonsoft.Json; +global using SqlSugar; +global using System; +global using System.Collections.Generic; +global using Infrastructure.Extensions; \ No newline at end of file diff --git a/ZR.Service/IBaseService.cs b/ZR.ServiceCore/IBaseService.cs similarity index 100% rename from ZR.Service/IBaseService.cs rename to ZR.ServiceCore/IBaseService.cs diff --git a/ZR.Admin.WebApi/Middleware/GlobalExceptionMiddleware.cs b/ZR.ServiceCore/Middleware/GlobalExceptionMiddleware.cs similarity index 90% rename from ZR.Admin.WebApi/Middleware/GlobalExceptionMiddleware.cs rename to ZR.ServiceCore/Middleware/GlobalExceptionMiddleware.cs index 7668a2e..d28b1e1 100644 --- a/ZR.Admin.WebApi/Middleware/GlobalExceptionMiddleware.cs +++ b/ZR.ServiceCore/Middleware/GlobalExceptionMiddleware.cs @@ -1,12 +1,17 @@ -using IPTools.Core; +using Infrastructure; +using Infrastructure.Attribute; +using Infrastructure.Model; +using IPTools.Core; +using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Http.Features; using NLog; using System.Text.Encodings.Web; -using System.Text.Json; +using ZR.Common; using ZR.Model.System; using ZR.Service.System.IService; +using textJson = System.Text.Json; -namespace ZR.Admin.WebApi.Middleware +namespace ZR.ServiceCore.Middleware { /// /// 全局异常处理中间件 @@ -62,15 +67,15 @@ namespace ZR.Admin.WebApi.Middleware logLevel = NLog.LogLevel.Error; context.Response.StatusCode = 500; } - var options = new JsonSerializerOptions + var options = new textJson.JsonSerializerOptions { Encoder = JavaScriptEncoder.UnsafeRelaxedJsonEscaping, - PropertyNamingPolicy = JsonNamingPolicy.CamelCase, + PropertyNamingPolicy = textJson.JsonNamingPolicy.CamelCase, WriteIndented = true }; ApiResult apiResult = new(code, msg); - string responseResult = JsonSerializer.Serialize(apiResult, options).ToLower(); + string responseResult = textJson.JsonSerializer.Serialize(apiResult, options); string ip = HttpContextExtension.GetClientUserIp(context); var ip_info = IpTool.Search(ip); @@ -119,8 +124,8 @@ namespace ZR.Admin.WebApi.Middleware $"\n> 操作地址:{sysOperLog.OperUrl}" + $"\n> 错误信息:{msg}\n\n> {error}"; + SysOperLogService.InsertOperlog(sysOperLog); WxNoticeHelper.SendMsg("系统出错", errorMsg, "", WxNoticeHelper.MsgType.markdown); - SysOperLogService.InsertOperlog(sysOperLog); } public static Endpoint GetEndpoint(HttpContext context) diff --git a/ZR.Model/System/Article.cs b/ZR.ServiceCore/Model/Article.cs similarity index 100% rename from ZR.Model/System/Article.cs rename to ZR.ServiceCore/Model/Article.cs diff --git a/ZR.Model/System/ArticleCategory.cs b/ZR.ServiceCore/Model/ArticleCategory.cs similarity index 100% rename from ZR.Model/System/ArticleCategory.cs rename to ZR.ServiceCore/Model/ArticleCategory.cs diff --git a/ZR.Model/System/CommonLang.cs b/ZR.ServiceCore/Model/CommonLang.cs similarity index 100% rename from ZR.Model/System/CommonLang.cs rename to ZR.ServiceCore/Model/CommonLang.cs diff --git a/ZR.Model/System/Dto/ArticleCategoryDto.cs b/ZR.ServiceCore/Model/Dto/ArticleCategoryDto.cs similarity index 100% rename from ZR.Model/System/Dto/ArticleCategoryDto.cs rename to ZR.ServiceCore/Model/Dto/ArticleCategoryDto.cs diff --git a/ZR.Model/System/Dto/ArticleDto.cs b/ZR.ServiceCore/Model/Dto/ArticleDto.cs similarity index 100% rename from ZR.Model/System/Dto/ArticleDto.cs rename to ZR.ServiceCore/Model/Dto/ArticleDto.cs diff --git a/ZR.Model/System/Dto/CommonLangDto.cs b/ZR.ServiceCore/Model/Dto/CommonLangDto.cs similarity index 100% rename from ZR.Model/System/Dto/CommonLangDto.cs rename to ZR.ServiceCore/Model/Dto/CommonLangDto.cs diff --git a/ZR.Model/System/Dto/GenTableDto.cs b/ZR.ServiceCore/Model/Dto/GenTableDto.cs similarity index 100% rename from ZR.Model/System/Dto/GenTableDto.cs rename to ZR.ServiceCore/Model/Dto/GenTableDto.cs diff --git a/ZR.Model/System/Dto/LockUserDto.cs b/ZR.ServiceCore/Model/Dto/LockUserDto.cs similarity index 100% rename from ZR.Model/System/Dto/LockUserDto.cs rename to ZR.ServiceCore/Model/Dto/LockUserDto.cs diff --git a/ZR.Model/System/Dto/LoginBodyDto.cs b/ZR.ServiceCore/Model/Dto/LoginBodyDto.cs similarity index 100% rename from ZR.Model/System/Dto/LoginBodyDto.cs rename to ZR.ServiceCore/Model/Dto/LoginBodyDto.cs diff --git a/ZR.Model/System/Dto/MenuDto.cs b/ZR.ServiceCore/Model/Dto/MenuDto.cs similarity index 100% rename from ZR.Model/System/Dto/MenuDto.cs rename to ZR.ServiceCore/Model/Dto/MenuDto.cs diff --git a/ZR.Model/System/Dto/RegisterDto.cs b/ZR.ServiceCore/Model/Dto/RegisterDto.cs similarity index 100% rename from ZR.Model/System/Dto/RegisterDto.cs rename to ZR.ServiceCore/Model/Dto/RegisterDto.cs diff --git a/ZR.Model/System/Dto/RoleMenuExportDto.cs b/ZR.ServiceCore/Model/Dto/RoleMenuExportDto.cs similarity index 100% rename from ZR.Model/System/Dto/RoleMenuExportDto.cs rename to ZR.ServiceCore/Model/Dto/RoleMenuExportDto.cs diff --git a/ZR.Model/System/Dto/RoleUserDto.cs b/ZR.ServiceCore/Model/Dto/RoleUserDto.cs similarity index 100% rename from ZR.Model/System/Dto/RoleUserDto.cs rename to ZR.ServiceCore/Model/Dto/RoleUserDto.cs diff --git a/ZR.Model/System/Dto/ScanDto.cs b/ZR.ServiceCore/Model/Dto/ScanDto.cs similarity index 100% rename from ZR.Model/System/Dto/ScanDto.cs rename to ZR.ServiceCore/Model/Dto/ScanDto.cs diff --git a/ZR.Model/System/Dto/SqlDiffLogDto.cs b/ZR.ServiceCore/Model/Dto/SqlDiffLogDto.cs similarity index 100% rename from ZR.Model/System/Dto/SqlDiffLogDto.cs rename to ZR.ServiceCore/Model/Dto/SqlDiffLogDto.cs diff --git a/ZR.Model/System/Dto/SysConfigDto.cs b/ZR.ServiceCore/Model/Dto/SysConfigDto.cs similarity index 100% rename from ZR.Model/System/Dto/SysConfigDto.cs rename to ZR.ServiceCore/Model/Dto/SysConfigDto.cs diff --git a/ZR.Model/System/Dto/SysDeptDto.cs b/ZR.ServiceCore/Model/Dto/SysDeptDto.cs similarity index 100% rename from ZR.Model/System/Dto/SysDeptDto.cs rename to ZR.ServiceCore/Model/Dto/SysDeptDto.cs diff --git a/ZR.Model/System/Dto/SysDictTypeDto.cs b/ZR.ServiceCore/Model/Dto/SysDictTypeDto.cs similarity index 100% rename from ZR.Model/System/Dto/SysDictTypeDto.cs rename to ZR.ServiceCore/Model/Dto/SysDictTypeDto.cs diff --git a/ZR.Model/System/Dto/SysFileQueryDto.cs b/ZR.ServiceCore/Model/Dto/SysFileQueryDto.cs similarity index 100% rename from ZR.Model/System/Dto/SysFileQueryDto.cs rename to ZR.ServiceCore/Model/Dto/SysFileQueryDto.cs diff --git a/ZR.Model/System/Dto/SysLogininfoDto.cs b/ZR.ServiceCore/Model/Dto/SysLogininfoDto.cs similarity index 100% rename from ZR.Model/System/Dto/SysLogininfoDto.cs rename to ZR.ServiceCore/Model/Dto/SysLogininfoDto.cs diff --git a/ZR.Model/System/Dto/SysNoticeDto.cs b/ZR.ServiceCore/Model/Dto/SysNoticeDto.cs similarity index 100% rename from ZR.Model/System/Dto/SysNoticeDto.cs rename to ZR.ServiceCore/Model/Dto/SysNoticeDto.cs diff --git a/ZR.Model/System/Dto/SysOperLogDto.cs b/ZR.ServiceCore/Model/Dto/SysOperLogDto.cs similarity index 100% rename from ZR.Model/System/Dto/SysOperLogDto.cs rename to ZR.ServiceCore/Model/Dto/SysOperLogDto.cs diff --git a/ZR.Model/System/Dto/SysRoleDto.cs b/ZR.ServiceCore/Model/Dto/SysRoleDto.cs similarity index 100% rename from ZR.Model/System/Dto/SysRoleDto.cs rename to ZR.ServiceCore/Model/Dto/SysRoleDto.cs diff --git a/ZR.Model/System/Dto/SysRoleMenuDto.cs b/ZR.ServiceCore/Model/Dto/SysRoleMenuDto.cs similarity index 100% rename from ZR.Model/System/Dto/SysRoleMenuDto.cs rename to ZR.ServiceCore/Model/Dto/SysRoleMenuDto.cs diff --git a/ZR.Model/System/Dto/SysUserDto.cs b/ZR.ServiceCore/Model/Dto/SysUserDto.cs similarity index 100% rename from ZR.Model/System/Dto/SysUserDto.cs rename to ZR.ServiceCore/Model/Dto/SysUserDto.cs diff --git a/ZR.Model/System/Dto/SysdictDataDto.cs b/ZR.ServiceCore/Model/Dto/SysdictDataDto.cs similarity index 100% rename from ZR.Model/System/Dto/SysdictDataDto.cs rename to ZR.ServiceCore/Model/Dto/SysdictDataDto.cs diff --git a/ZR.Model/System/Dto/TasksDto.cs b/ZR.ServiceCore/Model/Dto/TasksDto.cs similarity index 100% rename from ZR.Model/System/Dto/TasksDto.cs rename to ZR.ServiceCore/Model/Dto/TasksDto.cs diff --git a/ZR.Model/System/Dto/TasksLogDto.cs b/ZR.ServiceCore/Model/Dto/TasksLogDto.cs similarity index 100% rename from ZR.Model/System/Dto/TasksLogDto.cs rename to ZR.ServiceCore/Model/Dto/TasksLogDto.cs diff --git a/ZR.Model/System/Enums/MenuStatus.cs b/ZR.ServiceCore/Model/Enums/MenuStatus.cs similarity index 100% rename from ZR.Model/System/Enums/MenuStatus.cs rename to ZR.ServiceCore/Model/Enums/MenuStatus.cs diff --git a/ZR.Model/System/Enums/MenuType.cs b/ZR.ServiceCore/Model/Enums/MenuType.cs similarity index 100% rename from ZR.Model/System/Enums/MenuType.cs rename to ZR.ServiceCore/Model/Enums/MenuType.cs diff --git a/ZR.Model/System/Generate/GenTable.cs b/ZR.ServiceCore/Model/Generate/GenTable.cs similarity index 100% rename from ZR.Model/System/Generate/GenTable.cs rename to ZR.ServiceCore/Model/Generate/GenTable.cs diff --git a/ZR.Model/System/Generate/GenTableColumn.cs b/ZR.ServiceCore/Model/Generate/GenTableColumn.cs similarity index 100% rename from ZR.Model/System/Generate/GenTableColumn.cs rename to ZR.ServiceCore/Model/Generate/GenTableColumn.cs diff --git a/ZR.Model/System/SqlDiffLog.cs b/ZR.ServiceCore/Model/SqlDiffLog.cs similarity index 100% rename from ZR.Model/System/SqlDiffLog.cs rename to ZR.ServiceCore/Model/SqlDiffLog.cs diff --git a/ZR.Model/System/SysBase.cs b/ZR.ServiceCore/Model/SysBase.cs similarity index 100% rename from ZR.Model/System/SysBase.cs rename to ZR.ServiceCore/Model/SysBase.cs diff --git a/ZR.Model/System/SysConfig.cs b/ZR.ServiceCore/Model/SysConfig.cs similarity index 100% rename from ZR.Model/System/SysConfig.cs rename to ZR.ServiceCore/Model/SysConfig.cs diff --git a/ZR.Model/System/SysDept.cs b/ZR.ServiceCore/Model/SysDept.cs similarity index 100% rename from ZR.Model/System/SysDept.cs rename to ZR.ServiceCore/Model/SysDept.cs diff --git a/ZR.Model/System/SysDictData.cs b/ZR.ServiceCore/Model/SysDictData.cs similarity index 100% rename from ZR.Model/System/SysDictData.cs rename to ZR.ServiceCore/Model/SysDictData.cs diff --git a/ZR.Model/System/SysDictType.cs b/ZR.ServiceCore/Model/SysDictType.cs similarity index 100% rename from ZR.Model/System/SysDictType.cs rename to ZR.ServiceCore/Model/SysDictType.cs diff --git a/ZR.Model/System/SysFile.cs b/ZR.ServiceCore/Model/SysFile.cs similarity index 100% rename from ZR.Model/System/SysFile.cs rename to ZR.ServiceCore/Model/SysFile.cs diff --git a/ZR.Model/System/SysLogininfor.cs b/ZR.ServiceCore/Model/SysLogininfor.cs similarity index 100% rename from ZR.Model/System/SysLogininfor.cs rename to ZR.ServiceCore/Model/SysLogininfor.cs diff --git a/ZR.Model/System/SysMenu.cs b/ZR.ServiceCore/Model/SysMenu.cs similarity index 100% rename from ZR.Model/System/SysMenu.cs rename to ZR.ServiceCore/Model/SysMenu.cs diff --git a/ZR.Model/System/SysNotice.cs b/ZR.ServiceCore/Model/SysNotice.cs similarity index 100% rename from ZR.Model/System/SysNotice.cs rename to ZR.ServiceCore/Model/SysNotice.cs diff --git a/ZR.Model/System/SysOperLog.cs b/ZR.ServiceCore/Model/SysOperLog.cs similarity index 100% rename from ZR.Model/System/SysOperLog.cs rename to ZR.ServiceCore/Model/SysOperLog.cs diff --git a/ZR.Model/System/SysPost.cs b/ZR.ServiceCore/Model/SysPost.cs similarity index 100% rename from ZR.Model/System/SysPost.cs rename to ZR.ServiceCore/Model/SysPost.cs diff --git a/ZR.Model/System/SysRole.cs b/ZR.ServiceCore/Model/SysRole.cs similarity index 100% rename from ZR.Model/System/SysRole.cs rename to ZR.ServiceCore/Model/SysRole.cs diff --git a/ZR.Model/System/SysRoleDept.cs b/ZR.ServiceCore/Model/SysRoleDept.cs similarity index 100% rename from ZR.Model/System/SysRoleDept.cs rename to ZR.ServiceCore/Model/SysRoleDept.cs diff --git a/ZR.Model/System/SysRoleMenu.cs b/ZR.ServiceCore/Model/SysRoleMenu.cs similarity index 100% rename from ZR.Model/System/SysRoleMenu.cs rename to ZR.ServiceCore/Model/SysRoleMenu.cs diff --git a/ZR.Model/System/SysTasks.cs b/ZR.ServiceCore/Model/SysTasks.cs similarity index 100% rename from ZR.Model/System/SysTasks.cs rename to ZR.ServiceCore/Model/SysTasks.cs diff --git a/ZR.Model/System/SysTasksLog.cs b/ZR.ServiceCore/Model/SysTasksLog.cs similarity index 100% rename from ZR.Model/System/SysTasksLog.cs rename to ZR.ServiceCore/Model/SysTasksLog.cs diff --git a/ZR.Model/System/SysUser.cs b/ZR.ServiceCore/Model/SysUser.cs similarity index 100% rename from ZR.Model/System/SysUser.cs rename to ZR.ServiceCore/Model/SysUser.cs diff --git a/ZR.Model/System/SysUserPost.cs b/ZR.ServiceCore/Model/SysUserPost.cs similarity index 100% rename from ZR.Model/System/SysUserPost.cs rename to ZR.ServiceCore/Model/SysUserPost.cs diff --git a/ZR.Model/System/SysUserRole.cs b/ZR.ServiceCore/Model/SysUserRole.cs similarity index 100% rename from ZR.Model/System/SysUserRole.cs rename to ZR.ServiceCore/Model/SysUserRole.cs diff --git a/ZR.Model/System/UserConstants.cs b/ZR.ServiceCore/Model/UserConstants.cs similarity index 100% rename from ZR.Model/System/UserConstants.cs rename to ZR.ServiceCore/Model/UserConstants.cs diff --git a/ZR.Model/System/Vo/RouterVo.cs b/ZR.ServiceCore/Model/Vo/RouterVo.cs similarity index 100% rename from ZR.Model/System/Vo/RouterVo.cs rename to ZR.ServiceCore/Model/Vo/RouterVo.cs diff --git a/ZR.Model/System/Vo/TreeSelectVo.cs b/ZR.ServiceCore/Model/Vo/TreeSelectVo.cs similarity index 100% rename from ZR.Model/System/Vo/TreeSelectVo.cs rename to ZR.ServiceCore/Model/Vo/TreeSelectVo.cs diff --git a/ZR.ServiceCore/ProteryConstant.cs b/ZR.ServiceCore/ProteryConstant.cs new file mode 100644 index 0000000..74987d6 --- /dev/null +++ b/ZR.ServiceCore/ProteryConstant.cs @@ -0,0 +1,4 @@ +public enum ProteryConstant +{ + NOTNULL = 0 +} diff --git a/ZR.Service/System/ArticleCategoryService.cs b/ZR.ServiceCore/Services/ArticleCategoryService.cs similarity index 100% rename from ZR.Service/System/ArticleCategoryService.cs rename to ZR.ServiceCore/Services/ArticleCategoryService.cs diff --git a/ZR.Service/System/ArticleService.cs b/ZR.ServiceCore/Services/ArticleService.cs similarity index 100% rename from ZR.Service/System/ArticleService.cs rename to ZR.ServiceCore/Services/ArticleService.cs diff --git a/ZR.Service/System/CacheService.cs b/ZR.ServiceCore/Services/CacheService.cs similarity index 100% rename from ZR.Service/System/CacheService.cs rename to ZR.ServiceCore/Services/CacheService.cs diff --git a/ZR.Service/System/CommonLangService.cs b/ZR.ServiceCore/Services/CommonLangService.cs similarity index 100% rename from ZR.Service/System/CommonLangService.cs rename to ZR.ServiceCore/Services/CommonLangService.cs diff --git a/ZR.Service/System/GenTableService.cs b/ZR.ServiceCore/Services/GenTableService.cs similarity index 99% rename from ZR.Service/System/GenTableService.cs rename to ZR.ServiceCore/Services/GenTableService.cs index 47e398d..958d8d7 100644 --- a/ZR.Service/System/GenTableService.cs +++ b/ZR.ServiceCore/Services/GenTableService.cs @@ -191,7 +191,7 @@ namespace ZR.Service.System /// /// 删除表字段 /// - /// + /// /// public int DeleteGenTableColumn(long tableId) { diff --git a/ZR.Service/System/IService/IArticleCategoryService.cs b/ZR.ServiceCore/Services/IService/IArticleCategoryService.cs similarity index 100% rename from ZR.Service/System/IService/IArticleCategoryService.cs rename to ZR.ServiceCore/Services/IService/IArticleCategoryService.cs diff --git a/ZR.Service/System/IService/IArticleService.cs b/ZR.ServiceCore/Services/IService/IArticleService.cs similarity index 100% rename from ZR.Service/System/IService/IArticleService.cs rename to ZR.ServiceCore/Services/IService/IArticleService.cs diff --git a/ZR.Service/System/IService/ICommonLangService.cs b/ZR.ServiceCore/Services/IService/ICommonLangService.cs similarity index 90% rename from ZR.Service/System/IService/ICommonLangService.cs rename to ZR.ServiceCore/Services/IService/ICommonLangService.cs index 5af554a..7afd4d5 100644 --- a/ZR.Service/System/IService/ICommonLangService.cs +++ b/ZR.ServiceCore/Services/IService/ICommonLangService.cs @@ -1,9 +1,6 @@ -using System; using ZR.Model; using ZR.Model.Dto; using ZR.Model.Models; -using System.Collections.Generic; -using JinianNet.JNTemplate; namespace ZR.Service.System.IService { diff --git a/ZR.Service/System/IService/IGenTableService.cs b/ZR.ServiceCore/Services/IService/IGenTableService.cs similarity index 100% rename from ZR.Service/System/IService/IGenTableService.cs rename to ZR.ServiceCore/Services/IService/IGenTableService.cs diff --git a/ZR.Service/System/IService/ISqlDiffLogService.cs b/ZR.ServiceCore/Services/IService/ISqlDiffLogService.cs similarity index 100% rename from ZR.Service/System/IService/ISqlDiffLogService.cs rename to ZR.ServiceCore/Services/IService/ISqlDiffLogService.cs diff --git a/ZR.Service/System/IService/ISysConfigService.cs b/ZR.ServiceCore/Services/IService/ISysConfigService.cs similarity index 100% rename from ZR.Service/System/IService/ISysConfigService.cs rename to ZR.ServiceCore/Services/IService/ISysConfigService.cs diff --git a/ZR.Service/System/IService/ISysDeptService.cs b/ZR.ServiceCore/Services/IService/ISysDeptService.cs similarity index 100% rename from ZR.Service/System/IService/ISysDeptService.cs rename to ZR.ServiceCore/Services/IService/ISysDeptService.cs diff --git a/ZR.Service/System/IService/ISysDictDataService.cs b/ZR.ServiceCore/Services/IService/ISysDictDataService.cs similarity index 100% rename from ZR.Service/System/IService/ISysDictDataService.cs rename to ZR.ServiceCore/Services/IService/ISysDictDataService.cs diff --git a/ZR.Service/System/IService/ISysDictService.cs b/ZR.ServiceCore/Services/IService/ISysDictService.cs similarity index 97% rename from ZR.Service/System/IService/ISysDictService.cs rename to ZR.ServiceCore/Services/IService/ISysDictService.cs index 331d5f7..37be554 100644 --- a/ZR.Service/System/IService/ISysDictService.cs +++ b/ZR.ServiceCore/Services/IService/ISysDictService.cs @@ -23,7 +23,7 @@ namespace ZR.Service.System.IService /// /// 批量删除字典数据信息 /// - /// + /// /// public int DeleteDictTypeByIds(long[] dictIds); diff --git a/ZR.Service/System/IService/ISysFileService.cs b/ZR.ServiceCore/Services/IService/ISysFileService.cs similarity index 100% rename from ZR.Service/System/IService/ISysFileService.cs rename to ZR.ServiceCore/Services/IService/ISysFileService.cs diff --git a/ZR.Service/System/IService/ISysLoginService.cs b/ZR.ServiceCore/Services/IService/ISysLoginService.cs similarity index 100% rename from ZR.Service/System/IService/ISysLoginService.cs rename to ZR.ServiceCore/Services/IService/ISysLoginService.cs diff --git a/ZR.Service/System/IService/ISysMenuService.cs b/ZR.ServiceCore/Services/IService/ISysMenuService.cs similarity index 100% rename from ZR.Service/System/IService/ISysMenuService.cs rename to ZR.ServiceCore/Services/IService/ISysMenuService.cs diff --git a/ZR.Service/System/IService/ISysNoticeService.cs b/ZR.ServiceCore/Services/IService/ISysNoticeService.cs similarity index 100% rename from ZR.Service/System/IService/ISysNoticeService.cs rename to ZR.ServiceCore/Services/IService/ISysNoticeService.cs diff --git a/ZR.Service/System/IService/ISysOperLogService.cs b/ZR.ServiceCore/Services/IService/ISysOperLogService.cs similarity index 100% rename from ZR.Service/System/IService/ISysOperLogService.cs rename to ZR.ServiceCore/Services/IService/ISysOperLogService.cs diff --git a/ZR.Service/System/IService/ISysPermissionService.cs b/ZR.ServiceCore/Services/IService/ISysPermissionService.cs similarity index 100% rename from ZR.Service/System/IService/ISysPermissionService.cs rename to ZR.ServiceCore/Services/IService/ISysPermissionService.cs diff --git a/ZR.Service/System/IService/ISysPostService.cs b/ZR.ServiceCore/Services/IService/ISysPostService.cs similarity index 100% rename from ZR.Service/System/IService/ISysPostService.cs rename to ZR.ServiceCore/Services/IService/ISysPostService.cs diff --git a/ZR.Service/System/IService/ISysRoleService.cs b/ZR.ServiceCore/Services/IService/ISysRoleService.cs similarity index 98% rename from ZR.Service/System/IService/ISysRoleService.cs rename to ZR.ServiceCore/Services/IService/ISysRoleService.cs index 300ba37..151b296 100644 --- a/ZR.Service/System/IService/ISysRoleService.cs +++ b/ZR.ServiceCore/Services/IService/ISysRoleService.cs @@ -18,7 +18,6 @@ namespace ZR.Service.System.IService /// /// 查询所有角色 /// - /// /// public List SelectRoleAll(); @@ -103,7 +102,7 @@ namespace ZR.Service.System.IService /// /// 获取角色菜单id集合 /// - /// + /// /// public List SelectUserRoleMenus(long roleId); List SelectRoleMenuByRoleIds(long[] roleIds); diff --git a/ZR.Service/System/IService/ISysTasksLogService.cs b/ZR.ServiceCore/Services/IService/ISysTasksLogService.cs similarity index 100% rename from ZR.Service/System/IService/ISysTasksLogService.cs rename to ZR.ServiceCore/Services/IService/ISysTasksLogService.cs diff --git a/ZR.Service/System/IService/ISysTasksQzService.cs b/ZR.ServiceCore/Services/IService/ISysTasksQzService.cs similarity index 100% rename from ZR.Service/System/IService/ISysTasksQzService.cs rename to ZR.ServiceCore/Services/IService/ISysTasksQzService.cs diff --git a/ZR.Service/System/IService/ISysUserPostService.cs b/ZR.ServiceCore/Services/IService/ISysUserPostService.cs similarity index 100% rename from ZR.Service/System/IService/ISysUserPostService.cs rename to ZR.ServiceCore/Services/IService/ISysUserPostService.cs diff --git a/ZR.Service/System/IService/ISysUserRoleService.cs b/ZR.ServiceCore/Services/IService/ISysUserRoleService.cs similarity index 95% rename from ZR.Service/System/IService/ISysUserRoleService.cs rename to ZR.ServiceCore/Services/IService/ISysUserRoleService.cs index e9de810..42d54eb 100644 --- a/ZR.Service/System/IService/ISysUserRoleService.cs +++ b/ZR.ServiceCore/Services/IService/ISysUserRoleService.cs @@ -62,8 +62,7 @@ namespace ZR.Service.System.IService /// /// 新增加角色用户 /// - /// 角色id - /// 用户ids + /// /// public int InsertRoleUser(RoleUsersCreateDto roleUsersCreateDto); } diff --git a/ZR.Service/System/IService/ISysUserService.cs b/ZR.ServiceCore/Services/IService/ISysUserService.cs similarity index 98% rename from ZR.Service/System/IService/ISysUserService.cs rename to ZR.ServiceCore/Services/IService/ISysUserService.cs index 75feef1..a074e85 100644 --- a/ZR.Service/System/IService/ISysUserService.cs +++ b/ZR.ServiceCore/Services/IService/ISysUserService.cs @@ -33,7 +33,7 @@ namespace ZR.Service.System.IService /// /// 修改用户信息 /// - /// + /// /// public int UpdateUser(SysUser user); @@ -52,7 +52,7 @@ namespace ZR.Service.System.IService /// /// 删除用户 /// - /// + /// /// public int DeleteUser(long userid); diff --git a/ZR.Service/System/SeedDataService.cs b/ZR.ServiceCore/Services/SeedDataService.cs similarity index 100% rename from ZR.Service/System/SeedDataService.cs rename to ZR.ServiceCore/Services/SeedDataService.cs diff --git a/ZR.Service/System/SqlDiffLogService.cs b/ZR.ServiceCore/Services/SqlDiffLogService.cs similarity index 100% rename from ZR.Service/System/SqlDiffLogService.cs rename to ZR.ServiceCore/Services/SqlDiffLogService.cs diff --git a/ZR.Service/System/SysConfigService.cs b/ZR.ServiceCore/Services/SysConfigService.cs similarity index 100% rename from ZR.Service/System/SysConfigService.cs rename to ZR.ServiceCore/Services/SysConfigService.cs diff --git a/ZR.Service/System/SysDeptService.cs b/ZR.ServiceCore/Services/SysDeptService.cs similarity index 100% rename from ZR.Service/System/SysDeptService.cs rename to ZR.ServiceCore/Services/SysDeptService.cs diff --git a/ZR.Service/System/SysDictDataService.cs b/ZR.ServiceCore/Services/SysDictDataService.cs similarity index 100% rename from ZR.Service/System/SysDictDataService.cs rename to ZR.ServiceCore/Services/SysDictDataService.cs diff --git a/ZR.Service/System/SysDictService.cs b/ZR.ServiceCore/Services/SysDictService.cs similarity index 100% rename from ZR.Service/System/SysDictService.cs rename to ZR.ServiceCore/Services/SysDictService.cs diff --git a/ZR.Service/System/SysFileService.cs b/ZR.ServiceCore/Services/SysFileService.cs similarity index 96% rename from ZR.Service/System/SysFileService.cs rename to ZR.ServiceCore/Services/SysFileService.cs index 55d458a..d905800 100644 --- a/ZR.Service/System/SysFileService.cs +++ b/ZR.ServiceCore/Services/SysFileService.cs @@ -1,15 +1,12 @@ using Infrastructure; using Infrastructure.Attribute; -using Infrastructure.Extensions; +using Infrastructure.Enums; using Infrastructure.Model; using Microsoft.AspNetCore.Http; using Microsoft.Extensions.Options; -using System; -using System.IO; using System.Net; using System.Security.Cryptography; using System.Text; -using System.Threading.Tasks; using ZR.Common; using ZR.Model.System; using ZR.Service.System.IService; @@ -62,7 +59,7 @@ namespace ZR.Service.System string accessPath = string.Concat(uploadUrl, "/", filePath.Replace("\\", "/"), "/", fileName); SysFile file = new(formFile.FileName, fileName, fileExt, fileSize + "kb", filePath, userName) { - StoreType = (int)Infrastructure.Enums.StoreType.LOCAL, + StoreType = (int)StoreType.LOCAL, FileType = formFile.ContentType, FileUrl = finalFilePath.Replace("\\", "/"), AccessUrl = accessPath diff --git a/ZR.Service/System/SysLoginService.cs b/ZR.ServiceCore/Services/SysLoginService.cs similarity index 98% rename from ZR.Service/System/SysLoginService.cs rename to ZR.ServiceCore/Services/SysLoginService.cs index ec95094..f91b96a 100644 --- a/ZR.Service/System/SysLoginService.cs +++ b/ZR.ServiceCore/Services/SysLoginService.cs @@ -1,10 +1,7 @@ using Infrastructure; using Infrastructure.Attribute; using Infrastructure.Extensions; -using Infrastructure.WebExtensins; using Microsoft.AspNetCore.Http; -using SqlSugar; -using System; using UAParser; using ZR.Model; using ZR.Model.System; @@ -32,6 +29,7 @@ namespace ZR.Service.System /// /// 登录验证 /// + /// /// /// public SysUser Login(LoginBodyDto loginBody, SysLogininfor logininfor) diff --git a/ZR.Service/System/SysMenuService.cs b/ZR.ServiceCore/Services/SysMenuService.cs similarity index 100% rename from ZR.Service/System/SysMenuService.cs rename to ZR.ServiceCore/Services/SysMenuService.cs diff --git a/ZR.Service/System/SysNoticeService.cs b/ZR.ServiceCore/Services/SysNoticeService.cs similarity index 100% rename from ZR.Service/System/SysNoticeService.cs rename to ZR.ServiceCore/Services/SysNoticeService.cs diff --git a/ZR.Service/System/SysOperLogService.cs b/ZR.ServiceCore/Services/SysOperLogService.cs similarity index 98% rename from ZR.Service/System/SysOperLogService.cs rename to ZR.ServiceCore/Services/SysOperLogService.cs index 9fc804e..dcfa2aa 100644 --- a/ZR.Service/System/SysOperLogService.cs +++ b/ZR.ServiceCore/Services/SysOperLogService.cs @@ -34,7 +34,6 @@ namespace ZR.Service.System /// 查询系统操作日志集合 /// /// 操作日志对象 - /// /// 操作日志集合 public PagedInfo SelectOperLogList(SysOperLogQueryDto sysOper) { diff --git a/ZR.Service/System/SysPermissionService.cs b/ZR.ServiceCore/Services/SysPermissionService.cs similarity index 100% rename from ZR.Service/System/SysPermissionService.cs rename to ZR.ServiceCore/Services/SysPermissionService.cs diff --git a/ZR.Service/System/SysPostService.cs b/ZR.ServiceCore/Services/SysPostService.cs similarity index 94% rename from ZR.Service/System/SysPostService.cs rename to ZR.ServiceCore/Services/SysPostService.cs index 245519d..21e832c 100644 --- a/ZR.Service/System/SysPostService.cs +++ b/ZR.ServiceCore/Services/SysPostService.cs @@ -14,7 +14,7 @@ namespace ZR.Service.System /// /// 校验岗位编码是否唯一 /// - /// + /// /// public string CheckPostCodeUnique(SysPost post) { @@ -29,7 +29,7 @@ namespace ZR.Service.System /// /// 校验岗位名称是否唯一 /// - /// + /// /// public string CheckPostNameUnique(SysPost post) { diff --git a/ZR.Service/System/SysRoleMenuService.cs b/ZR.ServiceCore/Services/SysRoleMenuService.cs similarity index 96% rename from ZR.Service/System/SysRoleMenuService.cs rename to ZR.ServiceCore/Services/SysRoleMenuService.cs index bebdee2..dbd2b37 100644 --- a/ZR.Service/System/SysRoleMenuService.cs +++ b/ZR.ServiceCore/Services/SysRoleMenuService.cs @@ -1,6 +1,4 @@ using Infrastructure.Attribute; -using System.Collections.Generic; -using System.Linq; using ZR.Model.System; using ZR.Service.System.IService; diff --git a/ZR.Service/System/SysRoleService.cs b/ZR.ServiceCore/Services/SysRoleService.cs similarity index 100% rename from ZR.Service/System/SysRoleService.cs rename to ZR.ServiceCore/Services/SysRoleService.cs diff --git a/ZR.Service/System/SysTasksLogService.cs b/ZR.ServiceCore/Services/SysTasksLogService.cs similarity index 100% rename from ZR.Service/System/SysTasksLogService.cs rename to ZR.ServiceCore/Services/SysTasksLogService.cs diff --git a/ZR.Service/System/SysTasksQzService.cs b/ZR.ServiceCore/Services/SysTasksQzService.cs similarity index 100% rename from ZR.Service/System/SysTasksQzService.cs rename to ZR.ServiceCore/Services/SysTasksQzService.cs diff --git a/ZR.Service/System/SysUserPostService.cs b/ZR.ServiceCore/Services/SysUserPostService.cs similarity index 100% rename from ZR.Service/System/SysUserPostService.cs rename to ZR.ServiceCore/Services/SysUserPostService.cs diff --git a/ZR.Service/System/SysUserRoleService.cs b/ZR.ServiceCore/Services/SysUserRoleService.cs similarity index 100% rename from ZR.Service/System/SysUserRoleService.cs rename to ZR.ServiceCore/Services/SysUserRoleService.cs diff --git a/ZR.Service/System/SysUserService.cs b/ZR.ServiceCore/Services/SysUserService.cs similarity index 99% rename from ZR.Service/System/SysUserService.cs rename to ZR.ServiceCore/Services/SysUserService.cs index 940bef8..8cb03fb 100644 --- a/ZR.Service/System/SysUserService.cs +++ b/ZR.ServiceCore/Services/SysUserService.cs @@ -118,7 +118,7 @@ namespace ZR.Service /// /// 修改用户信息 /// - /// + /// /// public int UpdateUser(SysUser user) { diff --git a/ZR.Admin.WebApi/Extensions/DataPermi.cs b/ZR.ServiceCore/SqlSugar/DataPermi.cs similarity index 98% rename from ZR.Admin.WebApi/Extensions/DataPermi.cs rename to ZR.ServiceCore/SqlSugar/DataPermi.cs index 7d22f01..e9cc866 100644 --- a/ZR.Admin.WebApi/Extensions/DataPermi.cs +++ b/ZR.ServiceCore/SqlSugar/DataPermi.cs @@ -1,8 +1,8 @@ -using SqlSugar; +using Infrastructure; using SqlSugar.IOC; using ZR.Model.System; -namespace ZR.Admin.WebApi.Extensions +namespace ZR.ServiceCore.SqlSugar { public enum DataPermiEnum { diff --git a/ZR.Admin.WebApi/Extensions/InitTable.cs b/ZR.ServiceCore/SqlSugar/InitTable.cs similarity index 98% rename from ZR.Admin.WebApi/Extensions/InitTable.cs rename to ZR.ServiceCore/SqlSugar/InitTable.cs index 2997b82..88a4f90 100644 --- a/ZR.Admin.WebApi/Extensions/InitTable.cs +++ b/ZR.ServiceCore/SqlSugar/InitTable.cs @@ -3,7 +3,7 @@ using ZR.Model.Models; using ZR.Model.System; using ZR.Model.System.Generate; -namespace ZR.Admin.WebApi.Extensions +namespace ZR.ServiceCore.SqlSugar { /// /// 初始化表 diff --git a/ZR.Admin.WebApi/Extensions/SqlSugarCache.cs b/ZR.ServiceCore/SqlSugar/SqlSugarCache.cs similarity index 91% rename from ZR.Admin.WebApi/Extensions/SqlSugarCache.cs rename to ZR.ServiceCore/SqlSugar/SqlSugarCache.cs index 3e6ccda..c1e8f40 100644 --- a/ZR.Admin.WebApi/Extensions/SqlSugarCache.cs +++ b/ZR.ServiceCore/SqlSugar/SqlSugarCache.cs @@ -1,66 +1,66 @@ -using ZR.Common; - -namespace ZR.Admin.WebApi.Extensions -{ - public class SqlSugarCache : SqlSugar.ICacheService - { - public void Add(string key, V value) - { - //RedisServer.Cache.Set(key, value, 3600 + RedisHelper.RandomExpired(5, 30)); - CacheHelper.SetCache(key, value); - } - - public void Add(string key, V value, int cacheDurationInSeconds) - { - //RedisServer.Cache.Set(key, value, cacheDurationInSeconds); - CacheHelper.SetCaches(key, value, cacheDurationInSeconds); - } - - public bool ContainsKey(string key) - { - //return RedisServer.Cache.Exists(key); - return CacheHelper.Exists(key); - } - - public V Get(string key) - { - //return RedisServer.Cache.Get(key); - return (V)CacheHelper.Get(key); - } - - public IEnumerable GetAllKey() - { - //return RedisServer.Cache.Keys("*"); - return CacheHelper.GetCacheKeys(); - } - - public V GetOrCreate(string cacheKey, Func create, int cacheDurationInSeconds = int.MaxValue) - { - if (ContainsKey(cacheKey)) - { - var result = Get(cacheKey); - if (result == null) - { - return create(); - } - else - { - return result; - } - } - else - { - var restul = create(); - - Add(cacheKey, restul, cacheDurationInSeconds); - return restul; - } - } - - public void Remove(string key) - { - //RedisServer.Cache.Del(key); - CacheHelper.Remove(key); - } - } +using ZR.Common; + +namespace ZR.ServiceCore.SqlSugar +{ + public class SqlSugarCache : ICacheService + { + public void Add(string key, V value) + { + //RedisServer.Cache.Set(key, value, 3600 + RedisHelper.RandomExpired(5, 30)); + CacheHelper.SetCache(key, value); + } + + public void Add(string key, V value, int cacheDurationInSeconds) + { + //RedisServer.Cache.Set(key, value, cacheDurationInSeconds); + CacheHelper.SetCaches(key, value, cacheDurationInSeconds); + } + + public bool ContainsKey(string key) + { + //return RedisServer.Cache.Exists(key); + return CacheHelper.Exists(key); + } + + public V Get(string key) + { + //return RedisServer.Cache.Get(key); + return (V)CacheHelper.Get(key); + } + + public IEnumerable GetAllKey() + { + //return RedisServer.Cache.Keys("*"); + return CacheHelper.GetCacheKeys(); + } + + public V GetOrCreate(string cacheKey, Func create, int cacheDurationInSeconds = int.MaxValue) + { + if (ContainsKey(cacheKey)) + { + var result = Get(cacheKey); + if (result == null) + { + return create(); + } + else + { + return result; + } + } + else + { + var restul = create(); + + Add(cacheKey, restul, cacheDurationInSeconds); + return restul; + } + } + + public void Remove(string key) + { + //RedisServer.Cache.Del(key); + CacheHelper.Remove(key); + } + } } \ No newline at end of file diff --git a/ZR.Admin.WebApi/Extensions/DbExtension.cs b/ZR.ServiceCore/SqlSugar/SqlsugarSetup.cs similarity index 94% rename from ZR.Admin.WebApi/Extensions/DbExtension.cs rename to ZR.ServiceCore/SqlSugar/SqlsugarSetup.cs index 8cba189..b1e0361 100644 --- a/ZR.Admin.WebApi/Extensions/DbExtension.cs +++ b/ZR.ServiceCore/SqlSugar/SqlsugarSetup.cs @@ -1,15 +1,14 @@ -using Infrastructure.Extensions; -using SqlSugar; +using Infrastructure; +using Infrastructure.Model; +using Microsoft.AspNetCore.Hosting; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Hosting; using SqlSugar.IOC; -using ZR.Model; using ZR.Model.System; -namespace ZR.Admin.WebApi.Extensions +namespace ZR.ServiceCore.SqlSugar { - /// - /// sqlsugar 数据处理 - /// - public static class DbExtension + public static class SqlsugarSetup { private static NLog.Logger logger = NLog.LogManager.GetCurrentClassLogger(); @@ -17,11 +16,11 @@ namespace ZR.Admin.WebApi.Extensions /// 初始化db /// /// - /// /// - public static void AddDb(this IServiceCollection services, IConfiguration Configuration, IWebHostEnvironment environment) + public static void AddDb(this IServiceCollection services,IWebHostEnvironment environment) { - List dbConfigs = Configuration.GetSection("DbConfigs").Get>(); + var options = App.OptionsSetting; + List dbConfigs = options.DbConfigs; var iocList = new List(); foreach (var item in dbConfigs) @@ -52,7 +51,7 @@ namespace ZR.Admin.WebApi.Extensions }); }); - if (Configuration["InitDb"].ParseToBool() == true && environment.IsDevelopment()) + if (options.InitDb && environment.IsDevelopment()) { InitTable.InitDb(); } diff --git a/ZR.ServiceCore/ZR.ServiceCore.csproj b/ZR.ServiceCore/ZR.ServiceCore.csproj new file mode 100644 index 0000000..82db85b --- /dev/null +++ b/ZR.ServiceCore/ZR.ServiceCore.csproj @@ -0,0 +1,20 @@ + + + + net7.0 + enable + true + 1701;1702;1591;1570 + + + + + + + + + + + + + diff --git a/ZR.Tasks/ZR.Tasks.csproj b/ZR.Tasks/ZR.Tasks.csproj index 197e474..221d49b 100644 --- a/ZR.Tasks/ZR.Tasks.csproj +++ b/ZR.Tasks/ZR.Tasks.csproj @@ -5,7 +5,6 @@ - diff --git a/ZRAdmin.sln b/ZRAdmin.sln index 633d2ab..0c5700e 100644 --- a/ZRAdmin.sln +++ b/ZRAdmin.sln @@ -9,7 +9,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ZR.Model", "ZR.Model\ZR.Mod EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ZR.Common", "ZR.Common\ZR.Common.csproj", "{42C84599-1E99-45B4-929B-417C37337EF8}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Infrastructure", "Infrastructure\Infrastructure.csproj", "{5D740120-5491-4FE2-B5BE-8A9C48BFE3C5}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ZR.Infrastructure", "Infrastructure\ZR.Infrastructure.csproj", "{5D740120-5491-4FE2-B5BE-8A9C48BFE3C5}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ZR.Tasks", "ZR.Tasks\ZR.Tasks.csproj", "{B657ED99-40E5-423A-AFE7-157C4EE576CB}" EndProject @@ -19,6 +19,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ZR.Repository", "ZR.Reposit EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ZR.CodeGenerator", "ZR.CodeGenerator\ZR.CodeGenerator.csproj", "{B353DE0B-12C6-4C15-909A-DB68F71D5AE9}" EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ZR.ServiceCore", "ZR.ServiceCore\ZR.ServiceCore.csproj", "{4E2CC4E4-F109-4876-8498-912E13905765}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -57,6 +59,10 @@ Global {B353DE0B-12C6-4C15-909A-DB68F71D5AE9}.Debug|Any CPU.Build.0 = Debug|Any CPU {B353DE0B-12C6-4C15-909A-DB68F71D5AE9}.Release|Any CPU.ActiveCfg = Release|Any CPU {B353DE0B-12C6-4C15-909A-DB68F71D5AE9}.Release|Any CPU.Build.0 = Release|Any CPU + {4E2CC4E4-F109-4876-8498-912E13905765}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {4E2CC4E4-F109-4876-8498-912E13905765}.Debug|Any CPU.Build.0 = Debug|Any CPU + {4E2CC4E4-F109-4876-8498-912E13905765}.Release|Any CPU.ActiveCfg = Release|Any CPU + {4E2CC4E4-F109-4876-8498-912E13905765}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE