From 489a0b6fb8f9f281a3143753266d7249154df4d0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=88=E6=B7=B3?= Date: Thu, 15 Sep 2022 17:09:30 +0800 Subject: [PATCH 01/25] =?UTF-8?q?=E9=85=8D=E7=BD=AE=E6=96=87=E4=BB=B6?= =?UTF-8?q?=E7=83=AD=E9=87=8D=E8=BD=BD=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Yi.Framework.ApiMicroservice/Program.cs | 2 + .../BuilderExtend/JsonFileExtension.cs | 4 +- .../FileOptionsWritableBase.cs | 14 +++++++ .../OptionsWritable/IOptionsWritable.cs | 10 +++++ .../Internal/JsonOptionsWritable.cs | 37 +++++++++++++++++ .../OptionsWritable/OptionsWritableBase.cs | 29 +++++++++++++ ...onfigurationServiceCollectionExtensions.cs | 41 +++++++++++++++++++ .../Yi.Framework.WebCore.csproj | 4 ++ 8 files changed, 139 insertions(+), 2 deletions(-) create mode 100644 Yi.Framework.Net6/Yi.Framework.WebCore/BuilderExtend/OptionsWritable/FileOptionsWritableBase.cs create mode 100644 Yi.Framework.Net6/Yi.Framework.WebCore/BuilderExtend/OptionsWritable/IOptionsWritable.cs create mode 100644 Yi.Framework.Net6/Yi.Framework.WebCore/BuilderExtend/OptionsWritable/Internal/JsonOptionsWritable.cs create mode 100644 Yi.Framework.Net6/Yi.Framework.WebCore/BuilderExtend/OptionsWritable/OptionsWritableBase.cs create mode 100644 Yi.Framework.Net6/Yi.Framework.WebCore/BuilderExtend/OptionsWritable/OptionsWritableConfigurationServiceCollectionExtensions.cs diff --git a/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Program.cs b/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Program.cs index 52e69fb6..33507d35 100644 --- a/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Program.cs +++ b/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Program.cs @@ -10,6 +10,8 @@ using Microsoft.Extensions.Localization; using Yi.Framework.WebCore.AttributeExtend; using Yi.Framework.WebCore.SignalRHub; + + var builder = WebApplication.CreateBuilder(args); builder.Configuration.AddCommandLine(args); builder.WebHost.UseUrls(builder.Configuration.GetValue("StartUrl")); diff --git a/Yi.Framework.Net6/Yi.Framework.WebCore/BuilderExtend/JsonFileExtension.cs b/Yi.Framework.Net6/Yi.Framework.WebCore/BuilderExtend/JsonFileExtension.cs index 9a3c0c73..b5b67a2a 100644 --- a/Yi.Framework.Net6/Yi.Framework.WebCore/BuilderExtend/JsonFileExtension.cs +++ b/Yi.Framework.Net6/Yi.Framework.WebCore/BuilderExtend/JsonFileExtension.cs @@ -16,14 +16,14 @@ namespace Yi.Framework.WebCore.BuilderExtend string[] myJsonFile = new string[] { "appsettings.json", "Config/configuration.json" }; foreach (var item in myJsonFile) { - builder.AddJsonFile(item, optional: true, reloadOnChange: false); + builder.AddJsonFile(item, optional: true, reloadOnChange: true); } } else { foreach (var item in JsonFile) { - builder.AddJsonFile(item, optional: true, reloadOnChange: false); + builder.AddJsonFile(item, optional: true, reloadOnChange: true); } } diff --git a/Yi.Framework.Net6/Yi.Framework.WebCore/BuilderExtend/OptionsWritable/FileOptionsWritableBase.cs b/Yi.Framework.Net6/Yi.Framework.WebCore/BuilderExtend/OptionsWritable/FileOptionsWritableBase.cs new file mode 100644 index 00000000..2cc18721 --- /dev/null +++ b/Yi.Framework.Net6/Yi.Framework.WebCore/BuilderExtend/OptionsWritable/FileOptionsWritableBase.cs @@ -0,0 +1,14 @@ + +using Microsoft.Extensions.Options; + +namespace Yi.Framework.WebCore.BuilderExtend.OptionsWritable; + +public abstract class FileOptionsWritableBase : OptionsWritableBase, IOptionsWritable where TOptions : class, new() +{ + public FileOptionsWritableBase(IOptionsMonitor options, string section, string fileName) : base(options, section) + { + this.FileName = fileName; + } + + public string FileName { get; } +} \ No newline at end of file diff --git a/Yi.Framework.Net6/Yi.Framework.WebCore/BuilderExtend/OptionsWritable/IOptionsWritable.cs b/Yi.Framework.Net6/Yi.Framework.WebCore/BuilderExtend/OptionsWritable/IOptionsWritable.cs new file mode 100644 index 00000000..e0816b55 --- /dev/null +++ b/Yi.Framework.Net6/Yi.Framework.WebCore/BuilderExtend/OptionsWritable/IOptionsWritable.cs @@ -0,0 +1,10 @@ + +using Microsoft.Extensions.Options; +using System; + +namespace Yi.Framework.WebCore.BuilderExtend.OptionsWritable; + +public interface IOptionsWritable : IOptionsSnapshot where TOptions : class, new() +{ + void Update(Action configuration); +} \ No newline at end of file diff --git a/Yi.Framework.Net6/Yi.Framework.WebCore/BuilderExtend/OptionsWritable/Internal/JsonOptionsWritable.cs b/Yi.Framework.Net6/Yi.Framework.WebCore/BuilderExtend/OptionsWritable/Internal/JsonOptionsWritable.cs new file mode 100644 index 00000000..47ee93ff --- /dev/null +++ b/Yi.Framework.Net6/Yi.Framework.WebCore/BuilderExtend/OptionsWritable/Internal/JsonOptionsWritable.cs @@ -0,0 +1,37 @@ +using Microsoft.Extensions.Options; +using Newtonsoft.Json; +using Newtonsoft.Json.Linq; +using System; +using System.Collections.Generic; +using System.IO; + +namespace Yi.Framework.WebCore.BuilderExtend.OptionsWritable.Internal; + +internal class JsonOptionsWritable : FileOptionsWritableBase, IOptionsWritable where TOptions : class, new() +{ + public JsonOptionsWritable(IOptionsMonitor options, string section, string fileName) : base(options, section, fileName) + { + } + + public override void Update(Action configuration) + { + JObject? jObject = JsonConvert.DeserializeObject(File.ReadAllText(this.FileName)); + if (jObject != null) + { + TOptions option = this.Monitor.CurrentValue ?? new TOptions(); + + if (jObject.TryGetValue(this.Section, out JToken? jtoken)) + { + option = JsonConvert.DeserializeObject(jtoken.ToString()) ?? new TOptions(); + configuration?.Invoke(option); + jObject[this.Section] = JObject.Parse(JsonConvert.SerializeObject(option)); + } + else + { + configuration?.Invoke(option); + jObject.TryAdd(this.Section, JObject.Parse(JsonConvert.SerializeObject(option))); + } + File.WriteAllText(this.FileName, JsonConvert.SerializeObject(jObject, Formatting.Indented)); + } + } +} \ No newline at end of file diff --git a/Yi.Framework.Net6/Yi.Framework.WebCore/BuilderExtend/OptionsWritable/OptionsWritableBase.cs b/Yi.Framework.Net6/Yi.Framework.WebCore/BuilderExtend/OptionsWritable/OptionsWritableBase.cs new file mode 100644 index 00000000..e1147e94 --- /dev/null +++ b/Yi.Framework.Net6/Yi.Framework.WebCore/BuilderExtend/OptionsWritable/OptionsWritableBase.cs @@ -0,0 +1,29 @@ + +using Microsoft.Extensions.Options; +using System; + +namespace Yi.Framework.WebCore.BuilderExtend.OptionsWritable; + +public abstract class OptionsWritableBase : IOptionsWritable where TOptions : class, new() +{ + public OptionsWritableBase( + IOptionsMonitor options, + string section) + { + this.Monitor = options; + this.Section = section; + } + + public IOptionsMonitor Monitor { get; } + + public string Section { get; } + + public TOptions Value => this.Monitor.CurrentValue ?? new TOptions(); + + public TOptions Get(string name) + { + return this.Monitor.Get(name); + } + + public abstract void Update(Action configuration); +} \ No newline at end of file diff --git a/Yi.Framework.Net6/Yi.Framework.WebCore/BuilderExtend/OptionsWritable/OptionsWritableConfigurationServiceCollectionExtensions.cs b/Yi.Framework.Net6/Yi.Framework.WebCore/BuilderExtend/OptionsWritable/OptionsWritableConfigurationServiceCollectionExtensions.cs new file mode 100644 index 00000000..d6d761d9 --- /dev/null +++ b/Yi.Framework.Net6/Yi.Framework.WebCore/BuilderExtend/OptionsWritable/OptionsWritableConfigurationServiceCollectionExtensions.cs @@ -0,0 +1,41 @@ +using Microsoft.Extensions.Configuration; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Options; +using System; +using System.Configuration; +using Yi.Framework.WebCore.BuilderExtend.OptionsWritable; +using Yi.Framework.WebCore.BuilderExtend.OptionsWritable.Internal; + +namespace Yi.Framework.WebCore.BuilderExtend; + +public static class OptionsWritableConfigurationServiceCollectionExtensions +{ + public static void ConfigureJson(this IServiceCollection services, Microsoft.Extensions.Configuration.ConfigurationManager configuration, string jsonFilePath) + where TOption : class, new() + { + ConfigureJson(services, configuration.GetSection(typeof(TOption).Name), jsonFilePath); + } + + public static void ConfigureJson(this IServiceCollection services, IConfigurationSection section, string jsonFilePath) + where TOption : class, new() + { + services.Configure(section); + services.AddTransient>(provider => + new JsonOptionsWritable(provider.GetRequiredService>(), section.Key, jsonFilePath)); + } + + public static void ConfigureJson(this IServiceCollection services, Microsoft.Extensions.Configuration.ConfigurationManager configuration, Func jsonFilePathFunc) + where TOption : class, new() + { + ConfigureJson(services, configuration.GetSection(typeof(TOption).Name), jsonFilePathFunc); + } + + public static void ConfigureJson(this IServiceCollection services, IConfigurationSection section, Func jsonFilePathFunc) + where TOption : class, new() + { + services.Configure(section); + + services.AddTransient>(provider => + new JsonOptionsWritable(provider.GetRequiredService>(), section.Key, jsonFilePathFunc.Invoke(provider))); + } +} \ No newline at end of file diff --git a/Yi.Framework.Net6/Yi.Framework.WebCore/Yi.Framework.WebCore.csproj b/Yi.Framework.Net6/Yi.Framework.WebCore/Yi.Framework.WebCore.csproj index 1a6baaf2..bc7336af 100644 --- a/Yi.Framework.Net6/Yi.Framework.WebCore/Yi.Framework.WebCore.csproj +++ b/Yi.Framework.Net6/Yi.Framework.WebCore/Yi.Framework.WebCore.csproj @@ -37,4 +37,8 @@ + + + + From 844a7b455ccc0576d4925ee50a1721312534cd55 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=88=E6=B7=B3?= Date: Thu, 15 Sep 2022 18:40:24 +0800 Subject: [PATCH 02/25] =?UTF-8?q?=E9=89=B4=E6=9D=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controllers/TestController.cs | 7 ++++ .../Yi.Framework.ApiMicroservice/Program.cs | 2 +- .../Yi.Framework.WebCore/CommonExtend.cs | 2 +- .../MiddlewareExtend/JwtExtension.cs | 33 +++++++++++++++---- 4 files changed, 35 insertions(+), 9 deletions(-) diff --git a/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Controllers/TestController.cs b/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Controllers/TestController.cs index b52deaf4..6e8cdb28 100644 --- a/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Controllers/TestController.cs +++ b/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Controllers/TestController.cs @@ -197,5 +197,12 @@ namespace Yi.Framework.ApiMicroservice.Controllers var treeData = Common.Helper.TreeHelper.SetTree(vueRouterModels); return Result.Success().SetData(treeData); } + + [Authorize] + [HttpGet] + public Result AuthorizeTest() + { + return Result.Success(); + } } } diff --git a/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Program.cs b/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Program.cs index 33507d35..78745b74 100644 --- a/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Program.cs +++ b/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Program.cs @@ -1,3 +1,4 @@ +global using System; using Autofac.Extensions.DependencyInjection; using Yi.Framework.WebCore.BuilderExtend; using Yi.Framework.Core; @@ -11,7 +12,6 @@ using Yi.Framework.WebCore.AttributeExtend; using Yi.Framework.WebCore.SignalRHub; - var builder = WebApplication.CreateBuilder(args); builder.Configuration.AddCommandLine(args); builder.WebHost.UseUrls(builder.Configuration.GetValue("StartUrl")); diff --git a/Yi.Framework.Net6/Yi.Framework.WebCore/CommonExtend.cs b/Yi.Framework.Net6/Yi.Framework.WebCore/CommonExtend.cs index ebc23248..a7a81169 100644 --- a/Yi.Framework.Net6/Yi.Framework.WebCore/CommonExtend.cs +++ b/Yi.Framework.Net6/Yi.Framework.WebCore/CommonExtend.cs @@ -38,7 +38,7 @@ namespace Yi.Framework.WebCore long resId = 0; try { - claimlist = httpContext.AuthenticateAsync().Result.Principal.Claims; + claimlist = httpContext.User.Claims; resId = Convert.ToInt64(claimlist.FirstOrDefault(u => u.Type == JwtRegisteredClaimNames.Sid).Value); } catch diff --git a/Yi.Framework.Net6/Yi.Framework.WebCore/MiddlewareExtend/JwtExtension.cs b/Yi.Framework.Net6/Yi.Framework.WebCore/MiddlewareExtend/JwtExtension.cs index 451b3496..fc73ef92 100644 --- a/Yi.Framework.Net6/Yi.Framework.WebCore/MiddlewareExtend/JwtExtension.cs +++ b/Yi.Framework.Net6/Yi.Framework.WebCore/MiddlewareExtend/JwtExtension.cs @@ -5,9 +5,11 @@ using Microsoft.IdentityModel.Tokens; using System; using System.IO; using System.Text; +using System.Threading.Tasks; using Yi.Framework.Common.Const; using Yi.Framework.Common.Helper; using Yi.Framework.Common.IOCOptions; +using Yi.Framework.Common.Models; using Yi.Framework.Core; namespace Yi.Framework.WebCore.MiddlewareExtend @@ -25,15 +27,32 @@ namespace Yi.Framework.WebCore.MiddlewareExtend services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme) .AddJwtBearer(options => { + options.Events = new JwtBearerEvents + { + OnAuthenticationFailed = (context) => + { + return Task.CompletedTask; + }, + OnMessageReceived = (context) => + { + return Task.CompletedTask; + }, + OnChallenge = (context) => + { + return Task.CompletedTask; + }, + }; + options.TokenValidationParameters = new TokenValidationParameters { - ValidateIssuer = true,//是否验证Issuer - ValidateAudience = true,//是否验证Audience - ValidateLifetime = true,//是否验证失效时间 - ValidateIssuerSigningKey = true,//是否验证SecurityKey - ValidAudience = jwtOptions.Audience,//Audience - ValidIssuer = jwtOptions.Issuer,//Issuer,这两项和前面签发jwt的设置一致 - IssuerSigningKey = new RsaSecurityKey(RSAFileHelper.GetPublicKey()) + ClockSkew = TimeSpan.Zero,//过期缓冲时间 + ValidateIssuer = true,//是否验证Issuer + ValidateAudience = true,//是否验证Audience + ValidateLifetime = true,//是否验证失效时间 + ValidateIssuerSigningKey = true,//是否验证SecurityKey + ValidAudience = jwtOptions.Audience,//Audience + ValidIssuer = jwtOptions.Issuer,//Issuer,这两项和前面签发jwt的设置一致 + IssuerSigningKey = new RsaSecurityKey(RSAFileHelper.GetPublicKey()) }; }); return services; From 52b8bc8909b339730006582c3f8752808f26635c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=88=E6=B7=B3?= Date: Thu, 15 Sep 2022 18:44:12 +0800 Subject: [PATCH 03/25] =?UTF-8?q?=E4=B8=8A=E4=B8=8B=E6=96=87=E5=AF=B9?= =?UTF-8?q?=E8=B1=A1=E8=8E=B7=E5=8F=96=E7=94=A8=E6=88=B7id=E6=89=A9?= =?UTF-8?q?=E5=B1=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controllers/AccountController.cs | 8 ++++---- Yi.Framework.Net6/Yi.Framework.WebCore/CommonExtend.cs | 8 +++++++- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Controllers/AccountController.cs b/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Controllers/AccountController.cs index e9527636..4fda8ac8 100644 --- a/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Controllers/AccountController.cs +++ b/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Controllers/AccountController.cs @@ -110,7 +110,7 @@ namespace Yi.Framework.ApiMicroservice.Controllers public async Task GetUserAllInfo() { //通过鉴权jwt获取到用户的id - var userId = HttpContext.GetCurrentUserEntityInfo(out _).Id; + var userId = HttpContext.GetUserIdInfo(); var data = await _iUserService.GetUserAllInfo(userId); data.Menus.Clear(); return Result.Success().SetData(data); @@ -123,7 +123,7 @@ namespace Yi.Framework.ApiMicroservice.Controllers [HttpGet] public async Task GetRouterInfo() { - var userId = HttpContext.GetCurrentUserEntityInfo(out _).Id; + var userId = HttpContext.GetUserIdInfo(); var data = await _iUserService.GetUserAllInfo(userId); //将后端菜单转换成前端路由,组件级别需要过滤 @@ -144,7 +144,7 @@ namespace Yi.Framework.ApiMicroservice.Controllers user.Salt = null; //修改需要赋值上主键哦 - user.Id = HttpContext.GetCurrentUserEntityInfo(out _).Id; + user.Id = HttpContext.GetUserIdInfo(); return Result.Success().SetStatus(await _iUserService._repository.UpdateIgnoreNullAsync(user)); } @@ -156,7 +156,7 @@ namespace Yi.Framework.ApiMicroservice.Controllers [HttpPut] public async Task UpdatePassword(UpdatePasswordDto dto) { - long userId = HttpContext.GetCurrentUserEntityInfo(out _).Id; + long userId = HttpContext.GetUserIdInfo(); if (await _iUserService.UpdatePassword(dto, userId)) { diff --git a/Yi.Framework.Net6/Yi.Framework.WebCore/CommonExtend.cs b/Yi.Framework.Net6/Yi.Framework.WebCore/CommonExtend.cs index a7a81169..7f8a1214 100644 --- a/Yi.Framework.Net6/Yi.Framework.WebCore/CommonExtend.cs +++ b/Yi.Framework.Net6/Yi.Framework.WebCore/CommonExtend.cs @@ -26,13 +26,19 @@ namespace Yi.Framework.WebCore return "XMLHttpRequest".Equals(header); } + + public static long GetUserIdInfo(this HttpContext httpContext) + { + return Convert.ToInt64(httpContext.User.Claims.FirstOrDefault(u => u.Type== JwtRegisteredClaimNames.Sid)); + } + /// /// 基于HttpContext,当前鉴权方式解析,获取用户信息 /// 现在使用redis作为缓存,不需要将菜单存放至jwt中了 /// /// /// - public static UserEntity GetCurrentUserEntityInfo(this HttpContext httpContext, out List menuIds) + public static UserEntity GetUserEntityInfo(this HttpContext httpContext, out List menuIds) { IEnumerable claimlist = null; long resId = 0; From 0cc326836c90c6e492330d202b0f4a18de008c6c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=88=E6=B7=B3?= Date: Thu, 15 Sep 2022 18:59:01 +0800 Subject: [PATCH 04/25] =?UTF-8?q?=E6=95=B0=E6=8D=AE=E8=8C=83=E5=9B=B4?= =?UTF-8?q?=E6=9E=9A=E4=B8=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controllers/AccountController.cs | 3 +++ .../Yi.Framework.Common/Enum/DataScopeEnum.cs | 17 +++++++++++++++++ .../Yi.Framework.WebCore/CommonExtend.cs | 3 ++- 3 files changed, 22 insertions(+), 1 deletion(-) create mode 100644 Yi.Framework.Net6/Yi.Framework.Common/Enum/DataScopeEnum.cs diff --git a/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Controllers/AccountController.cs b/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Controllers/AccountController.cs index 4fda8ac8..f82fc405 100644 --- a/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Controllers/AccountController.cs +++ b/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Controllers/AccountController.cs @@ -23,6 +23,7 @@ namespace Yi.Framework.ApiMicroservice.Controllers /// 账户管理 /// [ApiController] + [Authorize] [Route("api/[controller]/[action]")] public class AccountController : ControllerBase { @@ -41,6 +42,7 @@ namespace Yi.Framework.ApiMicroservice.Controllers /// /// [HttpGet] + [AllowAnonymous] public async Task RestCC() { var user= await _iUserService._repository.GetFirstAsync(u => u.UserName == "cc"); @@ -96,6 +98,7 @@ namespace Yi.Framework.ApiMicroservice.Controllers /// /// [HttpPost] + [AllowAnonymous] public Result Logout() { return Result.Success("安全登出成功!"); diff --git a/Yi.Framework.Net6/Yi.Framework.Common/Enum/DataScopeEnum.cs b/Yi.Framework.Net6/Yi.Framework.Common/Enum/DataScopeEnum.cs new file mode 100644 index 00000000..ce2bcb1d --- /dev/null +++ b/Yi.Framework.Net6/Yi.Framework.Common/Enum/DataScopeEnum.cs @@ -0,0 +1,17 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Yi.Framework.Common.Enum +{ + public enum DataScopeEnum + { + All = 0, + Custom = 1, + Dept = 2, + DeptAndUnder = 3, + User = 4 + } +} diff --git a/Yi.Framework.Net6/Yi.Framework.WebCore/CommonExtend.cs b/Yi.Framework.Net6/Yi.Framework.WebCore/CommonExtend.cs index 7f8a1214..69680d71 100644 --- a/Yi.Framework.Net6/Yi.Framework.WebCore/CommonExtend.cs +++ b/Yi.Framework.Net6/Yi.Framework.WebCore/CommonExtend.cs @@ -29,7 +29,8 @@ namespace Yi.Framework.WebCore public static long GetUserIdInfo(this HttpContext httpContext) { - return Convert.ToInt64(httpContext.User.Claims.FirstOrDefault(u => u.Type== JwtRegisteredClaimNames.Sid)); + var p = httpContext; + return Convert.ToInt64(httpContext .User.Claims.FirstOrDefault(u => u.Type== JwtRegisteredClaimNames.Sid).Value); } /// From 2a4f6461818ab200c0b96eaeabe52f3cfba46a7a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=88=E6=B7=B3?= Date: Thu, 15 Sep 2022 19:05:57 +0800 Subject: [PATCH 05/25] =?UTF-8?q?=E6=95=B0=E6=8D=AE=E6=9D=83=E9=99=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Yi.Framework.Common/Enum/DataScopeEnum.cs | 10 +-- .../Yi.Framework.Core/DbFiterExtend.cs | 90 +++++++++++++++++++ 2 files changed, 95 insertions(+), 5 deletions(-) create mode 100644 Yi.Framework.Net6/Yi.Framework.Core/DbFiterExtend.cs diff --git a/Yi.Framework.Net6/Yi.Framework.Common/Enum/DataScopeEnum.cs b/Yi.Framework.Net6/Yi.Framework.Common/Enum/DataScopeEnum.cs index ce2bcb1d..12641d45 100644 --- a/Yi.Framework.Net6/Yi.Framework.Common/Enum/DataScopeEnum.cs +++ b/Yi.Framework.Net6/Yi.Framework.Common/Enum/DataScopeEnum.cs @@ -8,10 +8,10 @@ namespace Yi.Framework.Common.Enum { public enum DataScopeEnum { - All = 0, - Custom = 1, - Dept = 2, - DeptAndUnder = 3, - User = 4 + ALL = 0, + CUSTOM = 1, + DEPT = 2, + DEPT_FOLLOW = 3, + USER = 4 } } diff --git a/Yi.Framework.Net6/Yi.Framework.Core/DbFiterExtend.cs b/Yi.Framework.Net6/Yi.Framework.Core/DbFiterExtend.cs new file mode 100644 index 00000000..621ce4c9 --- /dev/null +++ b/Yi.Framework.Net6/Yi.Framework.Core/DbFiterExtend.cs @@ -0,0 +1,90 @@ +//using Brick.Common; +//using Brick.Common.Const; +//using Brick.Core; +//using Brick.Grpc; +//using Brick.WebCore.MiddlewareExtend; +//using ETX.Common.Enum; +//using ETX.Entity; +//using ETX.Interface.IService; +//using SqlSugar; +//using System.Linq; +//using Yi.Framework.Common.Enum; +//using Yi.Framework.Model.Models; + +//namespace Yi.Framework.Core +//{ +// public class DbFiterExtend +// { +// public static void Data(SqlSugarClient db) +// { +// //未登录情况 +// //if (!ServiceLocator.GetHttp(out var httpContext)) +// //{ +// // return; +// //} + +// //无需授权情况 +// //var account = httpContext.GetAccount(); +// //if (account.IsNull()) +// //{ +// // return; +// //} + +// //超级管理员直接放行 +// //if (ServiceLocator.Admin.Equals(account)) +// //{ +// // return; +// //} + +// //这里可以优化一下 +// //根据缓存获取全部用户信息 +// //var userRoleMenu = ServiceLocator.Instance.GetService().Get(RedisConst.GetStr(RedisConst.UserRoleMenu, account)); + + +// var roles = userRoleMenu.Roles; +// if (roles.IsNull()) +// { +// roles = new (); +// } +// //先测试部门就是LEBG +// long deptId= userRoleMenu.User.DeptId.TryToGuid(); +// long userId =httpContext.GetId(); +// //根据角色的数据范围,来添加相对于的数据权限 +// foreach (var role in roles) +// { +// DataScopeEnum dataScope =(DataScopeEnum)role.DataScope; +// switch (dataScope) +// { +// case DataScopeEnum.ALL: +// //直接放行 +// break; +// case DataScopeEnum.DEPT: +// //只能查询到自己的部门的数据 +// db.QueryFilter.Add(new TableFilterItem(it => it.DeptId== deptId, true)); +// break; +// case DataScopeEnum.USER: +// //只能查询到自己 +// db.QueryFilter.Add(new TableFilterItem(it => it.Id == userId,true)); +// break; +// case DataScopeEnum.CUSTOM: +// //自定义查询 +// var filter = new TableFilterItem(it => SqlFunc.Subqueryable().Where(f => f.DeptId == it.DeptId && f.RoleId == role.Id.TryToGuid()).Any(),true); +// db.QueryFilter.Add(filter); +// break; +// case DataScopeEnum.DEPT_FOLLOW: +// //放行自己部门及以下 +// var allChildDepts = db.Queryable().ToChildList(it => it.ParentId, deptId); + +// var filter1 = new TableFilterItem(it => allChildDepts.Select(f => f.Id).ToList().Contains((long)it.DeptId),true); +// db.QueryFilter.Add(filter1); + +// //var filter2 = new TableFilterItem(it => allChildDepts.Select(f => f.Id).ToList().Contains(it.Id),true); +// //db.QueryFilter.Add(filter2); +// break; +// default: +// break; +// } +// } +// } +// } +//} From 71cf85f535e43aecc1c30e8eb3964f7d8d5a3aa2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=88=E6=B7=B3?= Date: Thu, 15 Sep 2022 19:45:51 +0800 Subject: [PATCH 06/25] =?UTF-8?q?=E6=95=B0=E6=8D=AE=E6=9D=83=E9=99=90?= =?UTF-8?q?=E6=9F=A5=E8=AF=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- WebFirst/database/sqlite.db | Bin 634880 -> 634880 bytes .../Config/SwaggerDoc.xml | 21 ++++++ .../Controllers/DeptController.cs | 23 +++++- .../Controllers/RoleController.cs | 2 + .../yi-sqlsugar-dev.db | Bin 151552 -> 151552 bytes .../Yi.Framework.Interface/IDeptService.cs | 8 +++ .../Yi.Framework.Model/RoleEntity.cs | 6 +- .../Yi.Framework.Service/DeptService.cs | 5 ++ Yi.Vue3.X.RuoYi/src/api/system/dept.js | 9 +++ Yi.Vue3.X.RuoYi/src/api/system/role.js | 12 ++-- .../src/views/system/role/index.vue | 67 +++++++++++------- 11 files changed, 117 insertions(+), 36 deletions(-) diff --git a/WebFirst/database/sqlite.db b/WebFirst/database/sqlite.db index 661d2ca7c96e8f4b5914b54d9939a9d0c499ff30..6f908b4c7c286324f7bf7bbb5de2179fa33c0183 100644 GIT binary patch delta 62 zcmZp8pw{p}ZGyDm9|i`7*+2{f-4k_;8UHjUv?egNCNQ-oFt;YKv?j2&Ca|?8u(u{~ KY)#-?upR&_BocA} delta 62 zcmZp8pw{p}ZGyDmPX-2t*+2{fofCD88Gkk=v?egNCNQ-oFt;YKv?j2&Ca|?8u(u{~ KY)#-?upR&@+Y)L3 diff --git a/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Config/SwaggerDoc.xml b/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Config/SwaggerDoc.xml index 5c7257c5..b1d379e1 100644 --- a/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Config/SwaggerDoc.xml +++ b/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Config/SwaggerDoc.xml @@ -181,6 +181,27 @@ + + + 添加 + + + + + + + 更新 + + + + + + + 根据角色id获取该角色下全部部门 + + + + 动态条件分页查询 diff --git a/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Controllers/DeptController.cs b/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Controllers/DeptController.cs index b9fb1de5..e6e74b00 100644 --- a/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Controllers/DeptController.cs +++ b/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Controllers/DeptController.cs @@ -37,15 +37,36 @@ namespace Yi.Framework.ApiMicroservice.Controllers } - + /// + /// 添加 + /// + /// + /// public override async Task Add(DeptEntity entity) { return await base.Add(entity); } + /// + /// 更新 + /// + /// + /// public override async Task Update(DeptEntity entity) { return await base.Update(entity); } + + /// + /// 根据角色id获取该角色下全部部门 + /// + /// + /// + [HttpGet] + [Route("{id}")] + public async Task GetListByRoleId(long id) + { + return Result.Success().SetData(await _iDeptService.GetListByRoleId(id)); + } } } diff --git a/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Controllers/RoleController.cs b/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Controllers/RoleController.cs index 84703810..738acd95 100644 --- a/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Controllers/RoleController.cs +++ b/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Controllers/RoleController.cs @@ -87,5 +87,7 @@ namespace Yi.Framework.ApiMicroservice.Controllers return Result.Success().SetData(await _iRoleService._repository.UpdateIgnoreNullAsync(new RoleEntity() { Id = roleId, IsDeleted = isDel })); } + + } } diff --git a/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/yi-sqlsugar-dev.db b/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/yi-sqlsugar-dev.db index 6b62182e49aa08886dc48df008666acc385cce7f..6010d8eb458d1aa4e7ada590e64a95d9987c3deb 100644 GIT binary patch delta 131 zcmZozz}c{XbAmMEr-?Gote+V4f)h5T%=70dV_@NvVBi<$JHWqgGhcuNA0x+P^*DbP z{$vKP$yIS~{Gm*|Z1N1o&KwL3!i?e^lUw3E_`Mi;*(4c^9f4wkoD3Y3)#7bg7#JA5 fC#T1|^9L~VvPnZU2y%#WOfHOfZc12|!1w_GM1~z< delta 253 zcmZozz}c{XbAmMEyNNQ+tnV1~+*fQ&ndi@QhJl4of`MOxuZ%x=GhcuNA0xwL^*Dc) z5GEeB$yIS~ley!0qWHHk_((E1GjK342y@7a9^L&t*-3!m+1BnC>!%tS7#ZmrSn3)Y zDj1qt8CzNznCn@Zo0}LI8ygxKL)0V}^9M2VumO#5=I{hFj2(ey334(_R*Sb~@n;6w zl^*XNRGD6$l94nG>u+lr6F>?2rKC^WFW=C$vFqGto6NQ!q5QGBLL@Fn|b| g>Ka%m7@Am_m;l|NXKZL`ZfazbmD7~4EP?R@0IR}5%>V!Z diff --git a/Yi.Framework.Net6/Yi.Framework.Interface/IDeptService.cs b/Yi.Framework.Net6/Yi.Framework.Interface/IDeptService.cs index 26e345a1..bbb1a275 100644 --- a/Yi.Framework.Net6/Yi.Framework.Interface/IDeptService.cs +++ b/Yi.Framework.Net6/Yi.Framework.Interface/IDeptService.cs @@ -14,5 +14,13 @@ namespace Yi.Framework.Interface /// /// Task> SelctGetList(DeptEntity dept); + + + /// + /// 根据角色id获取该角色的部门权限 + /// + /// + /// + Task> GetListByRoleId(long roleId); } } diff --git a/Yi.Framework.Net6/Yi.Framework.Model/RoleEntity.cs b/Yi.Framework.Net6/Yi.Framework.Model/RoleEntity.cs index 37fe431d..3aec15c2 100644 --- a/Yi.Framework.Net6/Yi.Framework.Model/RoleEntity.cs +++ b/Yi.Framework.Net6/Yi.Framework.Model/RoleEntity.cs @@ -8,9 +8,11 @@ namespace Yi.Framework.Model.Models public partial class RoleEntity { - //[Navigate(typeof(UserRoleEntity), nameof(UserRoleEntity.RoleId), nameof(UserRoleEntity.UserId))] - //public List Users { get; set; } + [Navigate(typeof(RoleMenuEntity),nameof(RoleMenuEntity.RoleId),nameof(RoleMenuEntity.MenuId))] public List Menus { get; set; } + + [Navigate(typeof(RoleDeptEntity), nameof(RoleDeptEntity.RoleId), nameof(RoleDeptEntity.DeptId))] + public List Depts { get; set; } } } diff --git a/Yi.Framework.Net6/Yi.Framework.Service/DeptService.cs b/Yi.Framework.Net6/Yi.Framework.Service/DeptService.cs index a031e847..fc04ad51 100644 --- a/Yi.Framework.Net6/Yi.Framework.Service/DeptService.cs +++ b/Yi.Framework.Net6/Yi.Framework.Service/DeptService.cs @@ -21,5 +21,10 @@ namespace Yi.Framework.Service return data; } + + public async Task> GetListByRoleId(long roleId) + { + return (await _repository._Db.Queryable().Includes(r => r.Depts).SingleAsync(r => r.Id == roleId)).Depts; + } } } diff --git a/Yi.Vue3.X.RuoYi/src/api/system/dept.js b/Yi.Vue3.X.RuoYi/src/api/system/dept.js index 0d85cd7f..cf28c932 100644 --- a/Yi.Vue3.X.RuoYi/src/api/system/dept.js +++ b/Yi.Vue3.X.RuoYi/src/api/system/dept.js @@ -54,4 +54,13 @@ export function delDept(deptId) { method: 'delete', data:deptId }) +} + + +// 根据角色ID查询菜单下拉树结构 +export function roleDeptTreeselect(roleId) { + return request({ + url: '/dept/getListByRoleId/' + roleId, + method: 'get' + }) } \ No newline at end of file diff --git a/Yi.Vue3.X.RuoYi/src/api/system/role.js b/Yi.Vue3.X.RuoYi/src/api/system/role.js index 60ec5f10..7f401116 100644 --- a/Yi.Vue3.X.RuoYi/src/api/system/role.js +++ b/Yi.Vue3.X.RuoYi/src/api/system/role.js @@ -113,12 +113,12 @@ export function authUserSelectAll(data) { } // 根据角色ID查询部门树结构 -export function deptTreeSelect(roleId) { - return request({ - url: '/system/role/deptTree/' + roleId, - method: 'get' - }) -} +// export function deptTreeSelect(roleId) { +// return request({ +// url: '/system/role/deptTree/' + roleId, +// method: 'get' +// }) +// } // 获取角色选择框列表 export function roleOptionselect() { return request({ diff --git a/Yi.Vue3.X.RuoYi/src/views/system/role/index.vue b/Yi.Vue3.X.RuoYi/src/views/system/role/index.vue index 99d9cc4d..ea2bfefb 100644 --- a/Yi.Vue3.X.RuoYi/src/views/system/role/index.vue +++ b/Yi.Vue3.X.RuoYi/src/views/system/role/index.vue @@ -137,18 +137,18 @@ - + - + - + - + 展开/折叠 全选/全不选 父子联动 @@ -165,13 +165,14 @@ + From c63f9de5c51bd577b268d572eee3c1b774dfe04a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=88=E6=B7=B3?= Date: Fri, 16 Sep 2022 19:04:40 +0800 Subject: [PATCH 08/25] =?UTF-8?q?=E6=95=B0=E6=8D=AE=E6=9D=83=E9=99=90?= =?UTF-8?q?=E6=9B=B4=E6=96=B0=E9=A1=B5=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../yi-sqlsugar-dev.db | Bin 151552 -> 151552 bytes .../src/views/system/role/index.vue | 22 ++++++++---------- 2 files changed, 10 insertions(+), 12 deletions(-) diff --git a/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/yi-sqlsugar-dev.db b/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/yi-sqlsugar-dev.db index 9861e3b1b5ad8636772619ab75602312ff8f2098..e3211c5fe3759b5d3decc383ffec6a3f8252c8d4 100644 GIT binary patch delta 428 zcmZozz}c{XbAmMEzlk!=jQ=(!T!_`Ov@$TZGPTe%GO{o;HZU_XFf!6Lu+%j)Q!qqG zSsEK!nl(qoZI6m$T(wbxllKw>{~`Vsem8y&zEgZXe13cayq9>VY*tjL=B@w1#=v0B z00wNLXCf1uoCKIf*`oh$a1vlZHr~R@)ZEI%OwYu`Nc2SA@i$EZ3^ts+Y$&>;&dg{M zV8W&w?l>gf93b8GNS1@OGZNOmI{{=lJ2uN12c93Aim;6;xKX`INLYqGX*FB0I5=Hga7~l delta 335 zcmZozz}c{XbAmMEuZc3wjK4M}T!_`Ourf8WGO*M$H#0IdH!?ReFf!6Lu+%j)Q!qqG z8JiiI8#hPAZI6m$T(wb*gHM2g{}6u*zZ*XX-zmNxK0iJI-b { menuIds.push(m.id); }); - - nextTick(() => { - menuIds.forEach((v) => { + + nextTick(() => { + menuIds.forEach((v) => { menuRef.value.setChecked(v, true, false); }); @@ -626,17 +626,15 @@ function getDeptTree(roleId) { }); deptOptions.value = proxy.handleTree(selectList, "id"); - const deptIds = []; + let deptIds = []; roleDeptTreeselect(roleId).then((response) => { - - deptIds= response.data.map((x) => x.id) + deptIds = response.data.map((x) => x.id); + // nextTick(() => { + if (deptRef.value) { + deptRef.value.setCheckedKeys(deptIds); + } + // }); }); - - nextTick(() => { - if (deptRef.value) { - deptRef.value.setCheckedKeys(deptIds); - } - }); }); } /** 树权限(展开/折叠)*/ From 9618bd891ff9aae0d1fb7620ce90fbfd3b63a66d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=88=E6=B7=B3?= Date: Fri, 16 Sep 2022 19:18:24 +0800 Subject: [PATCH 09/25] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E7=94=A8=E6=88=B7?= =?UTF-8?q?=E6=80=A7=E5=88=AB=E5=AD=97=E6=AE=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- WebFirst/database/sqlite.db | Bin 634880 -> 634880 bytes .../yi-sqlsugar-dev.db | Bin 151552 -> 151552 bytes .../ModelsTemplate/UserEntity.cs | 5 +++++ .../src/views/system/user/index.vue | 3 +-- 4 files changed, 6 insertions(+), 2 deletions(-) diff --git a/WebFirst/database/sqlite.db b/WebFirst/database/sqlite.db index 6f908b4c7c286324f7bf7bbb5de2179fa33c0183..7b57d339f00c70a869e3f7b1372727180ce11caf 100644 GIT binary patch delta 167 zcmZp8pw{p}ZGw~#Ga~~7!)zdif!>KaMoi3%8xu_Q8N-^V>bFnTXWTwjpUIj@z)Zo= z(#p`l%E(C1)XdnzWOBg^jqMypOn+nf9N6qAaEN8QQz%mnvjQuFbXyoV zgRn3M2Zy9EBSUa%1rR-JSpKwQb!J|PP5ZqFCLm@8Viq7~1!6WJW(Q)9?e`)$mBIlN C=P|?p delta 165 zcmZp8pw{p}ZGw~#(;o%~hS@+21KksKjF_1IY)mlGXAEtgs^30UpK<$CeI{!rL1P6& zGb>{QD??K~149dA6Vu6wPc^o48ZrHrWwf5o8o*S!*-_vK%XX(wrW$4iWd>1E4h{}k zQAUP<{NfT2e!6M;lfAu}DLMIh>0a&kBA9@f8Hibcm=%cGfS4VKIkw-6;8Y3+02F~V AjQ{`u diff --git a/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/yi-sqlsugar-dev.db b/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/yi-sqlsugar-dev.db index e3211c5fe3759b5d3decc383ffec6a3f8252c8d4..f7907dacfe3bb8825e1dfcb6ee3e7755d570a12a 100644 GIT binary patch delta 202 zcmZozz}c{XbApr*6B7digDMcifc-=rBPJ%MjR|Y`nYdSO<`b~vW@3n+>?a*9(-_4p z$;QCQV9emm!64pfY0DtVz#ys2z{$YCIoVNORme=i(9+7#+{(yQ&)m?|(Ady)a)o>Y zm$8MBB@hG2$!#)^nE2H [SugarColumn(ColumnName="DeptId" )] public long? DeptId { get; set; } + /// + /// 性别 + /// + [SugarColumn(ColumnName="Sex" )] + public int? Sex { get; set; } } } diff --git a/Yi.Vue3.X.RuoYi/src/views/system/user/index.vue b/Yi.Vue3.X.RuoYi/src/views/system/user/index.vue index 89ad5b23..74636c8f 100644 --- a/Yi.Vue3.X.RuoYi/src/views/system/user/index.vue +++ b/Yi.Vue3.X.RuoYi/src/views/system/user/index.vue @@ -158,8 +158,7 @@ - + From dcf82d041a6e26e1bce6414ac8fdae2e3cbbf75e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=88=E6=B7=B3?= Date: Fri, 16 Sep 2022 19:57:56 +0800 Subject: [PATCH 10/25] =?UTF-8?q?=E9=AA=8C=E8=AF=81=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Config/SwaggerDoc.xml | 6 ++++++ .../Controllers/AccountController.cs | 11 +++++++++++ 2 files changed, 17 insertions(+) diff --git a/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Config/SwaggerDoc.xml b/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Config/SwaggerDoc.xml index 704bf226..31e156df 100644 --- a/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Config/SwaggerDoc.xml +++ b/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Config/SwaggerDoc.xml @@ -61,6 +61,12 @@ + + + 验证码 + + + Json To Sql 类比模式,通用模型 diff --git a/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Controllers/AccountController.cs b/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Controllers/AccountController.cs index f82fc405..b69e7fd6 100644 --- a/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Controllers/AccountController.cs +++ b/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Controllers/AccountController.cs @@ -167,5 +167,16 @@ namespace Yi.Framework.ApiMicroservice.Controllers } return Result.Error("更新失败!"); } + + /// + /// 验证码 + /// + /// + [AllowAnonymous] + [HttpGet] + public async Task CaptchaImage() + { + return Result.Success().SetData(new { uuid=123,img="dasdas"}); + } } } From 7905f82d651b7fd0300113c84d5ed4e877434b19 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=88=E6=B7=B3?= Date: Fri, 16 Sep 2022 20:01:01 +0800 Subject: [PATCH 11/25] =?UTF-8?q?=E9=AA=8C=E8=AF=81=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controllers/AccountController.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Controllers/AccountController.cs b/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Controllers/AccountController.cs index b69e7fd6..56574d95 100644 --- a/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Controllers/AccountController.cs +++ b/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Controllers/AccountController.cs @@ -176,7 +176,7 @@ namespace Yi.Framework.ApiMicroservice.Controllers [HttpGet] public async Task CaptchaImage() { - return Result.Success().SetData(new { uuid=123,img="dasdas"}); + return Result.Success().SetData(new { uuid=123,img="123456789"}); } } } From 2a8d436267261828ac601585ee9901213a737906 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=88=E6=B7=B3?= Date: Sat, 17 Sep 2022 18:09:18 +0800 Subject: [PATCH 12/25] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E9=AA=8C=E8=AF=81?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Program.cs | 5 ++++- .../Yi.Framework.Common/Yi.Framework.Common.csproj | 1 + 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Program.cs b/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Program.cs index 78745b74..54d8caca 100644 --- a/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Program.cs +++ b/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Program.cs @@ -10,7 +10,7 @@ using Yi.Framework.Language; using Microsoft.Extensions.Localization; using Yi.Framework.WebCore.AttributeExtend; using Yi.Framework.WebCore.SignalRHub; - +using Hei.Captcha; var builder = WebApplication.CreateBuilder(args); builder.Configuration.AddCommandLine(args); @@ -117,6 +117,8 @@ builder.Services.AddLocalizerService(); //signalR #endregion builder.Services.AddSignalR(); + +builder.Services.AddHeiCaptcha(); //----------------------------------------------------------------------------------------------------------- var app = builder.Build(); #region @@ -138,6 +140,7 @@ ServiceLocator.Instance = app.Services; //ץȡע #endregion //app.UseErrorHandlingService(); + #region //̬ļע #endregion diff --git a/Yi.Framework.Net6/Yi.Framework.Common/Yi.Framework.Common.csproj b/Yi.Framework.Net6/Yi.Framework.Common/Yi.Framework.Common.csproj index bcfa819d..02122188 100644 --- a/Yi.Framework.Net6/Yi.Framework.Common/Yi.Framework.Common.csproj +++ b/Yi.Framework.Net6/Yi.Framework.Common/Yi.Framework.Common.csproj @@ -6,6 +6,7 @@ + From a64d493a29d7dc354a628857f70202f53090598e Mon Sep 17 00:00:00 2001 From: chenchun <454313500@qq.com> Date: Sun, 18 Sep 2022 16:46:31 +0800 Subject: [PATCH 13/25] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E9=AA=8C=E8=AF=81?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controllers/AccountController.cs | 19 +++++++++++++------ Yi.Vue3.X.RuoYi/src/api/login.js | 2 +- Yi.Vue3.X.RuoYi/src/views/login.vue | 7 +++++-- 3 files changed, 19 insertions(+), 9 deletions(-) diff --git a/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Controllers/AccountController.cs b/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Controllers/AccountController.cs index 56574d95..6734f462 100644 --- a/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Controllers/AccountController.cs +++ b/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Controllers/AccountController.cs @@ -1,4 +1,5 @@ -using Microsoft.AspNetCore.Authorization; +using Hei.Captcha; +using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; using Microsoft.Extensions.Logging; using System; @@ -30,11 +31,13 @@ namespace Yi.Framework.ApiMicroservice.Controllers private IUserService _iUserService; private JwtInvoker _jwtInvoker; private ILogger _logger; - public AccountController(ILogger logger, IUserService iUserService, JwtInvoker jwtInvoker) + private SecurityCodeHelper _securityCode; + public AccountController(ILogger logger, IUserService iUserService, JwtInvoker jwtInvoker, SecurityCodeHelper securityCode) { _iUserService = iUserService; _jwtInvoker = jwtInvoker; _logger = logger; + _securityCode = securityCode; } /// @@ -45,7 +48,7 @@ namespace Yi.Framework.ApiMicroservice.Controllers [AllowAnonymous] public async Task RestCC() { - var user= await _iUserService._repository.GetFirstAsync(u => u.UserName == "cc"); + var user = await _iUserService._repository.GetFirstAsync(u => u.UserName == "cc"); user.Password = "123456"; user.BuildPassword(); await _iUserService._repository.UpdateIgnoreNullAsync(user); @@ -160,7 +163,7 @@ namespace Yi.Framework.ApiMicroservice.Controllers public async Task UpdatePassword(UpdatePasswordDto dto) { long userId = HttpContext.GetUserIdInfo(); - + if (await _iUserService.UpdatePassword(dto, userId)) { return Result.Success(); @@ -174,9 +177,13 @@ namespace Yi.Framework.ApiMicroservice.Controllers /// [AllowAnonymous] [HttpGet] - public async Task CaptchaImage() + public Result CaptchaImage() { - return Result.Success().SetData(new { uuid=123,img="123456789"}); + var uuid = Guid.NewGuid(); + var code = _securityCode.GetRandomEnDigitalText(4); + //将uuid与code中心化保存起来,登录根据uuid比对即可 + var imgbyte = _securityCode.GetEnDigitalCodeByte(code); + return Result.Success().SetData(new { uuid = uuid, img = imgbyte }); } } } diff --git a/Yi.Vue3.X.RuoYi/src/api/login.js b/Yi.Vue3.X.RuoYi/src/api/login.js index 024370aa..774990dd 100644 --- a/Yi.Vue3.X.RuoYi/src/api/login.js +++ b/Yi.Vue3.X.RuoYi/src/api/login.js @@ -49,7 +49,7 @@ export function logout() { // 获取验证码 export function getCodeImg() { return request({ - url: '/captchaImage', + url: '/account/captchaImage', headers: { isToken: false }, diff --git a/Yi.Vue3.X.RuoYi/src/views/login.vue b/Yi.Vue3.X.RuoYi/src/views/login.vue index bb37ba44..53d24f1e 100644 --- a/Yi.Vue3.X.RuoYi/src/views/login.vue +++ b/Yi.Vue3.X.RuoYi/src/views/login.vue @@ -129,8 +129,8 @@ function getCode() { getCodeImg().then(res => { captchaEnabled.value = res.captchaEnabled === undefined ? true : res.captchaEnabled; if (captchaEnabled.value) { - codeUrl.value = "data:image/gif;base64," + res.img; - loginForm.value.uuid = res.uuid; + codeUrl.value = "data:image/gif;base64," + res.data.img; + loginForm.value.uuid = res.data.uuid; } }); } @@ -188,10 +188,13 @@ getCookie(); color: #bfbfbf; } .login-code { + width: 33%; height: 40px; float: right; + img { + cursor: pointer; vertical-align: middle; } From 483aea5c4f32d6b5feb0e6bbda950ef732e613bb Mon Sep 17 00:00:00 2001 From: chenchun <454313500@qq.com> Date: Sun, 18 Sep 2022 17:22:47 +0800 Subject: [PATCH 14/25] =?UTF-8?q?=E6=95=B0=E6=8D=AE=E6=9D=83=E9=99=90?= =?UTF-8?q?=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controllers/AccountController.cs | 6 +- .../Yi.Framework.ApiMicroservice/Program.cs | 13 ++- .../Yi.Framework.Common/Base/NullValue.cs | 2 + .../Models/ServiceLocator.cs | 10 --- .../Yi.Framework.Core/DbFiterExtend.cs | 90 ------------------- .../Yi.Framework.Core/JwtInvoker.cs | 9 +- .../Yi.Framework.WebCore/CommonExtend.cs | 40 ++++++++- .../DbExtend/DbFiterExtend.cs | 88 ++++++++++++++++++ .../Yi.Framework.WebCore/ServiceLocator.cs | 27 ++++++ 9 files changed, 170 insertions(+), 115 deletions(-) delete mode 100644 Yi.Framework.Net6/Yi.Framework.Common/Models/ServiceLocator.cs delete mode 100644 Yi.Framework.Net6/Yi.Framework.Core/DbFiterExtend.cs create mode 100644 Yi.Framework.Net6/Yi.Framework.WebCore/DbExtend/DbFiterExtend.cs create mode 100644 Yi.Framework.Net6/Yi.Framework.WebCore/ServiceLocator.cs diff --git a/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Controllers/AccountController.cs b/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Controllers/AccountController.cs index 6734f462..b434aa41 100644 --- a/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Controllers/AccountController.cs +++ b/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Controllers/AccountController.cs @@ -64,10 +64,8 @@ namespace Yi.Framework.ApiMicroservice.Controllers [HttpPost] public async Task Login(LoginDto loginDto) { - - //跳过 + //跳过,需要redis缓存获取uuid与code的关系,进行比较即可 //先效验验证码和UUID - UserEntity user = new(); if (await _iUserService.Login(loginDto.UserName, loginDto.Password, o => user = o)) { @@ -181,7 +179,7 @@ namespace Yi.Framework.ApiMicroservice.Controllers { var uuid = Guid.NewGuid(); var code = _securityCode.GetRandomEnDigitalText(4); - //将uuid与code中心化保存起来,登录根据uuid比对即可 + //将uuid与code,Redis缓存中心化保存起来,登录根据uuid比对即可 var imgbyte = _securityCode.GetEnDigitalCodeByte(code); return Result.Success().SetData(new { uuid = uuid, img = imgbyte }); } diff --git a/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Program.cs b/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Program.cs index 54d8caca..d5273f13 100644 --- a/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Program.cs +++ b/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Program.cs @@ -11,6 +11,8 @@ using Microsoft.Extensions.Localization; using Yi.Framework.WebCore.AttributeExtend; using Yi.Framework.WebCore.SignalRHub; using Hei.Captcha; +using Yi.Framework.WebCore; +using Microsoft.Extensions.DependencyInjection; var builder = WebApplication.CreateBuilder(args); builder.Configuration.AddCommandLine(args); @@ -52,9 +54,10 @@ builder.Host.ConfigureLogging(loggingBuilder => #endregion builder.Services.AddIocService(builder.Configuration); #region -//Sqlsugarע +//Sqlsugarע,ǷȨ޹ܣҪRedis #endregion builder.Services.AddSqlsugarServer(); +//builder.Services.AddSqlsugarServer(DbFiterExtend.Data); #region //Quartz #endregion @@ -117,8 +120,14 @@ builder.Services.AddLocalizerService(); //signalR #endregion builder.Services.AddSignalR(); - +#region +//֤ +#endregion builder.Services.AddHeiCaptcha(); +#region +//Http +#endregion +builder.Services.AddHttpContextAccessor(); //----------------------------------------------------------------------------------------------------------- var app = builder.Build(); #region diff --git a/Yi.Framework.Net6/Yi.Framework.Common/Base/NullValue.cs b/Yi.Framework.Net6/Yi.Framework.Common/Base/NullValue.cs index d9379f64..9aa7ab9b 100644 --- a/Yi.Framework.Net6/Yi.Framework.Common/Base/NullValue.cs +++ b/Yi.Framework.Net6/Yi.Framework.Common/Base/NullValue.cs @@ -90,6 +90,8 @@ { #region 一般类型 + + public static Guid TryToGuid(this string guid) { if (Guid.TryParse(guid, out var guid1)) diff --git a/Yi.Framework.Net6/Yi.Framework.Common/Models/ServiceLocator.cs b/Yi.Framework.Net6/Yi.Framework.Common/Models/ServiceLocator.cs deleted file mode 100644 index 09b6c5cd..00000000 --- a/Yi.Framework.Net6/Yi.Framework.Common/Models/ServiceLocator.cs +++ /dev/null @@ -1,10 +0,0 @@ -using System; - -namespace Yi.Framework.Common.Models -{ - public static class ServiceLocator - { - public static IServiceProvider Instance { get; set; } - } - -} diff --git a/Yi.Framework.Net6/Yi.Framework.Core/DbFiterExtend.cs b/Yi.Framework.Net6/Yi.Framework.Core/DbFiterExtend.cs deleted file mode 100644 index 621ce4c9..00000000 --- a/Yi.Framework.Net6/Yi.Framework.Core/DbFiterExtend.cs +++ /dev/null @@ -1,90 +0,0 @@ -//using Brick.Common; -//using Brick.Common.Const; -//using Brick.Core; -//using Brick.Grpc; -//using Brick.WebCore.MiddlewareExtend; -//using ETX.Common.Enum; -//using ETX.Entity; -//using ETX.Interface.IService; -//using SqlSugar; -//using System.Linq; -//using Yi.Framework.Common.Enum; -//using Yi.Framework.Model.Models; - -//namespace Yi.Framework.Core -//{ -// public class DbFiterExtend -// { -// public static void Data(SqlSugarClient db) -// { -// //未登录情况 -// //if (!ServiceLocator.GetHttp(out var httpContext)) -// //{ -// // return; -// //} - -// //无需授权情况 -// //var account = httpContext.GetAccount(); -// //if (account.IsNull()) -// //{ -// // return; -// //} - -// //超级管理员直接放行 -// //if (ServiceLocator.Admin.Equals(account)) -// //{ -// // return; -// //} - -// //这里可以优化一下 -// //根据缓存获取全部用户信息 -// //var userRoleMenu = ServiceLocator.Instance.GetService().Get(RedisConst.GetStr(RedisConst.UserRoleMenu, account)); - - -// var roles = userRoleMenu.Roles; -// if (roles.IsNull()) -// { -// roles = new (); -// } -// //先测试部门就是LEBG -// long deptId= userRoleMenu.User.DeptId.TryToGuid(); -// long userId =httpContext.GetId(); -// //根据角色的数据范围,来添加相对于的数据权限 -// foreach (var role in roles) -// { -// DataScopeEnum dataScope =(DataScopeEnum)role.DataScope; -// switch (dataScope) -// { -// case DataScopeEnum.ALL: -// //直接放行 -// break; -// case DataScopeEnum.DEPT: -// //只能查询到自己的部门的数据 -// db.QueryFilter.Add(new TableFilterItem(it => it.DeptId== deptId, true)); -// break; -// case DataScopeEnum.USER: -// //只能查询到自己 -// db.QueryFilter.Add(new TableFilterItem(it => it.Id == userId,true)); -// break; -// case DataScopeEnum.CUSTOM: -// //自定义查询 -// var filter = new TableFilterItem(it => SqlFunc.Subqueryable().Where(f => f.DeptId == it.DeptId && f.RoleId == role.Id.TryToGuid()).Any(),true); -// db.QueryFilter.Add(filter); -// break; -// case DataScopeEnum.DEPT_FOLLOW: -// //放行自己部门及以下 -// var allChildDepts = db.Queryable().ToChildList(it => it.ParentId, deptId); - -// var filter1 = new TableFilterItem(it => allChildDepts.Select(f => f.Id).ToList().Contains((long)it.DeptId),true); -// db.QueryFilter.Add(filter1); - -// //var filter2 = new TableFilterItem(it => allChildDepts.Select(f => f.Id).ToList().Contains(it.Id),true); -// //db.QueryFilter.Add(filter2); -// break; -// default: -// break; -// } -// } -// } -// } -//} diff --git a/Yi.Framework.Net6/Yi.Framework.Core/JwtInvoker.cs b/Yi.Framework.Net6/Yi.Framework.Core/JwtInvoker.cs index de101ab4..5e948bfb 100644 --- a/Yi.Framework.Net6/Yi.Framework.Core/JwtInvoker.cs +++ b/Yi.Framework.Net6/Yi.Framework.Core/JwtInvoker.cs @@ -37,7 +37,8 @@ namespace Yi.Framework.Core claims.Add(new Claim(JwtRegisteredClaimNames.Nbf, $"{new DateTimeOffset(DateTime.Now).ToUnixTimeSeconds()}")); claims.Add(new Claim(JwtRegisteredClaimNames.Exp, $"{new DateTimeOffset(DateTime.Now.AddMinutes(minutes)).ToUnixTimeSeconds()}")); claims.Add(new Claim(JwtRegisteredClaimNames.Sid, user.Id.ToString())); - + claims.Add(new Claim(JwtRegisteredClaimNames.Name, user.UserName)); + claims.Add(new Claim("deptId", user.DeptId.ToString())); //-----------------------------以下从user的权限表中添加权限-----------------------例如: foreach (var m in menus) @@ -47,12 +48,6 @@ namespace Yi.Framework.Core claims.Add(new Claim("permission", m.PermissionCode.ToString())); } } - - if (isRefresh) - { - claims.Add(new Claim("Re", "true")); - } - var creds = new SigningCredentials(new RsaSecurityKey(Common.Helper.RSAFileHelper.GetKey()), SecurityAlgorithms.RsaSha256); var token = new JwtSecurityToken( issuer: _JWTTokenOptions.Issuer, diff --git a/Yi.Framework.Net6/Yi.Framework.WebCore/CommonExtend.cs b/Yi.Framework.Net6/Yi.Framework.WebCore/CommonExtend.cs index 69680d71..8d269644 100644 --- a/Yi.Framework.Net6/Yi.Framework.WebCore/CommonExtend.cs +++ b/Yi.Framework.Net6/Yi.Framework.WebCore/CommonExtend.cs @@ -26,13 +26,49 @@ namespace Yi.Framework.WebCore return "XMLHttpRequest".Equals(header); } - + /// + /// 通过鉴权完的token获取用户id + /// + /// + /// public static long GetUserIdInfo(this HttpContext httpContext) { var p = httpContext; - return Convert.ToInt64(httpContext .User.Claims.FirstOrDefault(u => u.Type== JwtRegisteredClaimNames.Sid).Value); + return Convert.ToInt64(httpContext.User.Claims.FirstOrDefault(u => u.Type == JwtRegisteredClaimNames.Sid).Value); } + /// + /// 通过鉴权完的token获取用户名 + /// + /// + /// + public static string GetUserNameInfo(this HttpContext httpContext) + { + var p = httpContext; + return httpContext.User.Claims.FirstOrDefault(u => u.Type == JwtRegisteredClaimNames.Name).Value; + } + + /// + /// 通过鉴权完的token获取用户部门 + /// + /// + /// + public static string GetDeptIdInfo(this HttpContext httpContext) + { + var p = httpContext; + return httpContext.User.Claims.FirstOrDefault(u => u.Type == "deptId").Value; + } + + /// + /// 通过鉴权完的token获取权限code + /// + /// + /// + public static string GetPermissionInfo(this HttpContext httpContext) + { + var p = httpContext; + return httpContext.User.Claims.FirstOrDefault(u => u.Type == "permission").Value; + } /// /// 基于HttpContext,当前鉴权方式解析,获取用户信息 /// 现在使用redis作为缓存,不需要将菜单存放至jwt中了 diff --git a/Yi.Framework.Net6/Yi.Framework.WebCore/DbExtend/DbFiterExtend.cs b/Yi.Framework.Net6/Yi.Framework.WebCore/DbExtend/DbFiterExtend.cs new file mode 100644 index 00000000..be89bcd7 --- /dev/null +++ b/Yi.Framework.Net6/Yi.Framework.WebCore/DbExtend/DbFiterExtend.cs @@ -0,0 +1,88 @@ +using Microsoft.Extensions.DependencyInjection; +using SqlSugar; +using System; +using System.Linq; +using Yi.Framework.Common.Enum; +using Yi.Framework.Common.Models; +using Yi.Framework.DTOModel; +using Yi.Framework.Model.Models; +using Yi.Framework.WebCore; + +namespace Yi.Framework.Core +{ + public class DbFiterExtend + { + public static void Data(SqlSugarClient db) + { + //非请求情况 + if (!ServiceLocator.GetHttp(out var httpContext)) + { + return; + } + + //无需授权情况 + var userName = httpContext.GetUserNameInfo(); + if (userName is null) + { + return; + } + + //超级管理员直接放行 + if (ServiceLocator.Admin.Equals(userName)) + { + return; + } + + //这里可以优化一下 + //根据缓存获取全部用户信息 + var userRoleMenu = ServiceLocator.Instance.GetService().Get("用户id"); + + + var roles = userRoleMenu.Roles; + if (roles.IsNull()) + { + roles = new(); + } + //先测试部门就是LEBG + long deptId = (long)userRoleMenu.User.DeptId; + long userId = httpContext.GetUserIdInfo(); + //根据角色的数据范围,来添加相对于的数据权限 + foreach (var role in roles) + { + DataScopeEnum dataScope = (DataScopeEnum)role.DataScope; + switch (dataScope) + { + case DataScopeEnum.ALL: + //直接放行 + break; + case DataScopeEnum.DEPT: + //只能查询到自己的部门的数据 + db.QueryFilter.Add(new TableFilterItem(it => it.DeptId == deptId, true)); + break; + case DataScopeEnum.USER: + //只能查询到自己 + db.QueryFilter.Add(new TableFilterItem(it => it.Id == userId, true)); + break; + case DataScopeEnum.CUSTOM: + //自定义查询 + var filter = new TableFilterItem(it => SqlFunc.Subqueryable().Where(f => f.DeptId == it.DeptId && f.RoleId == (long)role.Id).Any(), true); + db.QueryFilter.Add(filter); + break; + case DataScopeEnum.DEPT_FOLLOW: + //放行自己部门及以下 + var allChildDepts = db.Queryable().ToChildList(it => it.ParentId, deptId); + + var filter1 = new TableFilterItem(it => allChildDepts.Select(f => f.Id).ToList().Contains((long)it.DeptId), true); + db.QueryFilter.Add(filter1); + + //部门无需过滤 + //var filter2 = new TableFilterItem(it => allChildDepts.Select(f => f.Id).ToList().Contains(it.Id),true); + //db.QueryFilter.Add(filter2); + break; + default: + break; + } + } + } + } +} diff --git a/Yi.Framework.Net6/Yi.Framework.WebCore/ServiceLocator.cs b/Yi.Framework.Net6/Yi.Framework.WebCore/ServiceLocator.cs new file mode 100644 index 00000000..d6e235d2 --- /dev/null +++ b/Yi.Framework.Net6/Yi.Framework.WebCore/ServiceLocator.cs @@ -0,0 +1,27 @@ +using Microsoft.AspNetCore.Http; +using Microsoft.Extensions.DependencyInjection; +using System; +using Ubiety.Dns.Core.Common; + +namespace Yi.Framework.WebCore +{ + public static class ServiceLocator + { + public static IServiceProvider Instance { get; set; } + + public static string Admin { get; set; } = "cc"; + + public static bool GetHttp(out HttpContext httpContext) + { + httpContext = null; + var httpContextAccessor = Instance.GetService(); + if (httpContextAccessor is null) + { + return false; + } + httpContext = httpContextAccessor.HttpContext; + return true; + } + } + +} From 1b38ed5c78ac90cca7bc09a7eedf45f83753551b Mon Sep 17 00:00:00 2001 From: chenchun <454313500@qq.com> Date: Sun, 18 Sep 2022 17:49:17 +0800 Subject: [PATCH 15/25] Update README.md --- README.md | 35 ++++++++++++++++++++++++++++++----- 1 file changed, 30 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 1e7558e4..b22ba780 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ - +

Yi框架

一套与SqlSugar一样爽的.Net6低代码开源框架

集大成者,终究轮子

@@ -10,7 +10,7 @@ **** ### 简介: -**中文:意框架**(和他的名字一样“简易”) +**中文:意框架**(和他的名字一样“简易”,同时接入java耳熟能详的Ruoyi Vue3.0前端) 模块分化较多,可根据业务自行引用或抛弃,集大成者,大而全乎,也许你能从中学习到一些独特见解 @@ -34,11 +34,19 @@ Yi框架最新版本标签:`v1.2.0`,具体版本可以查看标签迭代 **分支**: -(本项目由EFCore版本历经3年不断迭代至Sqlsugar版本,现EFcore版本已弃用,目前sqlsugar不带任何业务,之后会更新业务功能) +(本项目由EFCore版本历经3年不断迭代至Sqlsugar版本,现EFcore版本已弃用,目前sqlsugar已带业务功能) **SqlSugar**:.Net6 DDD领域驱动设计 简单分层微服务架构 -**ec**:EFcore完整电商项目 +- Yi.Framework.Net6:.NetCore 6 意框架 + +- Yi.Vue3.X.RuoYi:Vue3 RuoYi前端框架 + + (你没有听错,已经接入java流行指数最高最火爆的框架之一,与其他框架不同,Yi框架后端为完全重制版,并非为ruoyi java模仿版) + +**SqlSugar-Dev**:为sqlsugar分支的实时开发版本 + +~~**ec**: EFcore完整电商项目~~ **** @@ -87,7 +95,24 @@ WebFirst开发:所有代码生成器已经配置完成,无需任何操作数 **封装**:Json处理模块,滑动验证码模块,base64图片处理模块,异常捕捉模块、邮件处理模块、linq封装模块、随机数模块、统一接口模块、基于策略的jwt验证、过滤器、数据库连接、跨域、初始化种子数据、Base32、Console输出、日期处理、文件传输、html筛选、http请求、ip过滤、md5加密、Rsa加密、序列化、雪花算法、字符串处理、编码处理、地址处理、xml处理、心跳检查。。。 **** -### 支持模块: +

业务支持模块

+ +(大部分ruoyi功能,采用ruoyi前端) + +- 用户管理 + +- 角色管理 + +- 菜单管理 + +- 部门管理 + +- 岗位管理 +- 等等 + + + +### 框架支持模块: 大致如图: From 729a563545d62e5525f18deb1a2c31692b9590d1 Mon Sep 17 00:00:00 2001 From: chenchun <454313500@qq.com> Date: Sun, 18 Sep 2022 17:50:38 +0800 Subject: [PATCH 16/25] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=A8=A1=E5=9D=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Yi.Framework.Model/Yi.Framework.Model.csproj | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Yi.Framework.Net6/Yi.Framework.Model/Yi.Framework.Model.csproj b/Yi.Framework.Net6/Yi.Framework.Model/Yi.Framework.Model.csproj index 7bc07bb8..1cbdd95d 100644 --- a/Yi.Framework.Net6/Yi.Framework.Model/Yi.Framework.Model.csproj +++ b/Yi.Framework.Net6/Yi.Framework.Model/Yi.Framework.Model.csproj @@ -41,4 +41,8 @@ + + + + From e8bb256a8d507f27b773ef215e60c4d436da8fff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=88=E6=B7=B3?= Date: Mon, 19 Sep 2022 14:24:13 +0800 Subject: [PATCH 17/25] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E7=A7=8D=E5=AD=90?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=E5=9F=BA=E7=A1=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../SeedData/AbstractSeed.cs | 17 +++++++++++ .../Yi.Framework.Model/SeedData/MenuSeed.cs | 23 +++++++++++++++ .../Yi.Framework.Model/SeedData/RoleSeed.cs | 23 +++++++++++++++ .../SeedData/SeedFactory.cs | 29 +++++++++++++++++++ .../Yi.Framework.Model/SeedData/UserSeed.cs | 26 +++++++++++++++++ .../Yi.Framework.Model.csproj | 4 --- 6 files changed, 118 insertions(+), 4 deletions(-) create mode 100644 Yi.Framework.Net6/Yi.Framework.Model/SeedData/AbstractSeed.cs create mode 100644 Yi.Framework.Net6/Yi.Framework.Model/SeedData/MenuSeed.cs create mode 100644 Yi.Framework.Net6/Yi.Framework.Model/SeedData/RoleSeed.cs create mode 100644 Yi.Framework.Net6/Yi.Framework.Model/SeedData/SeedFactory.cs create mode 100644 Yi.Framework.Net6/Yi.Framework.Model/SeedData/UserSeed.cs diff --git a/Yi.Framework.Net6/Yi.Framework.Model/SeedData/AbstractSeed.cs b/Yi.Framework.Net6/Yi.Framework.Model/SeedData/AbstractSeed.cs new file mode 100644 index 00000000..5275191d --- /dev/null +++ b/Yi.Framework.Net6/Yi.Framework.Model/SeedData/AbstractSeed.cs @@ -0,0 +1,17 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Yi.Framework.Model.SeedData +{ + public abstract class AbstractSeed + { + protected List Entitys { get; set; } = new List(); + public virtual List GetSeed() + { + return Entitys; + } + } +} diff --git a/Yi.Framework.Net6/Yi.Framework.Model/SeedData/MenuSeed.cs b/Yi.Framework.Net6/Yi.Framework.Model/SeedData/MenuSeed.cs new file mode 100644 index 00000000..21d98101 --- /dev/null +++ b/Yi.Framework.Net6/Yi.Framework.Model/SeedData/MenuSeed.cs @@ -0,0 +1,23 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Yi.Framework.Model.Models; + +namespace Yi.Framework.Model.SeedData +{ + public class MenuSeed: AbstractSeed + { + public override List GetSeed() + { + MenuEntity menu = new MenuEntity() + { + MenuName="首页", + PermissionCode="*:*:*" + }; + Entitys.Add(menu); + return Entitys; + } + } +} diff --git a/Yi.Framework.Net6/Yi.Framework.Model/SeedData/RoleSeed.cs b/Yi.Framework.Net6/Yi.Framework.Model/SeedData/RoleSeed.cs new file mode 100644 index 00000000..7fe503ac --- /dev/null +++ b/Yi.Framework.Net6/Yi.Framework.Model/SeedData/RoleSeed.cs @@ -0,0 +1,23 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Yi.Framework.Model.Models; + +namespace Yi.Framework.Model.SeedData +{ + public class RoleSeed : AbstractSeed + { + public override List GetSeed() + { + RoleEntity role = new RoleEntity() + { + RoleName = "管理员", + RoleCode = "admin", + }; + Entitys.Add(role); + return Entitys; + } + } +} diff --git a/Yi.Framework.Net6/Yi.Framework.Model/SeedData/SeedFactory.cs b/Yi.Framework.Net6/Yi.Framework.Model/SeedData/SeedFactory.cs new file mode 100644 index 00000000..0a624f3c --- /dev/null +++ b/Yi.Framework.Net6/Yi.Framework.Model/SeedData/SeedFactory.cs @@ -0,0 +1,29 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Yi.Framework.Model.Models; + +namespace Yi.Framework.Model.SeedData +{ + public class SeedFactory + { + public static List GetUserSeed() + { + return new UserSeed().GetSeed(); + } + public static List GetRoleSeed() + { + return new RoleSeed().GetSeed(); + } + public static List GetMenuSeed() + { + return new MenuSeed().GetSeed(); + } + public static List GetUserRoleSeed(List users,List roles) + { + return new List(); + } + } +} diff --git a/Yi.Framework.Net6/Yi.Framework.Model/SeedData/UserSeed.cs b/Yi.Framework.Net6/Yi.Framework.Model/SeedData/UserSeed.cs new file mode 100644 index 00000000..2e0c9635 --- /dev/null +++ b/Yi.Framework.Net6/Yi.Framework.Model/SeedData/UserSeed.cs @@ -0,0 +1,26 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Yi.Framework.Model.Models; + +namespace Yi.Framework.Model.SeedData +{ + public class UserSeed : AbstractSeed + { + public override List GetSeed() + { + UserEntity user = new UserEntity() + { + Name = "大橙子", + UserName = "cc", + Nick = "橙子", + Password = "123456" + }; + user.BuildPassword(); + Entitys.Add(user); + return Entitys; + } + } +} diff --git a/Yi.Framework.Net6/Yi.Framework.Model/Yi.Framework.Model.csproj b/Yi.Framework.Net6/Yi.Framework.Model/Yi.Framework.Model.csproj index 1cbdd95d..7bc07bb8 100644 --- a/Yi.Framework.Net6/Yi.Framework.Model/Yi.Framework.Model.csproj +++ b/Yi.Framework.Net6/Yi.Framework.Model/Yi.Framework.Model.csproj @@ -41,8 +41,4 @@ - - - - From 5785f5beea2a6113f4243064dac2625df211bd99 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=88=E6=B7=B3?= Date: Mon, 19 Sep 2022 17:25:43 +0800 Subject: [PATCH 18/25] =?UTF-8?q?=E6=95=B0=E6=8D=AE=E5=BA=93=E7=A7=8D?= =?UTF-8?q?=E5=AD=90=E5=88=9D=E5=A7=8B=E5=8C=96=E6=90=AD=E5=BB=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Yi.Framework.ApiMicroservice/Program.cs | 6 + .../Yi.Framework.ApiMicroservice.csproj | 16 +-- .../Yi.Framework.Model/SeedData/MenuSeed.cs | 115 +++++++++++++++++- .../Yi.Framework.Model/SeedData/RoleSeed.cs | 26 +++- .../SeedData/SeedFactory.cs | 32 ++++- .../Yi.Framework.Model/SeedData/UserSeed.cs | 42 ++++++- .../DbExtend/DbSeedExtend.cs | 56 +++++++++ .../MiddlewareExtend/RedisInitExtend.cs | 2 +- 8 files changed, 265 insertions(+), 30 deletions(-) create mode 100644 Yi.Framework.Net6/Yi.Framework.WebCore/DbExtend/DbSeedExtend.cs diff --git a/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Program.cs b/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Program.cs index d5273f13..88c1f81e 100644 --- a/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Program.cs +++ b/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Program.cs @@ -13,6 +13,7 @@ using Yi.Framework.WebCore.SignalRHub; using Hei.Captcha; using Yi.Framework.WebCore; using Microsoft.Extensions.DependencyInjection; +using Yi.Framework.WebCore.DbExtend; var builder = WebApplication.CreateBuilder(args); builder.Configuration.AddCommandLine(args); @@ -186,6 +187,11 @@ app.UseAuthorization(); //Consulע #endregion app.UseConsulService(); + +#region +//ݿע +#endregion +app.UseDbSeedInitService(); #region //redisע #endregion diff --git a/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Yi.Framework.ApiMicroservice.csproj b/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Yi.Framework.ApiMicroservice.csproj index e4e7aa28..2569ac4b 100644 --- a/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Yi.Framework.ApiMicroservice.csproj +++ b/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Yi.Framework.ApiMicroservice.csproj @@ -20,16 +20,6 @@ - - - - - - - Always - - - @@ -39,4 +29,10 @@ + + + Always + + + diff --git a/Yi.Framework.Net6/Yi.Framework.Model/SeedData/MenuSeed.cs b/Yi.Framework.Net6/Yi.Framework.Model/SeedData/MenuSeed.cs index 21d98101..e120af7f 100644 --- a/Yi.Framework.Net6/Yi.Framework.Model/SeedData/MenuSeed.cs +++ b/Yi.Framework.Net6/Yi.Framework.Model/SeedData/MenuSeed.cs @@ -1,22 +1,125 @@ -using System; +using SqlSugar; +using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; +using Yi.Framework.Common.Enum; using Yi.Framework.Model.Models; namespace Yi.Framework.Model.SeedData { - public class MenuSeed: AbstractSeed + public class MenuSeed : AbstractSeed { public override List GetSeed() { - MenuEntity menu = new MenuEntity() + //系统管理 + MenuEntity system = new MenuEntity() { - MenuName="首页", - PermissionCode="*:*:*" + Id = SnowFlakeSingle.Instance.NextId(), + MenuName = "系统管理", + PermissionCode = "*:*:*", + MenuType = MenuTypeEnum.Catalogue.GetHashCode(), + Router = "/system", + IsShow = true, + IsLink = false, + MenuIcon = "system", + OrderNum = 100, + ParentId = 0, + IsDeleted = false }; - Entitys.Add(menu); + Entitys.Add(system); + + //用户管理 + MenuEntity user = new MenuEntity() + { + Id = SnowFlakeSingle.Instance.NextId(), + MenuName = "用户管理", + PermissionCode = "system:user:list", + MenuType = MenuTypeEnum.Menu.GetHashCode(), + Router = "user", + IsShow = true, + IsLink = false, + IsCache = true, + Component = "system/user/index", + MenuIcon = "user", + OrderNum = 100, + ParentId = system.Id, + IsDeleted = false + }; + Entitys.Add(user); + + MenuEntity userQuery = new MenuEntity() + { + Id = SnowFlakeSingle.Instance.NextId(), + MenuName = "用户查询", + PermissionCode = "system:user:query", + MenuType = MenuTypeEnum.Component.GetHashCode(), + OrderNum = 100, + ParentId = user.Id, + IsDeleted = false + }; + Entitys.Add(userQuery); + + MenuEntity userAdd = new MenuEntity() + { + Id = SnowFlakeSingle.Instance.NextId(), + MenuName = "用户新增", + PermissionCode = "system:user:add", + MenuType = MenuTypeEnum.Component.GetHashCode(), + OrderNum = 100, + ParentId = user.Id, + IsDeleted = false + }; + Entitys.Add(userAdd); + + MenuEntity userEdit = new MenuEntity() + { + Id = SnowFlakeSingle.Instance.NextId(), + MenuName = "用户修改", + PermissionCode = "system:user:edit", + MenuType = MenuTypeEnum.Component.GetHashCode(), + OrderNum = 100, + ParentId = user.Id, + IsDeleted = false + }; + Entitys.Add(userEdit); + + MenuEntity userRemove = new MenuEntity() + { + Id = SnowFlakeSingle.Instance.NextId(), + MenuName = "用户删除", + PermissionCode = "system:user:remove", + MenuType = MenuTypeEnum.Component.GetHashCode(), + OrderNum = 100, + ParentId = user.Id, + IsDeleted = false + }; + Entitys.Add(userRemove); + + + + //角色管理 + MenuEntity role = new MenuEntity() + { + Id = SnowFlakeSingle.Instance.NextId(), + MenuName = "角色管理", + PermissionCode = "system:role:list", + MenuType = MenuTypeEnum.Menu.GetHashCode(), + Router = "role", + IsShow = true, + IsLink = false, + IsCache = true, + Component = "system/role/index", + MenuIcon = "peoples", + OrderNum = 100, + ParentId = system.Id, + IsDeleted = false + }; + Entitys.Add(role); + + + return Entitys; } } diff --git a/Yi.Framework.Net6/Yi.Framework.Model/SeedData/RoleSeed.cs b/Yi.Framework.Net6/Yi.Framework.Model/SeedData/RoleSeed.cs index 7fe503ac..c1460b7a 100644 --- a/Yi.Framework.Net6/Yi.Framework.Model/SeedData/RoleSeed.cs +++ b/Yi.Framework.Net6/Yi.Framework.Model/SeedData/RoleSeed.cs @@ -1,8 +1,10 @@ -using System; +using SqlSugar; +using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; +using Yi.Framework.Common.Enum; using Yi.Framework.Model.Models; namespace Yi.Framework.Model.SeedData @@ -11,12 +13,30 @@ namespace Yi.Framework.Model.SeedData { public override List GetSeed() { - RoleEntity role = new RoleEntity() + RoleEntity role1 = new RoleEntity() { + Id = SnowFlakeSingle.Instance.NextId(), RoleName = "管理员", RoleCode = "admin", + DataScope = DataScopeEnum.ALL.GetHashCode(), + OrderNum = 999, + Remark ="管理员", + IsDeleted = false }; - Entitys.Add(role); + Entitys.Add(role1); + + RoleEntity role2 = new RoleEntity() + { + Id = SnowFlakeSingle.Instance.NextId(), + RoleName = "测试角色", + RoleCode = "test", + DataScope = DataScopeEnum.ALL.GetHashCode(), + OrderNum = 1, + Remark = "测试用的角色", + IsDeleted = false + }; + Entitys.Add(role2); + return Entitys; } } diff --git a/Yi.Framework.Net6/Yi.Framework.Model/SeedData/SeedFactory.cs b/Yi.Framework.Net6/Yi.Framework.Model/SeedData/SeedFactory.cs index 0a624f3c..0320a355 100644 --- a/Yi.Framework.Net6/Yi.Framework.Model/SeedData/SeedFactory.cs +++ b/Yi.Framework.Net6/Yi.Framework.Model/SeedData/SeedFactory.cs @@ -1,4 +1,5 @@ -using System; +using SqlSugar; +using System; using System.Collections.Generic; using System.Linq; using System.Text; @@ -7,10 +8,10 @@ using Yi.Framework.Model.Models; namespace Yi.Framework.Model.SeedData { - public class SeedFactory + public class SeedFactory { public static List GetUserSeed() - { + { return new UserSeed().GetSeed(); } public static List GetRoleSeed() @@ -21,9 +22,30 @@ namespace Yi.Framework.Model.SeedData { return new MenuSeed().GetSeed(); } - public static List GetUserRoleSeed(List users,List roles) + public static List GetUserRoleSeed(List users, List roles) { - return new List(); + List userRoleEntities = new(); + foreach (var u in users) + { + foreach (var r in roles) + { + userRoleEntities.Add(new UserRoleEntity() {Id= SnowFlakeSingle.Instance.NextId(),UserId = u.Id, RoleId = r.Id, IsDeleted = false }); + } + } + return userRoleEntities; + } + + public static List GetRoleMenuSeed(List roles, List menus) + { + List roleMenuEntities = new(); + foreach (var r in roles) + { + foreach (var m in menus) + { + roleMenuEntities.Add(new RoleMenuEntity() { Id = SnowFlakeSingle.Instance.NextId(), RoleId = r.Id, MenuId = m.Id, IsDeleted = false }); + } + } + return roleMenuEntities; } } } diff --git a/Yi.Framework.Net6/Yi.Framework.Model/SeedData/UserSeed.cs b/Yi.Framework.Net6/Yi.Framework.Model/SeedData/UserSeed.cs index 2e0c9635..023f07f5 100644 --- a/Yi.Framework.Net6/Yi.Framework.Model/SeedData/UserSeed.cs +++ b/Yi.Framework.Net6/Yi.Framework.Model/SeedData/UserSeed.cs @@ -1,4 +1,5 @@ -using System; +using SqlSugar; +using System; using System.Collections.Generic; using System.Linq; using System.Text; @@ -11,15 +12,46 @@ namespace Yi.Framework.Model.SeedData { public override List GetSeed() { - UserEntity user = new UserEntity() + UserEntity user1 = new UserEntity() { + Id =SnowFlakeSingle.Instance.NextId(), Name = "大橙子", UserName = "cc", Nick = "橙子", - Password = "123456" + Password = "123456", + Email="454313500@qq.com", + Phone="13800000000", + Sex=0, + Address="深圳", + Age=20, + Introduction="还有谁?", + OrderNum=999, + Remark="描述是什么呢?", + IsDeleted=false }; - user.BuildPassword(); - Entitys.Add(user); + user1.BuildPassword(); + Entitys.Add(user1); + + UserEntity user2 = new UserEntity() + { + Id = SnowFlakeSingle.Instance.NextId(), + Name = "大测试", + UserName = "test", + Nick = "测试", + Password = "123456", + Email = "454313500@qq.com", + Phone = "15900000000", + Sex = 0, + Address = "深圳", + Age = 18, + Introduction = "还有我!", + OrderNum = 1, + Remark = "我没有描述!", + IsDeleted = false + }; + user2.BuildPassword(); + Entitys.Add(user2); + return Entitys; } } diff --git a/Yi.Framework.Net6/Yi.Framework.WebCore/DbExtend/DbSeedExtend.cs b/Yi.Framework.Net6/Yi.Framework.WebCore/DbExtend/DbSeedExtend.cs new file mode 100644 index 00000000..5ab736e8 --- /dev/null +++ b/Yi.Framework.Net6/Yi.Framework.WebCore/DbExtend/DbSeedExtend.cs @@ -0,0 +1,56 @@ +using Microsoft.AspNetCore.Builder; +using Microsoft.Extensions.DependencyInjection; +using SqlSugar; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Yi.Framework.Model.Models; +using Yi.Framework.Model.SeedData; + +namespace Yi.Framework.WebCore.DbExtend +{ + public static class DbSeedExtend + { + public static void UseDbSeedInitService(this IApplicationBuilder app) + { + + if (Appsettings.appBool("DbSeed_Enabled")) + { + + var _Db = app.ApplicationServices.GetService(); + var users = SeedFactory.GetUserSeed(); + var roles = SeedFactory.GetRoleSeed(); + var menus = SeedFactory.GetMenuSeed(); + if (!_Db.Queryable().Any()) + { + _Db.Insertable(users).ExecuteCommand(); + } + + if (!_Db.Queryable().Any()) + { + _Db.Insertable(roles).ExecuteCommand(); + } + + if (!_Db.Queryable().Any()) + { + _Db.Insertable(menus).ExecuteCommand(); + } + + if (!_Db.Queryable().Any()) + { + _Db.Insertable(SeedFactory.GetUserRoleSeed(users, roles)).ExecuteCommand(); + } + + if (!_Db.Queryable().Any()) + { + _Db.Insertable(SeedFactory.GetRoleMenuSeed(roles, menus)).ExecuteCommand(); + } + + + } + + } + } +} diff --git a/Yi.Framework.Net6/Yi.Framework.WebCore/MiddlewareExtend/RedisInitExtend.cs b/Yi.Framework.Net6/Yi.Framework.WebCore/MiddlewareExtend/RedisInitExtend.cs index 4a0c02b6..529b96d5 100644 --- a/Yi.Framework.Net6/Yi.Framework.WebCore/MiddlewareExtend/RedisInitExtend.cs +++ b/Yi.Framework.Net6/Yi.Framework.WebCore/MiddlewareExtend/RedisInitExtend.cs @@ -20,7 +20,7 @@ namespace Yi.Framework.WebCore.MiddlewareExtend if (Appsettings.appBool("RedisSeed_Enabled")) { - var _cacheClientDB = ServiceLocator.Instance.GetService(); + var _cacheClientDB = app.ApplicationServices.GetService(); try { From 55979e90dc65009b3f038cb2e3bec4dc85ddb7f5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=88=E6=B7=B3?= Date: Tue, 20 Sep 2022 15:11:55 +0800 Subject: [PATCH 19/25] =?UTF-8?q?=E8=8F=9C=E5=8D=95=E8=A7=92=E8=89=B2?= =?UTF-8?q?=E7=A7=8D=E5=AD=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Yi.Framework.Model/SeedData/MenuSeed.cs | 45 +++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/Yi.Framework.Net6/Yi.Framework.Model/SeedData/MenuSeed.cs b/Yi.Framework.Net6/Yi.Framework.Model/SeedData/MenuSeed.cs index e120af7f..993e464c 100644 --- a/Yi.Framework.Net6/Yi.Framework.Model/SeedData/MenuSeed.cs +++ b/Yi.Framework.Net6/Yi.Framework.Model/SeedData/MenuSeed.cs @@ -118,8 +118,53 @@ namespace Yi.Framework.Model.SeedData }; Entitys.Add(role); + MenuEntity roleQuery = new MenuEntity() + { + Id = SnowFlakeSingle.Instance.NextId(), + MenuName = "角色查询", + PermissionCode = "system:role:query", + MenuType = MenuTypeEnum.Component.GetHashCode(), + OrderNum = 100, + ParentId = user.Id, + IsDeleted = false + }; + Entitys.Add(roleQuery); + MenuEntity roleAdd = new MenuEntity() + { + Id = SnowFlakeSingle.Instance.NextId(), + MenuName = "角色新增", + PermissionCode = "system:role:add", + MenuType = MenuTypeEnum.Component.GetHashCode(), + OrderNum = 100, + ParentId = user.Id, + IsDeleted = false + }; + Entitys.Add(roleAdd); + MenuEntity roleEdit = new MenuEntity() + { + Id = SnowFlakeSingle.Instance.NextId(), + MenuName = "角色修改", + PermissionCode = "system:role:edit", + MenuType = MenuTypeEnum.Component.GetHashCode(), + OrderNum = 100, + ParentId = user.Id, + IsDeleted = false + }; + Entitys.Add(roleEdit); + + MenuEntity roleRemove = new MenuEntity() + { + Id = SnowFlakeSingle.Instance.NextId(), + MenuName = "角色删除", + PermissionCode = "system:role:remove", + MenuType = MenuTypeEnum.Component.GetHashCode(), + OrderNum = 100, + ParentId = user.Id, + IsDeleted = false + }; + Entitys.Add(roleRemove); return Entitys; } } From 5772de888c829b69ccbdd9ba46cb0e9b9f4ed78d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=88=E6=B7=B3?= Date: Tue, 20 Sep 2022 20:57:01 +0800 Subject: [PATCH 20/25] =?UTF-8?q?=E5=B2=97=E4=BD=8D=E3=80=81=E9=83=A8?= =?UTF-8?q?=E9=97=A8=E7=A7=8D=E5=AD=90=E6=95=B0=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../SeedData/DictionarySeed.cs | 18 ++ .../Yi.Framework.Model/SeedData/MenuSeed.cs | 277 +++++++++++++++++- 2 files changed, 293 insertions(+), 2 deletions(-) create mode 100644 Yi.Framework.Net6/Yi.Framework.Model/SeedData/DictionarySeed.cs diff --git a/Yi.Framework.Net6/Yi.Framework.Model/SeedData/DictionarySeed.cs b/Yi.Framework.Net6/Yi.Framework.Model/SeedData/DictionarySeed.cs new file mode 100644 index 00000000..ff3c5590 --- /dev/null +++ b/Yi.Framework.Net6/Yi.Framework.Model/SeedData/DictionarySeed.cs @@ -0,0 +1,18 @@ +using SqlSugar; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Yi.Framework.Model.Models; + +namespace Yi.Framework.Model.SeedData +{ + public class DictionarySeed : AbstractSeed + { + public override List GetSeed() + { + return Entitys; + } + } +} diff --git a/Yi.Framework.Net6/Yi.Framework.Model/SeedData/MenuSeed.cs b/Yi.Framework.Net6/Yi.Framework.Model/SeedData/MenuSeed.cs index 993e464c..9659a966 100644 --- a/Yi.Framework.Net6/Yi.Framework.Model/SeedData/MenuSeed.cs +++ b/Yi.Framework.Net6/Yi.Framework.Model/SeedData/MenuSeed.cs @@ -18,7 +18,7 @@ namespace Yi.Framework.Model.SeedData { Id = SnowFlakeSingle.Instance.NextId(), MenuName = "系统管理", - PermissionCode = "*:*:*", + //PermissionCode = "*:*:*", MenuType = MenuTypeEnum.Catalogue.GetHashCode(), Router = "/system", IsShow = true, @@ -98,7 +98,6 @@ namespace Yi.Framework.Model.SeedData Entitys.Add(userRemove); - //角色管理 MenuEntity role = new MenuEntity() { @@ -165,6 +164,280 @@ namespace Yi.Framework.Model.SeedData IsDeleted = false }; Entitys.Add(roleRemove); + + + //菜单管理 + MenuEntity menu = new MenuEntity() + { + Id = SnowFlakeSingle.Instance.NextId(), + MenuName = "菜单管理", + PermissionCode = "system:menu:list", + MenuType = MenuTypeEnum.Menu.GetHashCode(), + Router = "menu", + IsShow = true, + IsLink = false, + IsCache = true, + Component = "system/menu/index", + MenuIcon = "tree-table", + OrderNum = 100, + ParentId = system.Id, + IsDeleted = false + }; + Entitys.Add(menu); + + MenuEntity menuQuery = new MenuEntity() + { + Id = SnowFlakeSingle.Instance.NextId(), + MenuName = "菜单查询", + PermissionCode = "system:menu:query", + MenuType = MenuTypeEnum.Component.GetHashCode(), + OrderNum = 100, + ParentId = menu.Id, + IsDeleted = false + }; + Entitys.Add(menuQuery); + + MenuEntity menuAdd = new MenuEntity() + { + Id = SnowFlakeSingle.Instance.NextId(), + MenuName = "菜单新增", + PermissionCode = "system:menu:add", + MenuType = MenuTypeEnum.Component.GetHashCode(), + OrderNum = 100, + ParentId = menu.Id, + IsDeleted = false + }; + Entitys.Add(menuAdd); + + MenuEntity menuEdit = new MenuEntity() + { + Id = SnowFlakeSingle.Instance.NextId(), + MenuName = "菜单修改", + PermissionCode = "system:menu:edit", + MenuType = MenuTypeEnum.Component.GetHashCode(), + OrderNum = 100, + ParentId = menu.Id, + IsDeleted = false + }; + Entitys.Add(menuEdit); + + MenuEntity menuRemove = new MenuEntity() + { + Id = SnowFlakeSingle.Instance.NextId(), + MenuName = "菜单删除", + PermissionCode = "system:menu:remove", + MenuType = MenuTypeEnum.Component.GetHashCode(), + OrderNum = 100, + ParentId = menu.Id, + IsDeleted = false + }; + Entitys.Add(menuRemove); + + //部门管理 + MenuEntity dept = new MenuEntity() + { + Id = SnowFlakeSingle.Instance.NextId(), + MenuName = "部门管理", + PermissionCode = "system:dept:list", + MenuType = MenuTypeEnum.Menu.GetHashCode(), + Router = "dept", + IsShow = true, + IsLink = false, + IsCache = true, + Component = "system/dept/index", + MenuIcon = "tree", + OrderNum = 100, + ParentId = system.Id, + IsDeleted = false + }; + Entitys.Add(dept); + + MenuEntity deptQuery = new MenuEntity() + { + Id = SnowFlakeSingle.Instance.NextId(), + MenuName = "部门查询", + PermissionCode = "system:dept:query", + MenuType = MenuTypeEnum.Component.GetHashCode(), + OrderNum = 100, + ParentId = dept.Id, + IsDeleted = false + }; + Entitys.Add(deptQuery); + + MenuEntity deptAdd = new MenuEntity() + { + Id = SnowFlakeSingle.Instance.NextId(), + MenuName = "部门新增", + PermissionCode = "system:dept:add", + MenuType = MenuTypeEnum.Component.GetHashCode(), + OrderNum = 100, + ParentId = dept.Id, + IsDeleted = false + }; + Entitys.Add(deptAdd); + + MenuEntity deptEdit = new MenuEntity() + { + Id = SnowFlakeSingle.Instance.NextId(), + MenuName = "部门修改", + PermissionCode = "system:dept:edit", + MenuType = MenuTypeEnum.Component.GetHashCode(), + OrderNum = 100, + ParentId = dept.Id, + IsDeleted = false + }; + Entitys.Add(deptEdit); + + MenuEntity deptRemove = new MenuEntity() + { + Id = SnowFlakeSingle.Instance.NextId(), + MenuName = "部门删除", + PermissionCode = "system:dept:remove", + MenuType = MenuTypeEnum.Component.GetHashCode(), + OrderNum = 100, + ParentId = dept.Id, + IsDeleted = false + }; + Entitys.Add(deptRemove); + + + + //岗位管理 + MenuEntity post = new MenuEntity() + { + Id = SnowFlakeSingle.Instance.NextId(), + MenuName = "岗位管理", + PermissionCode = "system:post:list", + MenuType = MenuTypeEnum.Menu.GetHashCode(), + Router = "post", + IsShow = true, + IsLink = false, + IsCache = true, + Component = "system/post/index", + MenuIcon = "post", + OrderNum = 100, + ParentId = system.Id, + IsDeleted = false + }; + Entitys.Add(post); + + MenuEntity postQuery = new MenuEntity() + { + Id = SnowFlakeSingle.Instance.NextId(), + MenuName = "岗位查询", + PermissionCode = "system:post:query", + MenuType = MenuTypeEnum.Component.GetHashCode(), + OrderNum = 100, + ParentId = post.Id, + IsDeleted = false + }; + Entitys.Add(postQuery); + + MenuEntity postAdd = new MenuEntity() + { + Id = SnowFlakeSingle.Instance.NextId(), + MenuName = "岗位新增", + PermissionCode = "system:post:add", + MenuType = MenuTypeEnum.Component.GetHashCode(), + OrderNum = 100, + ParentId = post.Id, + IsDeleted = false + }; + Entitys.Add(postAdd); + + MenuEntity postEdit = new MenuEntity() + { + Id = SnowFlakeSingle.Instance.NextId(), + MenuName = "岗位修改", + PermissionCode = "system:post:edit", + MenuType = MenuTypeEnum.Component.GetHashCode(), + OrderNum = 100, + ParentId = post.Id, + IsDeleted = false + }; + Entitys.Add(postEdit); + + MenuEntity postRemove = new MenuEntity() + { + Id = SnowFlakeSingle.Instance.NextId(), + MenuName = "岗位删除", + PermissionCode = "system:post:remove", + MenuType = MenuTypeEnum.Component.GetHashCode(), + OrderNum = 100, + ParentId = post.Id, + IsDeleted = false + }; + Entitys.Add(postRemove); + + //字典管理 + MenuEntity dic = new MenuEntity() + { + Id = SnowFlakeSingle.Instance.NextId(), + MenuName = "字典管理", + PermissionCode = "system:dic:list", + MenuType = MenuTypeEnum.Menu.GetHashCode(), + Router = "dic", + IsShow = true, + IsLink = false, + IsCache = true, + Component = "system/dic/index", + MenuIcon = "dict", + OrderNum = 100, + ParentId = system.Id, + IsDeleted = false + }; + Entitys.Add(dic); + + MenuEntity dicQuery = new MenuEntity() + { + Id = SnowFlakeSingle.Instance.NextId(), + MenuName = "字典查询", + PermissionCode = "system:dic:query", + MenuType = MenuTypeEnum.Component.GetHashCode(), + OrderNum = 100, + ParentId = dic.Id, + IsDeleted = false + }; + Entitys.Add(dicQuery); + + MenuEntity dicAdd = new MenuEntity() + { + Id = SnowFlakeSingle.Instance.NextId(), + MenuName = "字典新增", + PermissionCode = "system:dic:add", + MenuType = MenuTypeEnum.Component.GetHashCode(), + OrderNum = 100, + ParentId = dic.Id, + IsDeleted = false + }; + Entitys.Add(dicAdd); + + MenuEntity dicEdit = new MenuEntity() + { + Id = SnowFlakeSingle.Instance.NextId(), + MenuName = "字典修改", + PermissionCode = "system:dic:edit", + MenuType = MenuTypeEnum.Component.GetHashCode(), + OrderNum = 100, + ParentId = dic.Id, + IsDeleted = false + }; + Entitys.Add(dicEdit); + + MenuEntity dicRemove = new MenuEntity() + { + Id = SnowFlakeSingle.Instance.NextId(), + MenuName = "字典删除", + PermissionCode = "system:dic:remove", + MenuType = MenuTypeEnum.Component.GetHashCode(), + OrderNum = 100, + ParentId = dic.Id, + IsDeleted = false + }; + Entitys.Add(dicRemove); + + + return Entitys; } } From 215c21ad8a2b9a7e70cb74f38fc852433f2b18bd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=88=E6=B7=B3?= Date: Wed, 21 Sep 2022 19:01:30 +0800 Subject: [PATCH 21/25] Update README.md --- README.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/README.md b/README.md index b22ba780..23a6a4a8 100644 --- a/README.md +++ b/README.md @@ -24,10 +24,8 @@ Yi框架-一套与SqlSugar一样爽的.Net6低代码开源框架。 适合.Net6学习、Sqlsugar学习 、项目二次开发。 集大成者,终究轮子 - Yi框架最新版本标签:`v1.2.0`,具体版本可以查看标签迭代 - (项目与Sqlsugar同步更新,但这作者老杰哥代码天天爆肝到凌晨两点,我们也尽量会跟上他的脚步。更新频繁,所以可watching持续关注。) ————这不仅仅是一个程序,更是一个艺术品,面向艺术的开发! From 261d9fcd799d53c98267a4b2505690e3a23427ad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=88=E6=B7=B3?= Date: Fri, 23 Sep 2022 16:03:32 +0800 Subject: [PATCH 22/25] Update README.md --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 23a6a4a8..c35cb9cc 100644 --- a/README.md +++ b/README.md @@ -26,6 +26,7 @@ Yi框架-一套与SqlSugar一样爽的.Net6低代码开源框架。 Yi框架最新版本标签:`v1.2.0`,具体版本可以查看标签迭代 + (项目与Sqlsugar同步更新,但这作者老杰哥代码天天爆肝到凌晨两点,我们也尽量会跟上他的脚步。更新频繁,所以可watching持续关注。) ————这不仅仅是一个程序,更是一个艺术品,面向艺术的开发! From 9149d6de9a3a14ab7057b4fde6959434acda5eba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=88=E6=B7=B3?= Date: Fri, 23 Sep 2022 18:46:37 +0800 Subject: [PATCH 23/25] =?UTF-8?q?=E9=85=8D=E7=BD=AE=E7=AE=A1=E7=90=86?= =?UTF-8?q?=E5=A2=9E=E5=88=A0=E6=94=B9=E6=9F=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- WebFirst/database/sqlite.db | Bin 634880 -> 634880 bytes .../Config/SwaggerDoc.xml | 8 ++ .../Controllers/ConfigController.cs | 40 +++++++++ .../yi-sqlsugar-dev.db | Bin 151552 -> 163840 bytes .../Yi.Framework.Interface/IConfigService.cs | 13 +++ .../IServiceTemplate/IConfigService.cs | 9 ++ .../ModelsTemplate/ConfigEntity.cs | 82 ++++++++++++++++++ .../Yi.Framework.Service/ConfigService.cs | 29 +++++++ .../ServiceTemplate/ConfigService.cs | 14 +++ Yi.Vue3.X.RuoYi/src/api/system/config.js | 18 ++-- .../src/views/system/config/index.vue | 19 ++-- 11 files changed, 217 insertions(+), 15 deletions(-) create mode 100644 Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Controllers/ConfigController.cs create mode 100644 Yi.Framework.Net6/Yi.Framework.Interface/IConfigService.cs create mode 100644 Yi.Framework.Net6/Yi.Framework.Interface/IServiceTemplate/IConfigService.cs create mode 100644 Yi.Framework.Net6/Yi.Framework.Model/ModelsTemplate/ConfigEntity.cs create mode 100644 Yi.Framework.Net6/Yi.Framework.Service/ConfigService.cs create mode 100644 Yi.Framework.Net6/Yi.Framework.Service/ServiceTemplate/ConfigService.cs diff --git a/WebFirst/database/sqlite.db b/WebFirst/database/sqlite.db index 7b57d339f00c70a869e3f7b1372727180ce11caf..d34d58c626bcaccfbb208dbe5e6b026caf7fe4b1 100644 GIT binary patch delta 586 zcmZp8pw{p}ZGyBQI|Bp5Y#@e#{)sxqjO-f|#Pk`xCztEXGA1`q)o-7w&$xZ6K2yGc z5Ie5|1OF6$6TT~a3A~?pTX+>VD=KjD+9i2&GcZa@$~zkyb8xUY=jWwmrbEb=t-a6p zu6wa?g^_`gk*qb+fIgCdhUi??1|!t{gJ7Lj$0; zC~gL2WuP{Bd6>4a#GF#7J}?ua@oB>zm@WfvgSJR+26=h7wkS}*d8bxFYy&bNdR|Uh zhtOlv7J=bHzr$ASw#9PF7T;Eu5P{P>_>@ zlV6yT!864(#V|9k#9O7!mYYFRl4E+pHAboS6Ol|n%nZaVK+FonY(UHo#2njCL~>e$ F0RSSO0}PeWCCJlAZ7t# TRv=~rVs;?r*nT3C(;^H2wazyc diff --git a/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Config/SwaggerDoc.xml b/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Config/SwaggerDoc.xml index 31e156df..9a2993e4 100644 --- a/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Config/SwaggerDoc.xml +++ b/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Config/SwaggerDoc.xml @@ -180,6 +180,14 @@ + + + 动态条件分页查询 + + + + + 动态条件查询 diff --git a/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Controllers/ConfigController.cs b/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Controllers/ConfigController.cs new file mode 100644 index 00000000..9ef0398f --- /dev/null +++ b/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Controllers/ConfigController.cs @@ -0,0 +1,40 @@ +using Microsoft.AspNetCore.Authorization; +using Microsoft.AspNetCore.Mvc; +using Microsoft.Extensions.Logging; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using Yi.Framework.Common.Models; +using Yi.Framework.Interface; +using Yi.Framework.Model.Models; +using Yi.Framework.Repository; +using Yi.Framework.WebCore; +using Yi.Framework.WebCore.AttributeExtend; +using Yi.Framework.WebCore.AuthorizationPolicy; + +namespace Yi.Framework.ApiMicroservice.Controllers +{ + [ApiController] + [Route("api/[controller]/[action]")] + public class ConfigController : BaseSimpleCrudController + { + private IConfigService _iConfigService; + public ConfigController(ILogger logger, IConfigService iConfigService) : base(logger, iConfigService) + { + _iConfigService = iConfigService; + } + + /// + /// 动态条件分页查询 + /// + /// + /// + /// + [HttpGet] + public async Task PageList([FromQuery] ConfigEntity dic, [FromQuery] PageParModel page) + { + return Result.Success().SetData(await _iConfigService.SelctPageList(dic, page)); + } + } +} diff --git a/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/yi-sqlsugar-dev.db b/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/yi-sqlsugar-dev.db index f7907dacfe3bb8825e1dfcb6ee3e7755d570a12a..131a3a4938fa9ad3043b398b8831973e95165cc6 100644 GIT binary patch delta 1400 zcma)6U2NM_6!x(lCvhF$j4VyV7R`-lo02v2Pkx;6Ktm`{t(&T}upzoNZku(Js-{gg zx@Zs0vI+5mwki@HPh+Tpy+DN`&6PGl;tiw?q^eAeM^w_62_#rwc;UuwP`ipB%f9wG zKIgmN_vzkS`OsOZu-6alLj*yD@YA~bmkujlL_}V_ZNn)NZ8d*{(4T1Q^Yc~2;=tF5 zhjw?>ea8)SKgE+BmcHzdkq&DVo;EQhkgJ150c0vd`~_tEcL} zQqO?#APea>CcK~Vz38vqYU`-|K%v?alQ9-gLlye?Wx_=V2>zaJhz{^2PUBSeG~4T# zaCF%@X2Vv76>5YSq=IM-tu3WJ9ByzlnNlOf2yKKKr%E1U}x0kqn*bQN3ZM~m-!{210mg@AYc1Sx;* zCgvCNJMQ9B4q}X)x7lU7zN<_Amo`P&W4xlCP05K!LP^AvF?GspF3vB!Lh_8)>ub^S zV_Ki=$Fw9_k>u$1_!KE6o>G*E6ptm6iaKQ#vgi-2wn3ldw{WWwTkWFnDu!yUk(ayYsJa4S}`Pv zVy|%g^`Rj_IE=fjiZ`^G3;F-387Q{ zhCmT9;U0a-rn3hy%5$-Lv&u2=V|mN+cA}%?bk6`rtIY-i`i$H6Pn;3P0h6yuxGVovKTf$e&lgMMi700E?k;I|O z&cpVUwURY}c`b7b<9g;`22WvexZuVkV#){awDJ2^wt_C z;qBaYOkWwdSEe#*b8eSSVT@tiR=~)jz`?|yz`(zjKVh??LJ&Vwko5F~`HV||qPH0M zZ}ETLELd=ke|r6SM%L-~*E1@K1D(XdTfxA;gFl8}f^QFBBA*!VDc%a8<^ + { + Task>> SelctPageList(ConfigEntity config, PageParModel page); + } +} diff --git a/Yi.Framework.Net6/Yi.Framework.Interface/IServiceTemplate/IConfigService.cs b/Yi.Framework.Net6/Yi.Framework.Interface/IServiceTemplate/IConfigService.cs new file mode 100644 index 00000000..d1f8d435 --- /dev/null +++ b/Yi.Framework.Net6/Yi.Framework.Interface/IServiceTemplate/IConfigService.cs @@ -0,0 +1,9 @@ +using Yi.Framework.Model.Models; +using Yi.Framework.Repository; + +namespace Yi.Framework.Interface +{ + public partial interface IConfigService:IBaseService + { + } +} diff --git a/Yi.Framework.Net6/Yi.Framework.Model/ModelsTemplate/ConfigEntity.cs b/Yi.Framework.Net6/Yi.Framework.Model/ModelsTemplate/ConfigEntity.cs new file mode 100644 index 00000000..f41dd6b0 --- /dev/null +++ b/Yi.Framework.Net6/Yi.Framework.Model/ModelsTemplate/ConfigEntity.cs @@ -0,0 +1,82 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text.Json.Serialization; +using SqlSugar; +namespace Yi.Framework.Model.Models +{ + /// + /// 配置表 + /// + [SugarTable("Config")] + public partial class ConfigEntity:IBaseModelEntity + { + public ConfigEntity() + { + this.CreateTime = DateTime.Now; + } + [JsonConverter(typeof(ValueToStringConverter))] + [SugarColumn(ColumnName="Id" ,IsPrimaryKey = true )] + public long Id { get; set; } + /// + /// 配置名称 + /// + [SugarColumn(ColumnName="ConfigName" )] + public string ConfigName { get; set; } + /// + /// 配置键 + /// + [SugarColumn(ColumnName="ConfigKey" )] + public string ConfigKey { get; set; } + /// + /// 配置值 + /// + [SugarColumn(ColumnName="ConfigValue" )] + public string ConfigValue { get; set; } + /// + /// 配置类别 + /// + [SugarColumn(ColumnName="ConfigType" )] + public string ConfigType { get; set; } + /// + /// 创建者 + /// + [SugarColumn(ColumnName="CreateUser" )] + public long? CreateUser { get; set; } + /// + /// 创建时间 + /// + [SugarColumn(ColumnName="CreateTime" )] + public DateTime? CreateTime { get; set; } + /// + /// 修改者 + /// + [SugarColumn(ColumnName="ModifyUser" )] + public long? ModifyUser { get; set; } + /// + /// 修改时间 + /// + [SugarColumn(ColumnName="ModifyTime" )] + public DateTime? ModifyTime { get; set; } + /// + /// 是否删除 + /// + [SugarColumn(ColumnName="IsDeleted" )] + public bool? IsDeleted { get; set; } + /// + /// 租户Id + /// + [SugarColumn(ColumnName="TenantId" )] + public long? TenantId { get; set; } + /// + /// 排序字段 + /// + [SugarColumn(ColumnName="OrderNum" )] + public int? OrderNum { get; set; } + /// + /// 描述 + /// + [SugarColumn(ColumnName="Remark" )] + public string Remark { get; set; } + } +} diff --git a/Yi.Framework.Net6/Yi.Framework.Service/ConfigService.cs b/Yi.Framework.Net6/Yi.Framework.Service/ConfigService.cs new file mode 100644 index 00000000..47221328 --- /dev/null +++ b/Yi.Framework.Net6/Yi.Framework.Service/ConfigService.cs @@ -0,0 +1,29 @@ +using SqlSugar; +using System; +using System.Collections.Generic; +using System.Threading.Tasks; +using Yi.Framework.Common.Models; +using Yi.Framework.Interface; +using Yi.Framework.Model.Models; +using Yi.Framework.Repository; + +namespace Yi.Framework.Service +{ + public partial class ConfigService : BaseService, IConfigService + { + public async Task>> SelctPageList(ConfigEntity config, PageParModel page) + { + RefAsync total = 0; + var data = await _repository._DbQueryable + .WhereIF(!string.IsNullOrEmpty(config.ConfigName), u => u.ConfigName.Contains(config.ConfigName)) + .WhereIF(!string.IsNullOrEmpty(config.ConfigKey), u => u.ConfigKey.Contains(config.ConfigKey)) + .WhereIF(page.StartTime.IsNotNull() && page.EndTime.IsNotNull(), u => u.CreateTime >= page.StartTime && u.CreateTime <= page.EndTime) + .WhereIF(config.IsDeleted.IsNotNull(), u => u.IsDeleted == config.IsDeleted) + .OrderBy(u => u.OrderNum, OrderByType.Desc) + .ToPageListAsync(page.PageNum, page.PageSize, total); + + return new PageModel>(data, total); + } + + } +} diff --git a/Yi.Framework.Net6/Yi.Framework.Service/ServiceTemplate/ConfigService.cs b/Yi.Framework.Net6/Yi.Framework.Service/ServiceTemplate/ConfigService.cs new file mode 100644 index 00000000..a9f404b4 --- /dev/null +++ b/Yi.Framework.Net6/Yi.Framework.Service/ServiceTemplate/ConfigService.cs @@ -0,0 +1,14 @@ +using SqlSugar; +using Yi.Framework.Interface; +using Yi.Framework.Model.Models; +using Yi.Framework.Repository; + +namespace Yi.Framework.Service +{ + public partial class ConfigService : BaseService, IConfigService + { + public ConfigService(IRepository repository) : base(repository) + { + } + } +} diff --git a/Yi.Vue3.X.RuoYi/src/api/system/config.js b/Yi.Vue3.X.RuoYi/src/api/system/config.js index a404d825..e1d549e6 100644 --- a/Yi.Vue3.X.RuoYi/src/api/system/config.js +++ b/Yi.Vue3.X.RuoYi/src/api/system/config.js @@ -3,7 +3,7 @@ import request from '@/utils/request' // 查询参数列表 export function listConfig(query) { return request({ - url: '/system/config/list', + url: '/config/pageList', method: 'get', params: query }) @@ -12,7 +12,7 @@ export function listConfig(query) { // 查询参数详细 export function getConfig(configId) { return request({ - url: '/system/config/' + configId, + url: '/config/getById/' + configId, method: 'get' }) } @@ -28,7 +28,7 @@ export function getConfigKey(configKey) { // 新增参数配置 export function addConfig(data) { return request({ - url: '/system/config', + url: '/config/add', method: 'post', data: data }) @@ -37,7 +37,7 @@ export function addConfig(data) { // 修改参数配置 export function updateConfig(data) { return request({ - url: '/system/config', + url: '/config/update', method: 'put', data: data }) @@ -45,9 +45,15 @@ export function updateConfig(data) { // 删除参数配置 export function delConfig(configId) { + +if("string"==typeof(configId)) +{ + configId=[configId]; +} return request({ - url: '/system/config/' + configId, - method: 'delete' + url: '/config/delList', + method: 'delete', + data:configId }) } diff --git a/Yi.Vue3.X.RuoYi/src/views/system/config/index.vue b/Yi.Vue3.X.RuoYi/src/views/system/config/index.vue index a81ec071..522a165c 100644 --- a/Yi.Vue3.X.RuoYi/src/views/system/config/index.vue +++ b/Yi.Vue3.X.RuoYi/src/views/system/config/index.vue @@ -98,7 +98,7 @@ - + @@ -213,8 +213,8 @@ const { queryParams, form, rules } = toRefs(data); function getList() { loading.value = true; listConfig(proxy.addDateRange(queryParams.value, dateRange.value)).then(response => { - configList.value = response.rows; - total.value = response.total; + configList.value = response.data.data; + total.value = response.data.total; loading.value = false; }); } @@ -226,12 +226,13 @@ function cancel() { /** 表单重置 */ function reset() { form.value = { - configId: undefined, + id: undefined, configName: undefined, configKey: undefined, configValue: undefined, configType: "Y", - remark: undefined + remark: undefined, + isDeleted: false }; proxy.resetForm("configRef"); } @@ -248,7 +249,7 @@ function resetQuery() { } /** 多选框选中数据 */ function handleSelectionChange(selection) { - ids.value = selection.map(item => item.configId); + ids.value = selection.map(item => item.id); single.value = selection.length != 1; multiple.value = !selection.length; } @@ -261,7 +262,7 @@ function handleAdd() { /** 修改按钮操作 */ function handleUpdate(row) { reset(); - const configId = row.configId || ids.value; + const configId = row.id || ids.value; getConfig(configId).then(response => { form.value = response.data; open.value = true; @@ -272,7 +273,7 @@ function handleUpdate(row) { function submitForm() { proxy.$refs["configRef"].validate(valid => { if (valid) { - if (form.value.configId != undefined) { + if (form.value.id != undefined) { updateConfig(form.value).then(response => { proxy.$modal.msgSuccess("修改成功"); open.value = false; @@ -290,7 +291,7 @@ function submitForm() { } /** 删除按钮操作 */ function handleDelete(row) { - const configIds = row.configId || ids.value; + const configIds = row.id || ids.value; proxy.$modal.confirm('是否确认删除参数编号为"' + configIds + '"的数据项?').then(function () { return delConfig(configIds); }).then(() => { From 1bd5fc389ac15ae78e860a82aeb7d1a1ca0489c1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=88=E6=B7=B3?= Date: Fri, 23 Sep 2022 18:53:59 +0800 Subject: [PATCH 24/25] =?UTF-8?q?=E5=AD=97=E5=85=B8=E6=A0=B7=E5=BC=8F?= =?UTF-8?q?=E7=B1=BB=E5=9E=8B=E5=8F=8A=E6=A0=B7=E5=BC=8Fclass=E8=AE=BE?= =?UTF-8?q?=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- WebFirst/database/sqlite.db | Bin 634880 -> 634880 bytes .../yi-sqlsugar-dev.db | Bin 163840 -> 163840 bytes .../ModelsTemplate/DictionaryInfoEntity.cs | 10 ++++++++++ 3 files changed, 10 insertions(+) diff --git a/WebFirst/database/sqlite.db b/WebFirst/database/sqlite.db index d34d58c626bcaccfbb208dbe5e6b026caf7fe4b1..25f2976c280adc18c3e86e66d54349ba1e57d964 100644 GIT binary patch delta 242 zcmZp8pw{p}ZGyBQ4+8_kY#@e#i4%2<8F@A)nCLU6Hc!=WpQ_KeeX2fF6{E0`v4Ww6 zm8qeXv5B6Mg^`7^q48wF*TR$D32*l>WZEOg?9J3ZojrhQG7Hl-ruNN_0xua;blOt6 z8DwQSI5=cw85x|5i=A^4fdrH;NlXXxi%W_!^U{sYT=d&gxEbW-fy(89%6&46OThAQ x22jKEjk}-D>xS!4Z%dwjSBXijT`-slh?#+y1&CRJm<@>8ftX{vU@+(V7y!kXM_d2^ delta 140 zcmZp8pw{p}ZGyBQI|Bp5Y#@e#{)sxqjO-f|O!OI(o2TlxPt|AKK2@Koic#3WQo+!~ z%Fxuxz(~)~($vV%*le=kYvD=ngtvPbGVPIL_GEf7ojrhQ@@7W?KPG1Nw&dw|m6+7p d1%sJ@m>Gy!fS47C*?^cGh&i?k26MiT0RY{~B}o7P diff --git a/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/yi-sqlsugar-dev.db b/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/yi-sqlsugar-dev.db index 131a3a4938fa9ad3043b398b8831973e95165cc6..649c915431c6c50a191955a72cd1e477cad79e91 100644 GIT binary patch delta 321 zcmZo@;A&{#njkGG%)r2)0mLxiG*QQxQMfT-YXalKcu9^V23{sr2EIM4J}k0)#XN~T z7F=;$noO$Or4ksqnYfxuW!c3wH5uDgx94Oq?qM|2QAqH~EG}`*Nh~f-P$)|*O3p|u z(l9pD1WGs;7h{TRZkJ7AbY)@TTf%sJds+tLY@D z;;rE6=at>8s8Gx^y?+m52n*1`R@0yFVKftrtk-srvYXalKcuBq`47@C|419Z7eOP4qig^-w zEV$yhG&z#COC>OJGfn5KW%|p;w}dI&S$6V5Zi(sds+fd9d^IS)wT4NUg>MPt*XjIq zOjEbZrZBp)a5cNgvWshKGPXHy*H2>H!?;}|i}9wbG_N@W7f(L}{|^2behI!ke2IKw zyr+08c=~xBZ&p+&=9%8VhcSdDh>MSH`tv=EX46mZVH6ZK&@;BMG%z+X1iIf*Q5fhO zX9kApv-dD+a~T@wnVDLenp;?Guh`4jH;HWr$m|_Jvn2VatHv`m$QzmKnH!s%S(;j; r6qctJmKPP4yD{;xiHeHzgN@l3&!o+1Y^-N!W@>I}y!}T!6Ndr-hiFdk diff --git a/Yi.Framework.Net6/Yi.Framework.Model/ModelsTemplate/DictionaryInfoEntity.cs b/Yi.Framework.Net6/Yi.Framework.Model/ModelsTemplate/DictionaryInfoEntity.cs index c789177d..57dffa89 100644 --- a/Yi.Framework.Net6/Yi.Framework.Model/ModelsTemplate/DictionaryInfoEntity.cs +++ b/Yi.Framework.Net6/Yi.Framework.Model/ModelsTemplate/DictionaryInfoEntity.cs @@ -78,5 +78,15 @@ namespace Yi.Framework.Model.Models /// [SugarColumn(ColumnName="Remark" )] public string Remark { get; set; } + /// + /// tag类型 + /// + [SugarColumn(ColumnName="ListClass" )] + public string ListClass { get; set; } + /// + /// tagClass + /// + [SugarColumn(ColumnName="CssClass" )] + public string CssClass { get; set; } } } From 544d65c7d02289a118297138f3e2023344e0e767 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=88=E6=B7=B3?= Date: Fri, 23 Sep 2022 18:55:12 +0800 Subject: [PATCH 25/25] Update README.md --- README.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/README.md b/README.md index c35cb9cc..9cb31f1b 100644 --- a/README.md +++ b/README.md @@ -107,6 +107,11 @@ WebFirst开发:所有代码生成器已经配置完成,无需任何操作数 - 部门管理 - 岗位管理 + +- 字典管理 + +- 参数管理 + - 等等