diff --git a/README.md b/README.md index 30df03e0..509b0d2a 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ - +

Yi框架

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

集大成者,终究轮子

@@ -10,7 +10,7 @@ **** ### 简介: -**中文:意框架**(和他的名字一样“简易”) +**中文:意框架**(和他的名字一样“简易”,同时接入java耳熟能详的Ruoyi Vue3.0前端) 模块分化较多,可根据业务自行引用或抛弃,集大成者,大而全乎,也许你能从中学习到一些独特见解 @@ -32,11 +32,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完整电商项目~~ **** @@ -85,7 +93,29 @@ WebFirst开发:所有代码生成器已经配置完成,无需任何操作数 **封装**:Json处理模块,滑动验证码模块,base64图片处理模块,异常捕捉模块、邮件处理模块、linq封装模块、随机数模块、统一接口模块、基于策略的jwt验证、过滤器、数据库连接、跨域、初始化种子数据、Base32、Console输出、日期处理、文件传输、html筛选、http请求、ip过滤、md5加密、Rsa加密、序列化、雪花算法、字符串处理、编码处理、地址处理、xml处理、心跳检查。。。 **** -### 支持模块: +

业务支持模块

+ +(大部分ruoyi功能,采用ruoyi前端) + +- 用户管理 + +- 角色管理 + +- 菜单管理 + +- 部门管理 + +- 岗位管理 + +- 字典管理 + +- 参数管理 + +- 等等 + + + +### 框架支持模块: 大致如图: diff --git a/WebFirst/database/sqlite.db b/WebFirst/database/sqlite.db index 661d2ca7..25f2976c 100644 Binary files a/WebFirst/database/sqlite.db and b/WebFirst/database/sqlite.db differ diff --git a/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Config/SwaggerDoc.xml b/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Config/SwaggerDoc.xml index 5c7257c5..9a2993e4 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 类比模式,通用模型 @@ -174,6 +180,14 @@ + + + 动态条件分页查询 + + + + + 动态条件查询 @@ -181,6 +195,27 @@ + + + 添加 + + + + + + + 更新 + + + + + + + 根据角色id获取该角色下全部部门 + + + + 动态条件分页查询 @@ -330,6 +365,12 @@ + + + 更改角色数据权限 + + + 测试控制器 diff --git a/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Controllers/AccountController.cs b/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Controllers/AccountController.cs index e9527636..b434aa41 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; @@ -23,17 +24,20 @@ namespace Yi.Framework.ApiMicroservice.Controllers /// 账户管理 /// [ApiController] + [Authorize] [Route("api/[controller]/[action]")] public class AccountController : ControllerBase { 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; } /// @@ -41,9 +45,10 @@ namespace Yi.Framework.ApiMicroservice.Controllers /// /// [HttpGet] + [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); @@ -59,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)) { @@ -96,6 +99,7 @@ namespace Yi.Framework.ApiMicroservice.Controllers /// /// [HttpPost] + [AllowAnonymous] public Result Logout() { return Result.Success("安全登出成功!"); @@ -110,7 +114,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 +127,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 +148,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,13 +160,28 @@ 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)) { return Result.Success(); } return Result.Error("更新失败!"); } + + /// + /// 验证码 + /// + /// + [AllowAnonymous] + [HttpGet] + public Result CaptchaImage() + { + var uuid = Guid.NewGuid(); + var code = _securityCode.GetRandomEnDigitalText(4); + //将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/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/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..de57f7a6 100644 --- a/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Controllers/RoleController.cs +++ b/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Controllers/RoleController.cs @@ -85,7 +85,16 @@ namespace Yi.Framework.ApiMicroservice.Controllers public async Task UpdateStatus(long roleId, bool isDel) { return Result.Success().SetData(await _iRoleService._repository.UpdateIgnoreNullAsync(new RoleEntity() { Id = roleId, IsDeleted = isDel })); + } + /// + ///更改角色数据权限 + /// + /// + [HttpPut] + public async Task UpdateDataScpoce(RoleInfoDto roleDto) + { + return Result.Success().SetStatus(await _iRoleService.UpdateDataScpoce(roleDto)); } } } 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 52e69fb6..88c1f81e 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; @@ -9,6 +10,10 @@ using Yi.Framework.Language; 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; +using Yi.Framework.WebCore.DbExtend; var builder = WebApplication.CreateBuilder(args); builder.Configuration.AddCommandLine(args); @@ -50,9 +55,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 @@ -115,6 +121,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 @@ -136,6 +150,7 @@ ServiceLocator.Instance = app.Services; //ץȡע #endregion //app.UseErrorHandlingService(); + #region //̬ļע #endregion @@ -172,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.ApiMicroservice/yi-sqlsugar-dev.db b/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/yi-sqlsugar-dev.db index 6b62182e..649c9154 100644 Binary files a/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/yi-sqlsugar-dev.db and b/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/yi-sqlsugar-dev.db differ 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/Enum/DataScopeEnum.cs b/Yi.Framework.Net6/Yi.Framework.Common/Enum/DataScopeEnum.cs new file mode 100644 index 00000000..12641d45 --- /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, + DEPT_FOLLOW = 3, + USER = 4 + } +} 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.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 @@ + 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.Interface/IConfigService.cs b/Yi.Framework.Net6/Yi.Framework.Interface/IConfigService.cs new file mode 100644 index 00000000..3edb9a3c --- /dev/null +++ b/Yi.Framework.Net6/Yi.Framework.Interface/IConfigService.cs @@ -0,0 +1,13 @@ +using System.Collections.Generic; +using System.Threading.Tasks; +using Yi.Framework.Common.Models; +using Yi.Framework.Model.Models; +using Yi.Framework.Repository; + +namespace Yi.Framework.Interface +{ + public partial interface IConfigService:IBaseService + { + Task>> SelctPageList(ConfigEntity config, PageParModel page); + } +} 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.Interface/IRoleService.cs b/Yi.Framework.Net6/Yi.Framework.Interface/IRoleService.cs index fde0871c..fffcbe3d 100644 --- a/Yi.Framework.Net6/Yi.Framework.Interface/IRoleService.cs +++ b/Yi.Framework.Net6/Yi.Framework.Interface/IRoleService.cs @@ -52,5 +52,20 @@ namespace Yi.Framework.Interface /// /// Task UpdateInfo(RoleInfoDto roleDto); + + /// + /// 给角色设置部门 + /// + /// + /// + /// + Task GiveRoleSetDept(List roleIds, List deptIds); + + /// + /// 更新角色数据权限 + /// + /// + /// + Task UpdateDataScpoce(RoleInfoDto roleDto); } } 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.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; } } } diff --git a/Yi.Framework.Net6/Yi.Framework.Model/ModelsTemplate/UserEntity.cs b/Yi.Framework.Net6/Yi.Framework.Model/ModelsTemplate/UserEntity.cs index 95f35eb0..70d7731f 100644 --- a/Yi.Framework.Net6/Yi.Framework.Model/ModelsTemplate/UserEntity.cs +++ b/Yi.Framework.Net6/Yi.Framework.Model/ModelsTemplate/UserEntity.cs @@ -123,5 +123,10 @@ namespace Yi.Framework.Model.Models /// [SugarColumn(ColumnName="DeptId" )] public long? DeptId { get; set; } + /// + /// 性别 + /// + [SugarColumn(ColumnName="Sex" )] + public int? Sex { get; set; } } } 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.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/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 new file mode 100644 index 00000000..9659a966 --- /dev/null +++ b/Yi.Framework.Net6/Yi.Framework.Model/SeedData/MenuSeed.cs @@ -0,0 +1,444 @@ +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 override List GetSeed() + { + //系统管理 + MenuEntity system = new MenuEntity() + { + 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(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); + + 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); + + + //菜单管理 + 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; + } + } +} 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..c1460b7a --- /dev/null +++ b/Yi.Framework.Net6/Yi.Framework.Model/SeedData/RoleSeed.cs @@ -0,0 +1,43 @@ +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 RoleSeed : AbstractSeed + { + public override List GetSeed() + { + RoleEntity role1 = new RoleEntity() + { + Id = SnowFlakeSingle.Instance.NextId(), + RoleName = "管理员", + RoleCode = "admin", + DataScope = DataScopeEnum.ALL.GetHashCode(), + OrderNum = 999, + Remark ="管理员", + IsDeleted = false + }; + 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 new file mode 100644 index 00000000..0320a355 --- /dev/null +++ b/Yi.Framework.Net6/Yi.Framework.Model/SeedData/SeedFactory.cs @@ -0,0 +1,51 @@ +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 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) + { + 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 new file mode 100644 index 00000000..023f07f5 --- /dev/null +++ b/Yi.Framework.Net6/Yi.Framework.Model/SeedData/UserSeed.cs @@ -0,0 +1,58 @@ +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 UserSeed : AbstractSeed + { + public override List GetSeed() + { + UserEntity user1 = new UserEntity() + { + Id =SnowFlakeSingle.Instance.NextId(), + Name = "大橙子", + UserName = "cc", + Nick = "橙子", + Password = "123456", + Email="454313500@qq.com", + Phone="13800000000", + Sex=0, + Address="深圳", + Age=20, + Introduction="还有谁?", + OrderNum=999, + Remark="描述是什么呢?", + IsDeleted=false + }; + 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.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/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.Framework.Net6/Yi.Framework.Service/RoleService.cs b/Yi.Framework.Net6/Yi.Framework.Service/RoleService.cs index 290165e3..47dc8f9c 100644 --- a/Yi.Framework.Net6/Yi.Framework.Service/RoleService.cs +++ b/Yi.Framework.Net6/Yi.Framework.Service/RoleService.cs @@ -28,8 +28,6 @@ namespace Yi.Framework.Service //遍历用户 foreach (var roleId in roleIds) { - - //添加新的关系 List roleMenuEntity = new(); foreach (var menu in menuIds) @@ -76,12 +74,46 @@ namespace Yi.Framework.Service return !0.Equals(res1) && res2; } + public async Task GiveRoleSetDept(List roleIds,List deptIds) + { + var _repositoryRoleDept = _repository.ChangeRepository>(); + //多次操作,需要事务确保原子性 + return await _repositoryRoleDept.UseTranAsync(async () => + { //删除用户之前所有的用户角色关系(物理删除,没有恢复的必要) + await _repositoryRoleDept.DeleteAsync(u => roleIds.Contains((long)u.RoleId)); + + //遍历角色 + foreach (var roleId in roleIds) + { + //添加新的关系 + List roleDeptEntity = new(); + foreach (var dept in deptIds) + { + roleDeptEntity.Add(new RoleDeptEntity() { RoleId = roleId, DeptId = dept }); + } + + //一次性批量添加 + await _repositoryRoleDept.InsertReturnSnowflakeIdAsync(roleDeptEntity); + } + }); + } public async Task UpdateInfo(RoleInfoDto roleDto) { var res1 = await _repository.UpdateIgnoreNullAsync(roleDto.Role); var res2 = await GiveRoleSetMenu(new List { roleDto.Role.Id }, roleDto.MenuIds); - return res1 && res2; + var res3 = await GiveRoleSetDept(new List { roleDto.Role.Id }, roleDto.DeptIds); + return res1 && res2&& res3; + } + + public async Task UpdateDataScpoce(RoleInfoDto roleDto) + { + var role= new RoleEntity(); + role.Id = roleDto.Role.Id; + role.DataScope = roleDto.Role.DataScope; + var res1 = await _repository.UpdateIgnoreNullAsync(role); + var res3 = await GiveRoleSetDept(new List { roleDto.Role.Id }, roleDto.DeptIds); + return res1 && res3; } } } 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.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/CommonExtend.cs b/Yi.Framework.Net6/Yi.Framework.WebCore/CommonExtend.cs index ebc23248..8d269644 100644 --- a/Yi.Framework.Net6/Yi.Framework.WebCore/CommonExtend.cs +++ b/Yi.Framework.Net6/Yi.Framework.WebCore/CommonExtend.cs @@ -26,19 +26,62 @@ 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); + } + + /// + /// 通过鉴权完的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中了 /// /// /// - 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; 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/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/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/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; 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 { 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; + } + } + +} 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 @@ + + + + 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/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/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..f000bd81 100644 --- a/Yi.Vue3.X.RuoYi/src/api/system/role.js +++ b/Yi.Vue3.X.RuoYi/src/api/system/role.js @@ -40,7 +40,7 @@ export function updateRole(data) { // 角色数据权限 export function dataScope(data) { return request({ - url: '/system/role/dataScope', + url: '/role/UpdateDataScpoce', method: 'put', data: data }) @@ -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/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; } 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(() => { 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..3650904e 100644 --- a/Yi.Vue3.X.RuoYi/src/views/system/role/index.vue +++ b/Yi.Vue3.X.RuoYi/src/views/system/role/index.vue @@ -1,58 +1,139 @@ - + - + - +