Merge branch 'sqlsugar-dev' of https://gitee.com/ccnetcore/Yi into sqlsugar-dev
This commit is contained in:
40
README.md
40
README.md
@@ -1,5 +1,5 @@
|
||||
|
||||
|
||||
|
||||
<h1 align="center"><img align="left" height="100px" src="https://user-images.githubusercontent.com/68722157/138828506-f58b7c57-5e10-4178-8f7d-5d5e12050113.png"> Yi框架</h1>
|
||||
<h4 align="center">一套与SqlSugar一样爽的.Net6低代码开源框架</h4>
|
||||
<h2 align="center">集大成者,终究轮子</h2>
|
||||
@@ -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处理、心跳检查。。。
|
||||
|
||||
****
|
||||
### 支持模块:
|
||||
<h3>业务支持模块</h3>
|
||||
|
||||
(大部分ruoyi功能,采用ruoyi前端)
|
||||
|
||||
- 用户管理
|
||||
|
||||
- 角色管理
|
||||
|
||||
- 菜单管理
|
||||
|
||||
- 部门管理
|
||||
|
||||
- 岗位管理
|
||||
|
||||
- 字典管理
|
||||
|
||||
- 参数管理
|
||||
|
||||
- 等等
|
||||
|
||||
|
||||
|
||||
### 框架支持模块:
|
||||
|
||||
大致如图:
|
||||
|
||||
|
||||
Binary file not shown.
@@ -61,6 +61,12 @@
|
||||
<param name="dto"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Yi.Framework.ApiMicroservice.Controllers.AccountController.CaptchaImage">
|
||||
<summary>
|
||||
验证码
|
||||
</summary>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="T:Yi.Framework.ApiMicroservice.Controllers.BaseCrudController`1">
|
||||
<summary>
|
||||
Json To Sql 类比模式,通用模型
|
||||
@@ -174,6 +180,14 @@
|
||||
<param name="ids"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Yi.Framework.ApiMicroservice.Controllers.ConfigController.PageList(Yi.Framework.Model.Models.ConfigEntity,Yi.Framework.Common.Models.PageParModel)">
|
||||
<summary>
|
||||
动态条件分页查询
|
||||
</summary>
|
||||
<param name="dic"></param>
|
||||
<param name="page"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Yi.Framework.ApiMicroservice.Controllers.DeptController.SelctGetList(Yi.Framework.Model.Models.DeptEntity)">
|
||||
<summary>
|
||||
动态条件查询
|
||||
@@ -181,6 +195,27 @@
|
||||
<param name="dept"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Yi.Framework.ApiMicroservice.Controllers.DeptController.Add(Yi.Framework.Model.Models.DeptEntity)">
|
||||
<summary>
|
||||
添加
|
||||
</summary>
|
||||
<param name="entity"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Yi.Framework.ApiMicroservice.Controllers.DeptController.Update(Yi.Framework.Model.Models.DeptEntity)">
|
||||
<summary>
|
||||
更新
|
||||
</summary>
|
||||
<param name="entity"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Yi.Framework.ApiMicroservice.Controllers.DeptController.GetListByRoleId(System.Int64)">
|
||||
<summary>
|
||||
根据角色id获取该角色下全部部门
|
||||
</summary>
|
||||
<param name="id"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Yi.Framework.ApiMicroservice.Controllers.DictionaryController.PageList(Yi.Framework.Model.Models.DictionaryEntity,Yi.Framework.Common.Models.PageParModel)">
|
||||
<summary>
|
||||
动态条件分页查询
|
||||
@@ -330,6 +365,12 @@
|
||||
<param name="isDel"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Yi.Framework.ApiMicroservice.Controllers.RoleController.UpdateDataScpoce(Yi.Framework.DTOModel.RoleInfoDto)">
|
||||
<summary>
|
||||
更改角色数据权限
|
||||
</summary>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="T:Yi.Framework.ApiMicroservice.Controllers.TestController">
|
||||
<summary>
|
||||
测试控制器
|
||||
|
||||
@@ -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
|
||||
/// 账户管理
|
||||
/// </summary>
|
||||
[ApiController]
|
||||
[Authorize]
|
||||
[Route("api/[controller]/[action]")]
|
||||
public class AccountController : ControllerBase
|
||||
{
|
||||
private IUserService _iUserService;
|
||||
private JwtInvoker _jwtInvoker;
|
||||
private ILogger _logger;
|
||||
public AccountController(ILogger<UserEntity> logger, IUserService iUserService, JwtInvoker jwtInvoker)
|
||||
private SecurityCodeHelper _securityCode;
|
||||
public AccountController(ILogger<UserEntity> logger, IUserService iUserService, JwtInvoker jwtInvoker, SecurityCodeHelper securityCode)
|
||||
{
|
||||
_iUserService = iUserService;
|
||||
_jwtInvoker = jwtInvoker;
|
||||
_logger = logger;
|
||||
_securityCode = securityCode;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -41,9 +45,10 @@ namespace Yi.Framework.ApiMicroservice.Controllers
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpGet]
|
||||
[AllowAnonymous]
|
||||
public async Task<Result> 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<Result> 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
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
[AllowAnonymous]
|
||||
public Result Logout()
|
||||
{
|
||||
return Result.Success("安全登出成功!");
|
||||
@@ -110,7 +114,7 @@ namespace Yi.Framework.ApiMicroservice.Controllers
|
||||
public async Task<Result> 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<Result> 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<Result> 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("更新失败!");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 验证码
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[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 });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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<ConfigEntity>
|
||||
{
|
||||
private IConfigService _iConfigService;
|
||||
public ConfigController(ILogger<ConfigEntity> logger, IConfigService iConfigService) : base(logger, iConfigService)
|
||||
{
|
||||
_iConfigService = iConfigService;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 动态条件分页查询
|
||||
/// </summary>
|
||||
/// <param name="dic"></param>
|
||||
/// <param name="page"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet]
|
||||
public async Task<Result> PageList([FromQuery] ConfigEntity dic, [FromQuery] PageParModel page)
|
||||
{
|
||||
return Result.Success().SetData(await _iConfigService.SelctPageList(dic, page));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -37,15 +37,36 @@ namespace Yi.Framework.ApiMicroservice.Controllers
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 添加
|
||||
/// </summary>
|
||||
/// <param name="entity"></param>
|
||||
/// <returns></returns>
|
||||
public override async Task<Result> Add(DeptEntity entity)
|
||||
{
|
||||
return await base.Add(entity);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 更新
|
||||
/// </summary>
|
||||
/// <param name="entity"></param>
|
||||
/// <returns></returns>
|
||||
public override async Task<Result> Update(DeptEntity entity)
|
||||
{
|
||||
return await base.Update(entity);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 根据角色id获取该角色下全部部门
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet]
|
||||
[Route("{id}")]
|
||||
public async Task<Result> GetListByRoleId(long id)
|
||||
{
|
||||
return Result.Success().SetData(await _iDeptService.GetListByRoleId(id));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -85,7 +85,16 @@ namespace Yi.Framework.ApiMicroservice.Controllers
|
||||
public async Task<Result> UpdateStatus(long roleId, bool isDel)
|
||||
{
|
||||
return Result.Success().SetData(await _iRoleService._repository.UpdateIgnoreNullAsync(new RoleEntity() { Id = roleId, IsDeleted = isDel }));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///更改角色数据权限
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpPut]
|
||||
public async Task<Result> UpdateDataScpoce(RoleInfoDto roleDto)
|
||||
{
|
||||
return Result.Success().SetStatus(await _iRoleService.UpdateDataScpoce(roleDto));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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<61><72><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ע<EFBFBD><D7A2>
|
||||
//Sqlsugar<61><72><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ע<EFBFBD><D7A2>,<2C>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ȩ<EFBFBD><EFBFBD><DEB9>ܣ<EFBFBD><DCA3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ҪRedis<69><73><EFBFBD><EFBFBD>
|
||||
#endregion
|
||||
builder.Services.AddSqlsugarServer();
|
||||
//builder.Services.AddSqlsugarServer(DbFiterExtend.Data);
|
||||
#region
|
||||
//Quartz<74><7A><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
#endregion
|
||||
@@ -115,6 +121,14 @@ builder.Services.AddLocalizerService();
|
||||
//<2F><><EFBFBD><EFBFBD>signalR
|
||||
#endregion
|
||||
builder.Services.AddSignalR();
|
||||
#region
|
||||
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>֤<EFBFBD><D6A4>
|
||||
#endregion
|
||||
builder.Services.AddHeiCaptcha();
|
||||
#region
|
||||
//<2F><><EFBFBD><EFBFBD>Http<74><70><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
#endregion
|
||||
builder.Services.AddHttpContextAccessor();
|
||||
//-----------------------------------------------------------------------------------------------------------
|
||||
var app = builder.Build();
|
||||
#region
|
||||
@@ -136,6 +150,7 @@ ServiceLocator.Instance = app.Services;
|
||||
//<2F><><EFBFBD><EFBFBD>ץȡ<D7A5><C8A1><EFBFBD><EFBFBD>ע<EFBFBD><D7A2>
|
||||
#endregion
|
||||
//app.UseErrorHandlingService();
|
||||
|
||||
#region
|
||||
//<2F><>̬<EFBFBD>ļ<EFBFBD>ע<EFBFBD><D7A2>
|
||||
#endregion
|
||||
@@ -172,6 +187,11 @@ app.UseAuthorization();
|
||||
//Consul<75><6C><EFBFBD><EFBFBD>ע<EFBFBD><D7A2>
|
||||
#endregion
|
||||
app.UseConsulService();
|
||||
|
||||
#region
|
||||
//<2F><><EFBFBD>ݿ<EFBFBD><DDBF><EFBFBD><EFBFBD><EFBFBD>ע<EFBFBD><D7A2>
|
||||
#endregion
|
||||
app.UseDbSeedInitService();
|
||||
#region
|
||||
//redis<69><73><EFBFBD><EFBFBD>ע<EFBFBD><D7A2>
|
||||
#endregion
|
||||
|
||||
@@ -20,16 +20,6 @@
|
||||
<None Remove="wwwrooot\**" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<None Remove="yi-sqlsugar-dev.db" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Content Include="yi-sqlsugar-dev.db">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</Content>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Yi.Framework.WebCore\Yi.Framework.WebCore.csproj" />
|
||||
</ItemGroup>
|
||||
@@ -39,4 +29,10 @@
|
||||
<Folder Include="wwwroot\image\" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<None Update="yi-sqlsugar-dev.db">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
||||
Binary file not shown.
@@ -90,6 +90,8 @@
|
||||
{
|
||||
#region 一般类型
|
||||
|
||||
|
||||
|
||||
public static Guid TryToGuid(this string guid)
|
||||
{
|
||||
if (Guid.TryParse(guid, out var guid1))
|
||||
|
||||
17
Yi.Framework.Net6/Yi.Framework.Common/Enum/DataScopeEnum.cs
Normal file
17
Yi.Framework.Net6/Yi.Framework.Common/Enum/DataScopeEnum.cs
Normal file
@@ -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
|
||||
}
|
||||
}
|
||||
@@ -1,10 +0,0 @@
|
||||
using System;
|
||||
|
||||
namespace Yi.Framework.Common.Models
|
||||
{
|
||||
public static class ServiceLocator
|
||||
{
|
||||
public static IServiceProvider Instance { get; set; }
|
||||
}
|
||||
|
||||
}
|
||||
@@ -6,6 +6,7 @@
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="EPPlus" Version="5.8.4" />
|
||||
<PackageReference Include="Hei.Captcha" Version="0.3.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Localization.Abstractions" Version="6.0.3" />
|
||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
|
||||
<PackageReference Include="SharpZipLib" Version="1.3.3" />
|
||||
|
||||
@@ -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,
|
||||
|
||||
13
Yi.Framework.Net6/Yi.Framework.Interface/IConfigService.cs
Normal file
13
Yi.Framework.Net6/Yi.Framework.Interface/IConfigService.cs
Normal file
@@ -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<ConfigEntity>
|
||||
{
|
||||
Task<PageModel<List<ConfigEntity>>> SelctPageList(ConfigEntity config, PageParModel page);
|
||||
}
|
||||
}
|
||||
@@ -14,5 +14,13 @@ namespace Yi.Framework.Interface
|
||||
/// <param name="dept"></param>
|
||||
/// <returns></returns>
|
||||
Task<List<DeptEntity>> SelctGetList(DeptEntity dept);
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 根据角色id获取该角色的部门权限
|
||||
/// </summary>
|
||||
/// <param name="roleId"></param>
|
||||
/// <returns></returns>
|
||||
Task<List<DeptEntity>> GetListByRoleId(long roleId);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -52,5 +52,20 @@ namespace Yi.Framework.Interface
|
||||
/// <param name="roleDto"></param>
|
||||
/// <returns></returns>
|
||||
Task<bool> UpdateInfo(RoleInfoDto roleDto);
|
||||
|
||||
/// <summary>
|
||||
/// 给角色设置部门
|
||||
/// </summary>
|
||||
/// <param name="roleIds"></param>
|
||||
/// <param name="deptIds"></param>
|
||||
/// <returns></returns>
|
||||
Task<bool> GiveRoleSetDept(List<long> roleIds, List<long> deptIds);
|
||||
|
||||
/// <summary>
|
||||
/// 更新角色数据权限
|
||||
/// </summary>
|
||||
/// <param name="roleDto"></param>
|
||||
/// <returns></returns>
|
||||
Task<bool> UpdateDataScpoce(RoleInfoDto roleDto);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
using Yi.Framework.Model.Models;
|
||||
using Yi.Framework.Repository;
|
||||
|
||||
namespace Yi.Framework.Interface
|
||||
{
|
||||
public partial interface IConfigService:IBaseService<ConfigEntity>
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -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
|
||||
{
|
||||
/// <summary>
|
||||
/// 配置表
|
||||
///</summary>
|
||||
[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; }
|
||||
/// <summary>
|
||||
/// 配置名称
|
||||
///</summary>
|
||||
[SugarColumn(ColumnName="ConfigName" )]
|
||||
public string ConfigName { get; set; }
|
||||
/// <summary>
|
||||
/// 配置键
|
||||
///</summary>
|
||||
[SugarColumn(ColumnName="ConfigKey" )]
|
||||
public string ConfigKey { get; set; }
|
||||
/// <summary>
|
||||
/// 配置值
|
||||
///</summary>
|
||||
[SugarColumn(ColumnName="ConfigValue" )]
|
||||
public string ConfigValue { get; set; }
|
||||
/// <summary>
|
||||
/// 配置类别
|
||||
///</summary>
|
||||
[SugarColumn(ColumnName="ConfigType" )]
|
||||
public string ConfigType { get; set; }
|
||||
/// <summary>
|
||||
/// 创建者
|
||||
///</summary>
|
||||
[SugarColumn(ColumnName="CreateUser" )]
|
||||
public long? CreateUser { get; set; }
|
||||
/// <summary>
|
||||
/// 创建时间
|
||||
///</summary>
|
||||
[SugarColumn(ColumnName="CreateTime" )]
|
||||
public DateTime? CreateTime { get; set; }
|
||||
/// <summary>
|
||||
/// 修改者
|
||||
///</summary>
|
||||
[SugarColumn(ColumnName="ModifyUser" )]
|
||||
public long? ModifyUser { get; set; }
|
||||
/// <summary>
|
||||
/// 修改时间
|
||||
///</summary>
|
||||
[SugarColumn(ColumnName="ModifyTime" )]
|
||||
public DateTime? ModifyTime { get; set; }
|
||||
/// <summary>
|
||||
/// 是否删除
|
||||
///</summary>
|
||||
[SugarColumn(ColumnName="IsDeleted" )]
|
||||
public bool? IsDeleted { get; set; }
|
||||
/// <summary>
|
||||
/// 租户Id
|
||||
///</summary>
|
||||
[SugarColumn(ColumnName="TenantId" )]
|
||||
public long? TenantId { get; set; }
|
||||
/// <summary>
|
||||
/// 排序字段
|
||||
///</summary>
|
||||
[SugarColumn(ColumnName="OrderNum" )]
|
||||
public int? OrderNum { get; set; }
|
||||
/// <summary>
|
||||
/// 描述
|
||||
///</summary>
|
||||
[SugarColumn(ColumnName="Remark" )]
|
||||
public string Remark { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -78,5 +78,15 @@ namespace Yi.Framework.Model.Models
|
||||
///</summary>
|
||||
[SugarColumn(ColumnName="Remark" )]
|
||||
public string Remark { get; set; }
|
||||
/// <summary>
|
||||
/// tag类型
|
||||
///</summary>
|
||||
[SugarColumn(ColumnName="ListClass" )]
|
||||
public string ListClass { get; set; }
|
||||
/// <summary>
|
||||
/// tagClass
|
||||
///</summary>
|
||||
[SugarColumn(ColumnName="CssClass" )]
|
||||
public string CssClass { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -123,5 +123,10 @@ namespace Yi.Framework.Model.Models
|
||||
///</summary>
|
||||
[SugarColumn(ColumnName="DeptId" )]
|
||||
public long? DeptId { get; set; }
|
||||
/// <summary>
|
||||
/// 性别
|
||||
///</summary>
|
||||
[SugarColumn(ColumnName="Sex" )]
|
||||
public int? Sex { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,9 +8,11 @@ namespace Yi.Framework.Model.Models
|
||||
|
||||
public partial class RoleEntity
|
||||
{
|
||||
//[Navigate(typeof(UserRoleEntity), nameof(UserRoleEntity.RoleId), nameof(UserRoleEntity.UserId))]
|
||||
//public List<UserEntity> Users { get; set; }
|
||||
|
||||
[Navigate(typeof(RoleMenuEntity),nameof(RoleMenuEntity.RoleId),nameof(RoleMenuEntity.MenuId))]
|
||||
public List<MenuEntity> Menus { get; set; }
|
||||
|
||||
[Navigate(typeof(RoleDeptEntity), nameof(RoleDeptEntity.RoleId), nameof(RoleDeptEntity.DeptId))]
|
||||
public List<DeptEntity> Depts { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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<T>
|
||||
{
|
||||
protected List<T> Entitys { get; set; } = new List<T>();
|
||||
public virtual List<T> GetSeed()
|
||||
{
|
||||
return Entitys;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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<DictionaryEntity>
|
||||
{
|
||||
public override List<DictionaryEntity> GetSeed()
|
||||
{
|
||||
return Entitys;
|
||||
}
|
||||
}
|
||||
}
|
||||
444
Yi.Framework.Net6/Yi.Framework.Model/SeedData/MenuSeed.cs
Normal file
444
Yi.Framework.Net6/Yi.Framework.Model/SeedData/MenuSeed.cs
Normal file
@@ -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<MenuEntity>
|
||||
{
|
||||
public override List<MenuEntity> 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
43
Yi.Framework.Net6/Yi.Framework.Model/SeedData/RoleSeed.cs
Normal file
43
Yi.Framework.Net6/Yi.Framework.Model/SeedData/RoleSeed.cs
Normal file
@@ -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<RoleEntity>
|
||||
{
|
||||
public override List<RoleEntity> 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
51
Yi.Framework.Net6/Yi.Framework.Model/SeedData/SeedFactory.cs
Normal file
51
Yi.Framework.Net6/Yi.Framework.Model/SeedData/SeedFactory.cs
Normal file
@@ -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<UserEntity> GetUserSeed()
|
||||
{
|
||||
return new UserSeed().GetSeed();
|
||||
}
|
||||
public static List<RoleEntity> GetRoleSeed()
|
||||
{
|
||||
return new RoleSeed().GetSeed();
|
||||
}
|
||||
public static List<MenuEntity> GetMenuSeed()
|
||||
{
|
||||
return new MenuSeed().GetSeed();
|
||||
}
|
||||
public static List<UserRoleEntity> GetUserRoleSeed(List<UserEntity> users, List<RoleEntity> roles)
|
||||
{
|
||||
List<UserRoleEntity> 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<RoleMenuEntity> GetRoleMenuSeed(List<RoleEntity> roles, List<MenuEntity> menus)
|
||||
{
|
||||
List<RoleMenuEntity> 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
58
Yi.Framework.Net6/Yi.Framework.Model/SeedData/UserSeed.cs
Normal file
58
Yi.Framework.Net6/Yi.Framework.Model/SeedData/UserSeed.cs
Normal file
@@ -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<UserEntity>
|
||||
{
|
||||
public override List<UserEntity> 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
29
Yi.Framework.Net6/Yi.Framework.Service/ConfigService.cs
Normal file
29
Yi.Framework.Net6/Yi.Framework.Service/ConfigService.cs
Normal file
@@ -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<ConfigEntity>, IConfigService
|
||||
{
|
||||
public async Task<PageModel<List<ConfigEntity>>> SelctPageList(ConfigEntity config, PageParModel page)
|
||||
{
|
||||
RefAsync<int> 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<List<ConfigEntity>>(data, total);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -21,5 +21,10 @@ namespace Yi.Framework.Service
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
public async Task<List<DeptEntity>> GetListByRoleId(long roleId)
|
||||
{
|
||||
return (await _repository._Db.Queryable<RoleEntity>().Includes(r => r.Depts).SingleAsync(r => r.Id == roleId)).Depts;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,8 +28,6 @@ namespace Yi.Framework.Service
|
||||
//遍历用户
|
||||
foreach (var roleId in roleIds)
|
||||
{
|
||||
|
||||
|
||||
//添加新的关系
|
||||
List<RoleMenuEntity> roleMenuEntity = new();
|
||||
foreach (var menu in menuIds)
|
||||
@@ -76,12 +74,46 @@ namespace Yi.Framework.Service
|
||||
return !0.Equals(res1) && res2;
|
||||
}
|
||||
|
||||
public async Task<bool> GiveRoleSetDept(List<long> roleIds,List<long> deptIds)
|
||||
{
|
||||
var _repositoryRoleDept = _repository.ChangeRepository<Repository<RoleDeptEntity>>();
|
||||
//多次操作,需要事务确保原子性
|
||||
return await _repositoryRoleDept.UseTranAsync(async () =>
|
||||
{ //删除用户之前所有的用户角色关系(物理删除,没有恢复的必要)
|
||||
await _repositoryRoleDept.DeleteAsync(u => roleIds.Contains((long)u.RoleId));
|
||||
|
||||
//遍历角色
|
||||
foreach (var roleId in roleIds)
|
||||
{
|
||||
//添加新的关系
|
||||
List<RoleDeptEntity> roleDeptEntity = new();
|
||||
foreach (var dept in deptIds)
|
||||
{
|
||||
roleDeptEntity.Add(new RoleDeptEntity() { RoleId = roleId, DeptId = dept });
|
||||
}
|
||||
|
||||
//一次性批量添加
|
||||
await _repositoryRoleDept.InsertReturnSnowflakeIdAsync(roleDeptEntity);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public async Task<bool> UpdateInfo(RoleInfoDto roleDto)
|
||||
{
|
||||
var res1 = await _repository.UpdateIgnoreNullAsync(roleDto.Role);
|
||||
var res2 = await GiveRoleSetMenu(new List<long> { roleDto.Role.Id }, roleDto.MenuIds);
|
||||
return res1 && res2;
|
||||
var res3 = await GiveRoleSetDept(new List<long> { roleDto.Role.Id }, roleDto.DeptIds);
|
||||
return res1 && res2&& res3;
|
||||
}
|
||||
|
||||
public async Task<bool> 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<long> { roleDto.Role.Id }, roleDto.DeptIds);
|
||||
return res1 && res3;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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<ConfigEntity>, IConfigService
|
||||
{
|
||||
public ConfigService(IRepository<ConfigEntity> repository) : base(repository)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
|
||||
using Microsoft.Extensions.Options;
|
||||
|
||||
namespace Yi.Framework.WebCore.BuilderExtend.OptionsWritable;
|
||||
|
||||
public abstract class FileOptionsWritableBase<TOptions> : OptionsWritableBase<TOptions>, IOptionsWritable<TOptions> where TOptions : class, new()
|
||||
{
|
||||
public FileOptionsWritableBase(IOptionsMonitor<TOptions> options, string section, string fileName) : base(options, section)
|
||||
{
|
||||
this.FileName = fileName;
|
||||
}
|
||||
|
||||
public string FileName { get; }
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
|
||||
using Microsoft.Extensions.Options;
|
||||
using System;
|
||||
|
||||
namespace Yi.Framework.WebCore.BuilderExtend.OptionsWritable;
|
||||
|
||||
public interface IOptionsWritable<out TOptions> : IOptionsSnapshot<TOptions> where TOptions : class, new()
|
||||
{
|
||||
void Update(Action<TOptions> configuration);
|
||||
}
|
||||
@@ -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<TOptions> : FileOptionsWritableBase<TOptions>, IOptionsWritable<TOptions> where TOptions : class, new()
|
||||
{
|
||||
public JsonOptionsWritable(IOptionsMonitor<TOptions> options, string section, string fileName) : base(options, section, fileName)
|
||||
{
|
||||
}
|
||||
|
||||
public override void Update(Action<TOptions> configuration)
|
||||
{
|
||||
JObject? jObject = JsonConvert.DeserializeObject<JObject>(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<TOptions>(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));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
|
||||
using Microsoft.Extensions.Options;
|
||||
using System;
|
||||
|
||||
namespace Yi.Framework.WebCore.BuilderExtend.OptionsWritable;
|
||||
|
||||
public abstract class OptionsWritableBase<TOptions> : IOptionsWritable<TOptions> where TOptions : class, new()
|
||||
{
|
||||
public OptionsWritableBase(
|
||||
IOptionsMonitor<TOptions> options,
|
||||
string section)
|
||||
{
|
||||
this.Monitor = options;
|
||||
this.Section = section;
|
||||
}
|
||||
|
||||
public IOptionsMonitor<TOptions> 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<TOptions> configuration);
|
||||
}
|
||||
@@ -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<TOption>(this IServiceCollection services, Microsoft.Extensions.Configuration.ConfigurationManager configuration, string jsonFilePath)
|
||||
where TOption : class, new()
|
||||
{
|
||||
ConfigureJson<TOption>(services, configuration.GetSection(typeof(TOption).Name), jsonFilePath);
|
||||
}
|
||||
|
||||
public static void ConfigureJson<TOption>(this IServiceCollection services, IConfigurationSection section, string jsonFilePath)
|
||||
where TOption : class, new()
|
||||
{
|
||||
services.Configure<TOption>(section);
|
||||
services.AddTransient<IOptionsWritable<TOption>>(provider =>
|
||||
new JsonOptionsWritable<TOption>(provider.GetRequiredService<IOptionsMonitor<TOption>>(), section.Key, jsonFilePath));
|
||||
}
|
||||
|
||||
public static void ConfigureJson<TOption>(this IServiceCollection services, Microsoft.Extensions.Configuration.ConfigurationManager configuration, Func<IServiceProvider, string> jsonFilePathFunc)
|
||||
where TOption : class, new()
|
||||
{
|
||||
ConfigureJson<TOption>(services, configuration.GetSection(typeof(TOption).Name), jsonFilePathFunc);
|
||||
}
|
||||
|
||||
public static void ConfigureJson<TOption>(this IServiceCollection services, IConfigurationSection section, Func<IServiceProvider, string> jsonFilePathFunc)
|
||||
where TOption : class, new()
|
||||
{
|
||||
services.Configure<TOption>(section);
|
||||
|
||||
services.AddTransient<IOptionsWritable<TOption>>(provider =>
|
||||
new JsonOptionsWritable<TOption>(provider.GetRequiredService<IOptionsMonitor<TOption>>(), section.Key, jsonFilePathFunc.Invoke(provider)));
|
||||
}
|
||||
}
|
||||
@@ -26,19 +26,62 @@ namespace Yi.Framework.WebCore
|
||||
return "XMLHttpRequest".Equals(header);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 通过鉴权完的token获取用户id
|
||||
/// </summary>
|
||||
/// <param name="httpContext"></param>
|
||||
/// <returns></returns>
|
||||
public static long GetUserIdInfo(this HttpContext httpContext)
|
||||
{
|
||||
var p = httpContext;
|
||||
return Convert.ToInt64(httpContext.User.Claims.FirstOrDefault(u => u.Type == JwtRegisteredClaimNames.Sid).Value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 通过鉴权完的token获取用户名
|
||||
/// </summary>
|
||||
/// <param name="httpContext"></param>
|
||||
/// <returns></returns>
|
||||
public static string GetUserNameInfo(this HttpContext httpContext)
|
||||
{
|
||||
var p = httpContext;
|
||||
return httpContext.User.Claims.FirstOrDefault(u => u.Type == JwtRegisteredClaimNames.Name).Value;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 通过鉴权完的token获取用户部门
|
||||
/// </summary>
|
||||
/// <param name="httpContext"></param>
|
||||
/// <returns></returns>
|
||||
public static string GetDeptIdInfo(this HttpContext httpContext)
|
||||
{
|
||||
var p = httpContext;
|
||||
return httpContext.User.Claims.FirstOrDefault(u => u.Type == "deptId").Value;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 通过鉴权完的token获取权限code
|
||||
/// </summary>
|
||||
/// <param name="httpContext"></param>
|
||||
/// <returns></returns>
|
||||
public static string GetPermissionInfo(this HttpContext httpContext)
|
||||
{
|
||||
var p = httpContext;
|
||||
return httpContext.User.Claims.FirstOrDefault(u => u.Type == "permission").Value;
|
||||
}
|
||||
/// <summary>
|
||||
/// 基于HttpContext,当前鉴权方式解析,获取用户信息
|
||||
/// 现在使用redis作为缓存,不需要将菜单存放至jwt中了
|
||||
/// </summary>
|
||||
/// <param name="httpContext"></param>
|
||||
/// <returns></returns>
|
||||
public static UserEntity GetCurrentUserEntityInfo(this HttpContext httpContext, out List<Guid> menuIds)
|
||||
public static UserEntity GetUserEntityInfo(this HttpContext httpContext, out List<Guid> menuIds)
|
||||
{
|
||||
IEnumerable<Claim> 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
|
||||
|
||||
@@ -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<CacheClientDB>().Get<UserRoleMenuDto>("用户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<UserEntity>(it => it.DeptId == deptId, true));
|
||||
break;
|
||||
case DataScopeEnum.USER:
|
||||
//只能查询到自己
|
||||
db.QueryFilter.Add(new TableFilterItem<UserEntity>(it => it.Id == userId, true));
|
||||
break;
|
||||
case DataScopeEnum.CUSTOM:
|
||||
//自定义查询
|
||||
var filter = new TableFilterItem<UserEntity>(it => SqlFunc.Subqueryable<RoleDeptEntity>().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<DeptEntity>().ToChildList(it => it.ParentId, deptId);
|
||||
|
||||
var filter1 = new TableFilterItem<UserEntity>(it => allChildDepts.Select(f => f.Id).ToList().Contains((long)it.DeptId), true);
|
||||
db.QueryFilter.Add(filter1);
|
||||
|
||||
//部门无需过滤
|
||||
//var filter2 = new TableFilterItem<DeptEntity>(it => allChildDepts.Select(f => f.Id).ToList().Contains(it.Id),true);
|
||||
//db.QueryFilter.Add(filter2);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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<ISqlSugarClient>();
|
||||
var users = SeedFactory.GetUserSeed();
|
||||
var roles = SeedFactory.GetRoleSeed();
|
||||
var menus = SeedFactory.GetMenuSeed();
|
||||
if (!_Db.Queryable<UserEntity>().Any())
|
||||
{
|
||||
_Db.Insertable(users).ExecuteCommand();
|
||||
}
|
||||
|
||||
if (!_Db.Queryable<RoleEntity>().Any())
|
||||
{
|
||||
_Db.Insertable(roles).ExecuteCommand();
|
||||
}
|
||||
|
||||
if (!_Db.Queryable<MenuEntity>().Any())
|
||||
{
|
||||
_Db.Insertable(menus).ExecuteCommand();
|
||||
}
|
||||
|
||||
if (!_Db.Queryable<UserRoleEntity>().Any())
|
||||
{
|
||||
_Db.Insertable(SeedFactory.GetUserRoleSeed(users, roles)).ExecuteCommand();
|
||||
}
|
||||
|
||||
if (!_Db.Queryable<RoleMenuEntity>().Any())
|
||||
{
|
||||
_Db.Insertable(SeedFactory.GetRoleMenuSeed(roles, menus)).ExecuteCommand();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
|
||||
@@ -20,7 +20,7 @@ namespace Yi.Framework.WebCore.MiddlewareExtend
|
||||
|
||||
if (Appsettings.appBool("RedisSeed_Enabled"))
|
||||
{
|
||||
var _cacheClientDB = ServiceLocator.Instance.GetService<CacheClientDB>();
|
||||
var _cacheClientDB = app.ApplicationServices.GetService<CacheClientDB>();
|
||||
|
||||
try
|
||||
{
|
||||
|
||||
27
Yi.Framework.Net6/Yi.Framework.WebCore/ServiceLocator.cs
Normal file
27
Yi.Framework.Net6/Yi.Framework.WebCore/ServiceLocator.cs
Normal file
@@ -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<IHttpContextAccessor>();
|
||||
if (httpContextAccessor is null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
httpContext = httpContextAccessor.HttpContext;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -37,4 +37,8 @@
|
||||
<ProjectReference Include="..\Yi.Framework.Service\Yi.Framework.Service.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Folder Include="BuilderExtend\OptionsWritable\" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
||||
@@ -49,7 +49,7 @@ export function logout() {
|
||||
// 获取验证码
|
||||
export function getCodeImg() {
|
||||
return request({
|
||||
url: '/captchaImage',
|
||||
url: '/account/captchaImage',
|
||||
headers: {
|
||||
isToken: false
|
||||
},
|
||||
|
||||
@@ -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
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@@ -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'
|
||||
})
|
||||
}
|
||||
@@ -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({
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -98,7 +98,7 @@
|
||||
|
||||
<el-table v-loading="loading" :data="configList" @selection-change="handleSelectionChange">
|
||||
<el-table-column type="selection" width="55" align="center" />
|
||||
<el-table-column label="参数主键" align="center" prop="configId" />
|
||||
<el-table-column label="参数主键" align="center" prop="id" />
|
||||
<el-table-column label="参数名称" align="center" prop="configName" :show-overflow-tooltip="true" />
|
||||
<el-table-column label="参数键名" align="center" prop="configKey" :show-overflow-tooltip="true" />
|
||||
<el-table-column label="参数键值" align="center" prop="configValue" />
|
||||
@@ -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(() => {
|
||||
|
||||
@@ -1,58 +1,139 @@
|
||||
<template>
|
||||
<div class="app-container">
|
||||
<el-form :model="queryParams" ref="queryRef" v-show="showSearch" :inline="true">
|
||||
<el-form
|
||||
:model="queryParams"
|
||||
ref="queryRef"
|
||||
v-show="showSearch"
|
||||
:inline="true"
|
||||
>
|
||||
<el-form-item label="角色名称" prop="roleName">
|
||||
<el-input v-model="queryParams.roleName" placeholder="请输入角色名称" clearable style="width: 240px"
|
||||
@keyup.enter="handleQuery" />
|
||||
<el-input
|
||||
v-model="queryParams.roleName"
|
||||
placeholder="请输入角色名称"
|
||||
clearable
|
||||
style="width: 240px"
|
||||
@keyup.enter="handleQuery"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="权限字符" prop="roleCode">
|
||||
<el-input v-model="queryParams.roleCode" placeholder="请输入权限字符" clearable style="width: 240px"
|
||||
@keyup.enter="handleQuery" />
|
||||
<el-input
|
||||
v-model="queryParams.roleCode"
|
||||
placeholder="请输入权限字符"
|
||||
clearable
|
||||
style="width: 240px"
|
||||
@keyup.enter="handleQuery"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="状态" prop="isDeleted">
|
||||
<el-select v-model="queryParams.isDeleted" placeholder="角色状态" clearable style="width: 240px">
|
||||
<el-option v-for="dict in sys_normal_disable" :key="dict.value" :label="dict.label" :value="dict.value" />
|
||||
<el-select
|
||||
v-model="queryParams.isDeleted"
|
||||
placeholder="角色状态"
|
||||
clearable
|
||||
style="width: 240px"
|
||||
>
|
||||
<el-option
|
||||
v-for="dict in sys_normal_disable"
|
||||
:key="dict.value"
|
||||
:label="dict.label"
|
||||
:value="dict.value"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="创建时间" style="width: 308px">
|
||||
<el-date-picker v-model="dateRange" value-format="YYYY-MM-DD" type="daterange" range-separator="-"
|
||||
start-placeholder="开始日期" end-placeholder="结束日期"></el-date-picker>
|
||||
<el-date-picker
|
||||
v-model="dateRange"
|
||||
value-format="YYYY-MM-DD"
|
||||
type="daterange"
|
||||
range-separator="-"
|
||||
start-placeholder="开始日期"
|
||||
end-placeholder="结束日期"
|
||||
></el-date-picker>
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button type="primary" icon="Search" @click="handleQuery">搜索</el-button>
|
||||
<el-button type="primary" icon="Search" @click="handleQuery"
|
||||
>搜索</el-button
|
||||
>
|
||||
<el-button icon="Refresh" @click="resetQuery">重置</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<el-row :gutter="10" class="mb8">
|
||||
<el-col :span="1.5">
|
||||
<el-button type="primary" plain icon="Plus" @click="handleAdd" v-hasPermi="['system:role:add']">新增</el-button>
|
||||
<el-button
|
||||
type="primary"
|
||||
plain
|
||||
icon="Plus"
|
||||
@click="handleAdd"
|
||||
v-hasPermi="['system:role:add']"
|
||||
>新增</el-button
|
||||
>
|
||||
</el-col>
|
||||
<el-col :span="1.5">
|
||||
<el-button type="success" plain icon="Edit" :disabled="single" @click="handleUpdate"
|
||||
v-hasPermi="['system:role:edit']">修改</el-button>
|
||||
<el-button
|
||||
type="success"
|
||||
plain
|
||||
icon="Edit"
|
||||
:disabled="single"
|
||||
@click="handleUpdate"
|
||||
v-hasPermi="['system:role:edit']"
|
||||
>修改</el-button
|
||||
>
|
||||
</el-col>
|
||||
<el-col :span="1.5">
|
||||
<el-button type="danger" plain icon="Delete" :disabled="multiple" @click="handleDelete"
|
||||
v-hasPermi="['system:role:remove']">删除</el-button>
|
||||
<el-button
|
||||
type="danger"
|
||||
plain
|
||||
icon="Delete"
|
||||
:disabled="multiple"
|
||||
@click="handleDelete"
|
||||
v-hasPermi="['system:role:remove']"
|
||||
>删除</el-button
|
||||
>
|
||||
</el-col>
|
||||
<el-col :span="1.5">
|
||||
<el-button type="warning" plain icon="Download" @click="handleExport" v-hasPermi="['system:role:export']">导出
|
||||
<el-button
|
||||
type="warning"
|
||||
plain
|
||||
icon="Download"
|
||||
@click="handleExport"
|
||||
v-hasPermi="['system:role:export']"
|
||||
>导出
|
||||
</el-button>
|
||||
</el-col>
|
||||
<right-toolbar v-model:showSearch="showSearch" @queryTable="getList"></right-toolbar>
|
||||
<right-toolbar
|
||||
v-model:showSearch="showSearch"
|
||||
@queryTable="getList"
|
||||
></right-toolbar>
|
||||
</el-row>
|
||||
|
||||
<!-- 表格数据 -->
|
||||
<el-table v-loading="loading" :data="roleList" @selection-change="handleSelectionChange">
|
||||
<el-table
|
||||
v-loading="loading"
|
||||
:data="roleList"
|
||||
@selection-change="handleSelectionChange"
|
||||
>
|
||||
<el-table-column type="selection" width="55" align="center" />
|
||||
<el-table-column label="角色编号" prop="roleCode" width="120" />
|
||||
<el-table-column label="角色名称" prop="roleName" :show-overflow-tooltip="true" width="150" />
|
||||
<el-table-column label="权限字符" prop="roleCode" :show-overflow-tooltip="true" width="150" />
|
||||
<el-table-column
|
||||
label="角色名称"
|
||||
prop="roleName"
|
||||
:show-overflow-tooltip="true"
|
||||
width="150"
|
||||
/>
|
||||
<el-table-column
|
||||
label="权限字符"
|
||||
prop="roleCode"
|
||||
:show-overflow-tooltip="true"
|
||||
width="150"
|
||||
/>
|
||||
<el-table-column label="显示顺序" prop="orderNum" width="100" />
|
||||
<el-table-column label="状态" align="center" width="100">
|
||||
<template #default="scope">
|
||||
<el-switch v-model="scope.row.isDeleted" :active-value=false :inactive-value=true
|
||||
@change="handleStatusChange(scope.row)"></el-switch>
|
||||
<el-switch
|
||||
v-model="scope.row.isDeleted"
|
||||
:active-value="false"
|
||||
:inactive-value="true"
|
||||
@change="handleStatusChange(scope.row)"
|
||||
></el-switch>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="创建时间" align="center" prop="createTime">
|
||||
@@ -60,41 +141,93 @@
|
||||
<span>{{ parseTime(scope.row.createTime) }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
|
||||
<el-table-column
|
||||
label="操作"
|
||||
align="center"
|
||||
class-name="small-padding fixed-width"
|
||||
>
|
||||
<template #default="scope">
|
||||
<el-tooltip content="修改" placement="top" v-if="scope.row.roleId !== 1">
|
||||
<el-button type="text" icon="Edit" @click="handleUpdate(scope.row)" v-hasPermi="['system:role:edit']">
|
||||
<el-tooltip
|
||||
content="修改"
|
||||
placement="top"
|
||||
v-if="scope.row.roleId !== 1"
|
||||
>
|
||||
<el-button
|
||||
type="text"
|
||||
icon="Edit"
|
||||
@click="handleUpdate(scope.row)"
|
||||
v-hasPermi="['system:role:edit']"
|
||||
>
|
||||
</el-button>
|
||||
</el-tooltip>
|
||||
<el-tooltip content="删除" placement="top" v-if="scope.row.roleId !== 1">
|
||||
<el-button type="text" icon="Delete" @click="handleDelete(scope.row)" v-hasPermi="['system:role:remove']">
|
||||
<el-tooltip
|
||||
content="删除"
|
||||
placement="top"
|
||||
v-if="scope.row.roleId !== 1"
|
||||
>
|
||||
<el-button
|
||||
type="text"
|
||||
icon="Delete"
|
||||
@click="handleDelete(scope.row)"
|
||||
v-hasPermi="['system:role:remove']"
|
||||
>
|
||||
</el-button>
|
||||
</el-tooltip>
|
||||
<el-tooltip content="数据权限" placement="top" v-if="scope.row.roleId !== 1">
|
||||
<el-button type="text" icon="CircleCheck" @click="handleDataScope(scope.row)"
|
||||
v-hasPermi="['system:role:edit']"></el-button>
|
||||
<el-tooltip
|
||||
content="数据权限"
|
||||
placement="top"
|
||||
v-if="scope.row.roleId !== 1"
|
||||
>
|
||||
<el-button
|
||||
type="text"
|
||||
icon="CircleCheck"
|
||||
@click="handleDataScope(scope.row)"
|
||||
v-hasPermi="['system:role:edit']"
|
||||
></el-button>
|
||||
</el-tooltip>
|
||||
<el-tooltip content="分配用户" placement="top" v-if="scope.row.roleId !== 1">
|
||||
<el-button type="text" icon="User" @click="handleAuthUser(scope.row)" v-hasPermi="['system:role:edit']">
|
||||
<el-tooltip
|
||||
content="分配用户"
|
||||
placement="top"
|
||||
v-if="scope.row.roleId !== 1"
|
||||
>
|
||||
<el-button
|
||||
type="text"
|
||||
icon="User"
|
||||
@click="handleAuthUser(scope.row)"
|
||||
v-hasPermi="['system:role:edit']"
|
||||
>
|
||||
</el-button>
|
||||
</el-tooltip>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
|
||||
<pagination v-show="total > 0" :total="total" v-model:page="queryParams.pageNum"
|
||||
v-model:limit="queryParams.pageSize" @pagination="getList" />
|
||||
<pagination
|
||||
v-show="total > 0"
|
||||
:total="total"
|
||||
v-model:page="queryParams.pageNum"
|
||||
v-model:limit="queryParams.pageSize"
|
||||
@pagination="getList"
|
||||
/>
|
||||
|
||||
<!-- 添加或修改角色配置对话框 -->
|
||||
<el-dialog :title="title" v-model="open" width="500px" append-to-body>
|
||||
<el-form ref="roleRef" :model="form.role" :rules="rules" label-width="100px">
|
||||
<el-form
|
||||
ref="roleRef"
|
||||
:model="form.role"
|
||||
:rules="rules"
|
||||
label-width="100px"
|
||||
>
|
||||
<el-form-item label="角色名称" prop="roleName">
|
||||
<el-input v-model="form.role.roleName" placeholder="请输入角色名称" />
|
||||
</el-form-item>
|
||||
<el-form-item prop="roleCode">
|
||||
<template #label>
|
||||
<span>
|
||||
<el-tooltip content="控制器中定义的权限字符,如:@PreAuthorize(`@ss.hasRole('admin')`)" placement="top">
|
||||
<el-tooltip
|
||||
content="控制器中定义的权限字符,如:@PreAuthorize(`@ss.hasRole('admin')`)"
|
||||
placement="top"
|
||||
>
|
||||
<el-icon>
|
||||
<question-filled />
|
||||
</el-icon>
|
||||
@@ -105,24 +238,55 @@
|
||||
<el-input v-model="form.role.roleCode" placeholder="请输入权限字符" />
|
||||
</el-form-item>
|
||||
<el-form-item label="角色顺序" prop="orderNum">
|
||||
<el-input-number v-model="form.role.orderNum" controls-position="right" :min="0" />
|
||||
<el-input-number
|
||||
v-model="form.role.orderNum"
|
||||
controls-position="right"
|
||||
:min="0"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="状态">
|
||||
<el-radio-group v-model="form.role.isDeleted">
|
||||
<el-radio v-for="dict in sys_normal_disable" :key="dict.value" :label="JSON.parse(dict.value)">{{dict.label}}</el-radio>
|
||||
<el-radio
|
||||
v-for="dict in sys_normal_disable"
|
||||
:key="dict.value"
|
||||
:label="JSON.parse(dict.value)"
|
||||
>{{ dict.label }}</el-radio
|
||||
>
|
||||
</el-radio-group>
|
||||
</el-form-item>
|
||||
<el-form-item label="菜单权限">
|
||||
<el-checkbox v-model="menuExpand" @change="handleCheckedTreeExpand($event, 'menu')">展开/折叠</el-checkbox>
|
||||
<el-checkbox v-model="menuNodeAll" @change="handleCheckedTreeNodeAll($event, 'menu')">全选/全不选</el-checkbox>
|
||||
<el-checkbox v-model="form.role.menuCheckStrictly" @change="handleCheckedTreeConnect($event, 'menu')">父子联动
|
||||
<el-checkbox
|
||||
v-model="menuExpand"
|
||||
@change="handleCheckedTreeExpand($event, 'menu')"
|
||||
>展开/折叠</el-checkbox
|
||||
>
|
||||
<el-checkbox
|
||||
v-model="menuNodeAll"
|
||||
@change="handleCheckedTreeNodeAll($event, 'menu')"
|
||||
>全选/全不选</el-checkbox
|
||||
>
|
||||
<el-checkbox
|
||||
v-model="form.role.menuCheckStrictly"
|
||||
@change="handleCheckedTreeConnect($event, 'menu')"
|
||||
>父子联动
|
||||
</el-checkbox>
|
||||
<el-tree class="tree-border" :data="menuOptions" show-checkbox ref="menuRef" node-key="id"
|
||||
:check-strictly="!form.role.menuCheckStrictly" empty-text="加载中,请稍候"
|
||||
:props="{ label: 'label', children: 'children' }"></el-tree>
|
||||
<el-tree
|
||||
class="tree-border"
|
||||
:data="menuOptions"
|
||||
show-checkbox
|
||||
ref="menuRef"
|
||||
node-key="id"
|
||||
:check-strictly="!form.role.menuCheckStrictly"
|
||||
empty-text="加载中,请稍候"
|
||||
:props="{ label: 'label', children: 'children' }"
|
||||
></el-tree>
|
||||
</el-form-item>
|
||||
<el-form-item label="备注">
|
||||
<el-input v-model="form.role.remark" type="textarea" placeholder="请输入内容"></el-input>
|
||||
<el-input
|
||||
v-model="form.role.remark"
|
||||
type="textarea"
|
||||
placeholder="请输入内容"
|
||||
></el-input>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<template #footer>
|
||||
@@ -134,7 +298,12 @@
|
||||
</el-dialog>
|
||||
|
||||
<!-- 分配角色数据权限对话框 -->
|
||||
<el-dialog :title="title" v-model="openDataScope" width="500px" append-to-body>
|
||||
<el-dialog
|
||||
:title="title"
|
||||
v-model="openDataScope"
|
||||
width="500px"
|
||||
append-to-body
|
||||
>
|
||||
<el-form :model="form" label-width="80px">
|
||||
<el-form-item label="角色名称">
|
||||
<el-input v-model="form.role.roleName" :disabled="true" />
|
||||
@@ -143,19 +312,46 @@
|
||||
<el-input v-model="form.role.roleCode" :disabled="true" />
|
||||
</el-form-item>
|
||||
<el-form-item label="权限范围">
|
||||
<el-select v-model="form.role.dataScope" @change="dataScopeSelectChange">
|
||||
<el-option v-for="item in dataScopeOptions" :key="item.value" :label="item.label" :value="item.value">
|
||||
<el-select
|
||||
v-model="form.role.dataScope"
|
||||
@change="dataScopeSelectChange"
|
||||
>
|
||||
<el-option
|
||||
v-for="item in dataScopeOptions"
|
||||
:key="item.value"
|
||||
:label="item.label"
|
||||
:value="item.value"
|
||||
>
|
||||
</el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="数据权限" v-show="form.role.dataScope == 2">
|
||||
<el-checkbox v-model="deptExpand" @change="handleCheckedTreeExpand($event, 'dept')">展开/折叠</el-checkbox>
|
||||
<el-checkbox v-model="deptNodeAll" @change="handleCheckedTreeNodeAll($event, 'dept')">全选/全不选</el-checkbox>
|
||||
<el-checkbox v-model="form.deptCheckStrictly" @change="handleCheckedTreeConnect($event, 'dept')">父子联动
|
||||
<el-form-item label="数据权限" v-show="form.role.dataScope == 1">
|
||||
<el-checkbox
|
||||
v-model="deptExpand"
|
||||
@change="handleCheckedTreeExpand($event, 'dept')"
|
||||
>展开/折叠</el-checkbox
|
||||
>
|
||||
<el-checkbox
|
||||
v-model="deptNodeAll"
|
||||
@change="handleCheckedTreeNodeAll($event, 'dept')"
|
||||
>全选/全不选</el-checkbox
|
||||
>
|
||||
<el-checkbox
|
||||
v-model="form.deptCheckStrictly"
|
||||
@change="handleCheckedTreeConnect($event, 'dept')"
|
||||
>父子联动
|
||||
</el-checkbox>
|
||||
<el-tree class="tree-border" :data="deptOptions" show-checkbox default-expand-all ref="deptRef" node-key="id"
|
||||
:check-strictly="!form.deptCheckStrictly" empty-text="加载中,请稍候"
|
||||
:props="{ label: 'label', children: 'children' }"></el-tree>
|
||||
<el-tree
|
||||
class="tree-border"
|
||||
:data="deptOptions"
|
||||
show-checkbox
|
||||
default-expand-all
|
||||
ref="deptRef"
|
||||
node-key="id"
|
||||
:check-strictly="!form.deptCheckStrictly"
|
||||
empty-text="加载中,请稍候"
|
||||
:props="{ label: 'label', children: 'children' }"
|
||||
></el-tree>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<template #footer>
|
||||
@@ -169,9 +365,21 @@
|
||||
</template>
|
||||
|
||||
<script setup name="Role">
|
||||
import { addRole, changeRoleStatus, dataScope, delRole, getRole, listRole, updateRole, deptTreeSelect } from "@/api/system/role";
|
||||
import { roleMenuTreeselect, treeselect as menuTreeselect, listMenu } from "@/api/system/menu";
|
||||
|
||||
import {
|
||||
addRole,
|
||||
changeRoleStatus,
|
||||
dataScope,
|
||||
delRole,
|
||||
getRole,
|
||||
listRole,
|
||||
updateRole,
|
||||
} from "@/api/system/role";
|
||||
import {
|
||||
roleMenuTreeselect,
|
||||
treeselect as menuTreeselect,
|
||||
listMenu,
|
||||
} from "@/api/system/menu";
|
||||
import { listDept, roleDeptTreeselect } from "@/api/system/dept";
|
||||
const router = useRouter();
|
||||
const { proxy } = getCurrentInstance();
|
||||
const { sys_normal_disable } = proxy.useDict("sys_normal_disable");
|
||||
@@ -198,11 +406,11 @@ const deptRef = ref(null);
|
||||
|
||||
/** 数据范围选项*/
|
||||
const dataScopeOptions = ref([
|
||||
{ value: "1", label: "全部数据权限" },
|
||||
{ value: "2", label: "自定数据权限" },
|
||||
{ value: "3", label: "本部门数据权限" },
|
||||
{ value: "4", label: "本部门及以下数据权限" },
|
||||
{ value: "5", label: "仅本人数据权限" }
|
||||
{ value: 0, label: "全部数据权限" },
|
||||
{ value: 1, label: "自定数据权限" },
|
||||
{ value: 2, label: "本部门数据权限" },
|
||||
{ value: 3, label: "本部门及以下数据权限" },
|
||||
{ value: 4, label: "仅本人数据权限" },
|
||||
]);
|
||||
|
||||
const data = reactive({
|
||||
@@ -212,12 +420,18 @@ const data = reactive({
|
||||
pageSize: 10,
|
||||
roleName: undefined,
|
||||
roleCode: undefined,
|
||||
isDeleted: undefined
|
||||
isDeleted: undefined,
|
||||
},
|
||||
rules: {
|
||||
roleName: [{ required: true, message: "角色名称不能为空", trigger: "blur" }],
|
||||
roleCode: [{ required: true, message: "权限字符不能为空", trigger: "blur" }],
|
||||
orderNum: [{ required: true, message: "角色顺序不能为空", trigger: "blur" }]
|
||||
roleName: [
|
||||
{ required: true, message: "角色名称不能为空", trigger: "blur" },
|
||||
],
|
||||
roleCode: [
|
||||
{ required: true, message: "权限字符不能为空", trigger: "blur" },
|
||||
],
|
||||
orderNum: [
|
||||
{ required: true, message: "角色顺序不能为空", trigger: "blur" },
|
||||
],
|
||||
},
|
||||
});
|
||||
|
||||
@@ -226,11 +440,13 @@ const { queryParams, form, rules } = toRefs(data);
|
||||
/** 查询角色列表 */
|
||||
function getList() {
|
||||
loading.value = true;
|
||||
listRole(proxy.addDateRange(queryParams.value, dateRange.value)).then(response => {
|
||||
roleList.value = response.data.data;
|
||||
total.value = response.data.total;
|
||||
loading.value = false;
|
||||
});
|
||||
listRole(proxy.addDateRange(queryParams.value, dateRange.value)).then(
|
||||
(response) => {
|
||||
roleList.value = response.data.data;
|
||||
total.value = response.data.total;
|
||||
loading.value = false;
|
||||
}
|
||||
);
|
||||
}
|
||||
/** 搜索按钮操作 */
|
||||
function handleQuery() {
|
||||
@@ -246,35 +462,47 @@ function resetQuery() {
|
||||
/** 删除按钮操作 */
|
||||
function handleDelete(row) {
|
||||
const roleIds = row.id || ids.value;
|
||||
proxy.$modal.confirm('是否确认删除角色编号为"' + roleIds + '"的数据项?').then(function () {
|
||||
return delRole(roleIds);
|
||||
}).then(() => {
|
||||
getList();
|
||||
proxy.$modal.msgSuccess("删除成功");
|
||||
}).catch(() => { });
|
||||
proxy.$modal
|
||||
.confirm('是否确认删除角色编号为"' + roleIds + '"的数据项?')
|
||||
.then(function () {
|
||||
return delRole(roleIds);
|
||||
})
|
||||
.then(() => {
|
||||
getList();
|
||||
proxy.$modal.msgSuccess("删除成功");
|
||||
})
|
||||
.catch(() => {});
|
||||
}
|
||||
/** 导出按钮操作 */
|
||||
function handleExport() {
|
||||
proxy.download("system/role/export", {
|
||||
...queryParams.value,
|
||||
}, `role_${new Date().getTime()}.xlsx`);
|
||||
proxy.download(
|
||||
"system/role/export",
|
||||
{
|
||||
...queryParams.value,
|
||||
},
|
||||
`role_${new Date().getTime()}.xlsx`
|
||||
);
|
||||
}
|
||||
/** 多选框选中数据 */
|
||||
function handleSelectionChange(selection) {
|
||||
ids.value = selection.map(item => item.id);
|
||||
ids.value = selection.map((item) => item.id);
|
||||
single.value = selection.length != 1;
|
||||
multiple.value = !selection.length;
|
||||
}
|
||||
/** 角色状态修改 */
|
||||
function handleStatusChange(row) {
|
||||
let text = row.isDeleted === false ? "启用" : "停用";
|
||||
proxy.$modal.confirm('确认要"' + text + '""' + row.roleName + '"角色吗?').then(function () {
|
||||
return changeRoleStatus(row.id, row.isDeleted);
|
||||
}).then(() => {
|
||||
proxy.$modal.msgSuccess(text + "成功");
|
||||
}).catch(function () {
|
||||
row.isDeleted = row.isDeleted === "0" ? "1" : "0";
|
||||
});
|
||||
proxy.$modal
|
||||
.confirm('确认要"' + text + '""' + row.roleName + '"角色吗?')
|
||||
.then(function () {
|
||||
return changeRoleStatus(row.id, row.isDeleted);
|
||||
})
|
||||
.then(() => {
|
||||
proxy.$modal.msgSuccess(text + "成功");
|
||||
})
|
||||
.catch(function () {
|
||||
row.isDeleted = row.isDeleted === "0" ? "1" : "0";
|
||||
});
|
||||
}
|
||||
/** 更多操作 */
|
||||
function handleCommand(command, row) {
|
||||
@@ -295,13 +523,18 @@ function handleAuthUser(row) {
|
||||
}
|
||||
/** 查询菜单树结构 */
|
||||
function getMenuTreeselect() {
|
||||
listMenu().then(response => {
|
||||
listMenu().then((response) => {
|
||||
const options = [];
|
||||
response.data.forEach(m => {
|
||||
options.push({ id: m.id, label: m.menuName, parentId: m.parentId, children: m.children })
|
||||
})
|
||||
response.data.forEach((m) => {
|
||||
options.push({
|
||||
id: m.id,
|
||||
label: m.menuName,
|
||||
parentId: m.parentId,
|
||||
children: m.children,
|
||||
});
|
||||
});
|
||||
menuOptions.value = proxy.handleTree(options);
|
||||
})
|
||||
});
|
||||
}
|
||||
/** 所有部门节点数据 */
|
||||
function getDeptAllCheckedKeys() {
|
||||
@@ -330,12 +563,11 @@ function reset() {
|
||||
IsDeleted: false,
|
||||
menuCheckStrictly: false,
|
||||
deptCheckStrictly: false,
|
||||
remark: undefined
|
||||
remark: undefined,
|
||||
dataScope: 0,
|
||||
},
|
||||
menuIds: [],
|
||||
deptIds: []
|
||||
|
||||
|
||||
deptIds: [],
|
||||
};
|
||||
proxy.resetForm("roleRef");
|
||||
}
|
||||
@@ -351,7 +583,7 @@ function handleUpdate(row) {
|
||||
reset();
|
||||
const roleId = row.id || ids.value;
|
||||
getRoleMenuTreeselect(roleId);
|
||||
getRole(roleId).then(response => {
|
||||
getRole(roleId).then((response) => {
|
||||
form.value.role = response.data;
|
||||
form.value.role.orderNum = Number(form.value.role.orderNum);
|
||||
open.value = true;
|
||||
@@ -364,138 +596,145 @@ function getRoleMenuTreeselect(roleId) {
|
||||
//2:获取全量菜单
|
||||
getMenuTreeselect();
|
||||
|
||||
roleMenuTreeselect(roleId).then(response => {
|
||||
|
||||
roleMenuTreeselect(roleId).then((response) => {
|
||||
const menuIds = [];
|
||||
response.data.forEach(m => {
|
||||
menuIds.push(m.id)
|
||||
})
|
||||
response.data.forEach((m) => {
|
||||
menuIds.push(m.id);
|
||||
});
|
||||
|
||||
menuIds.forEach((v) => {
|
||||
nextTick(() => {
|
||||
nextTick(() => {
|
||||
menuIds.forEach((v) => {
|
||||
menuRef.value.setChecked(v, true, false);
|
||||
});
|
||||
|
||||
//这里是要一个当前用户已拥有的菜单的id
|
||||
})
|
||||
|
||||
});
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
/** 根据角色ID查询部门树结构 */
|
||||
function getDeptTree(roleId) {
|
||||
return deptTreeSelect(roleId).then(response => {
|
||||
deptOptions.value = response.depts;
|
||||
return response;
|
||||
return listDept().then((response) => {
|
||||
const selectList = [];
|
||||
response.data.forEach((res) => {
|
||||
selectList.push({
|
||||
id: res.id,
|
||||
label: res.deptName,
|
||||
parentId: res.parentId,
|
||||
orderNum: res.orderNum,
|
||||
children: [],
|
||||
});
|
||||
}
|
||||
});
|
||||
deptOptions.value = proxy.handleTree(selectList, "id");
|
||||
|
||||
let deptIds = [];
|
||||
roleDeptTreeselect(roleId).then((response) => {
|
||||
deptIds = response.data.map((x) => x.id);
|
||||
// nextTick(() => {
|
||||
if (deptRef.value) {
|
||||
deptRef.value.setCheckedKeys(deptIds);
|
||||
}
|
||||
// });
|
||||
});
|
||||
});
|
||||
}
|
||||
/** 树权限(展开/折叠)*/
|
||||
function handleCheckedTreeExpand(value, type) {
|
||||
if (type == "menu") {
|
||||
let treeList = menuOptions.value;
|
||||
for (let i = 0; i < treeList.length; i++) {
|
||||
menuRef.value.store.nodesMap[treeList[i].id].expanded = value;
|
||||
}
|
||||
} else if (type == "dept") {
|
||||
let treeList = deptOptions.value;
|
||||
for (let i = 0; i < treeList.length; i++) {
|
||||
deptRef.value.store.nodesMap[treeList[i].id].expanded = value;
|
||||
}
|
||||
}
|
||||
if (type == "menu") {
|
||||
let treeList = menuOptions.value;
|
||||
for (let i = 0; i < treeList.length; i++) {
|
||||
menuRef.value.store.nodesMap[treeList[i].id].expanded = value;
|
||||
}
|
||||
} else if (type == "dept") {
|
||||
let treeList = deptOptions.value;
|
||||
for (let i = 0; i < treeList.length; i++) {
|
||||
deptRef.value.store.nodesMap[treeList[i].id].expanded = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
/** 树权限(全选/全不选) */
|
||||
function handleCheckedTreeNodeAll(value, type) {
|
||||
if (type == "menu") {
|
||||
menuRef.value.setCheckedNodes(value ? menuOptions.value : []);
|
||||
} else if (type == "dept") {
|
||||
deptRef.value.setCheckedNodes(value ? deptOptions.value : []);
|
||||
}
|
||||
}
|
||||
if (type == "menu") {
|
||||
menuRef.value.setCheckedNodes(value ? menuOptions.value : []);
|
||||
} else if (type == "dept") {
|
||||
deptRef.value.setCheckedNodes(value ? deptOptions.value : []);
|
||||
}
|
||||
}
|
||||
/** 树权限(父子联动) */
|
||||
function handleCheckedTreeConnect(value, type) {
|
||||
if (type == "menu") {
|
||||
form.value.menuCheckStrictly = value ? true : false;
|
||||
} else if (type == "dept") {
|
||||
form.value.deptCheckStrictly = value ? true : false;
|
||||
}
|
||||
}
|
||||
if (type == "menu") {
|
||||
form.value.menuCheckStrictly = value ? true : false;
|
||||
} else if (type == "dept") {
|
||||
form.value.deptCheckStrictly = value ? true : false;
|
||||
}
|
||||
}
|
||||
/** 所有菜单节点数据 */
|
||||
function getMenuAllCheckedKeys() {
|
||||
// 目前被选中的菜单节点
|
||||
let checkedKeys = menuRef.value.getCheckedKeys();
|
||||
// 半选中的菜单节点
|
||||
let halfCheckedKeys = menuRef.value.getHalfCheckedKeys();
|
||||
checkedKeys.unshift.apply(checkedKeys, halfCheckedKeys);
|
||||
return checkedKeys;
|
||||
}
|
||||
// 目前被选中的菜单节点
|
||||
let checkedKeys = menuRef.value.getCheckedKeys();
|
||||
// 半选中的菜单节点
|
||||
let halfCheckedKeys = menuRef.value.getHalfCheckedKeys();
|
||||
checkedKeys.unshift.apply(checkedKeys, halfCheckedKeys);
|
||||
return checkedKeys;
|
||||
}
|
||||
/** 提交按钮 */
|
||||
function submitForm() {
|
||||
proxy.$refs["roleRef"].validate(valid => {
|
||||
if (valid) {
|
||||
if (form.value.role.id != undefined) {
|
||||
form.value.menuIds = getMenuAllCheckedKeys();
|
||||
updateRole(form.value).then(response => {
|
||||
proxy.$modal.msgSuccess("修改成功");
|
||||
open.value = false;
|
||||
getList();
|
||||
});
|
||||
} else {
|
||||
form.value.menuIds = getMenuAllCheckedKeys();
|
||||
addRole(form.value).then(response => {
|
||||
proxy.$modal.msgSuccess("新增成功");
|
||||
open.value = false;
|
||||
getList();
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
/** 取消按钮 */
|
||||
function cancel() {
|
||||
open.value = false;
|
||||
reset();
|
||||
}
|
||||
/** 选择角色权限范围触发 */
|
||||
function dataScopeSelectChange(value) {
|
||||
if (value !== "2") {
|
||||
deptRef.value.setCheckedKeys([]);
|
||||
}
|
||||
}
|
||||
/** 分配数据权限操作 */
|
||||
function handleDataScope(row) {
|
||||
reset();
|
||||
const deptTreeSelect = getDeptTree(row.id);
|
||||
getRole(row.id).then(response => {
|
||||
form.value = response.data;
|
||||
openDataScope.value = true;
|
||||
nextTick(() => {
|
||||
deptTreeSelect.then(res => {
|
||||
nextTick(() => {
|
||||
if (deptRef.value) {
|
||||
deptRef.value.setCheckedKeys(res.checkedKeys);
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
title.value = "分配数据权限";
|
||||
});
|
||||
}
|
||||
/** 提交按钮(数据权限) */
|
||||
function submitDataScope() {
|
||||
if (form.value.id != undefined) {
|
||||
form.value.deptIds = getDeptAllCheckedKeys();
|
||||
dataScope(form.value).then(response => {
|
||||
proxy.$refs["roleRef"].validate((valid) => {
|
||||
if (valid) {
|
||||
if (form.value.role.id != undefined) {
|
||||
form.value.menuIds = getMenuAllCheckedKeys();
|
||||
updateRole(form.value).then((response) => {
|
||||
proxy.$modal.msgSuccess("修改成功");
|
||||
openDataScope.value = false;
|
||||
open.value = false;
|
||||
getList();
|
||||
});
|
||||
} else {
|
||||
form.value.menuIds = getMenuAllCheckedKeys();
|
||||
addRole(form.value).then((response) => {
|
||||
proxy.$modal.msgSuccess("新增成功");
|
||||
open.value = false;
|
||||
getList();
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
/** 取消按钮 */
|
||||
function cancel() {
|
||||
open.value = false;
|
||||
reset();
|
||||
}
|
||||
/** 选择角色权限范围触发 */
|
||||
function dataScopeSelectChange(value) {
|
||||
if (value !== "2") {
|
||||
deptRef.value.setCheckedKeys([]);
|
||||
}
|
||||
}
|
||||
/** 分配数据权限操作 */
|
||||
function handleDataScope(row) {
|
||||
reset();
|
||||
getDeptTree(row.id);
|
||||
getRole(row.id).then((response) => {
|
||||
form.value.role = response.data;
|
||||
openDataScope.value = true;
|
||||
title.value = "分配数据权限";
|
||||
});
|
||||
}
|
||||
/** 提交按钮(数据权限) */
|
||||
function submitDataScope() {
|
||||
if (form.value.role.id != undefined) {
|
||||
form.value.deptIds = getDeptAllCheckedKeys();
|
||||
dataScope(form.value).then((response) => {
|
||||
proxy.$modal.msgSuccess("修改成功");
|
||||
openDataScope.value = false;
|
||||
getList();
|
||||
});
|
||||
}
|
||||
}
|
||||
/** 取消按钮(数据权限)*/
|
||||
function cancelDataScope() {
|
||||
openDataScope.value = false;
|
||||
reset();
|
||||
}
|
||||
openDataScope.value = false;
|
||||
reset();
|
||||
}
|
||||
|
||||
getList();
|
||||
</script>
|
||||
|
||||
@@ -158,8 +158,7 @@
|
||||
<el-col :span="12">
|
||||
<el-form-item label="用户性别">
|
||||
<el-select v-model="form.user.sex" placeholder="请选择">
|
||||
<el-option v-for="dict in sys_user_sex" :key="dict.value" :label="dict.label"
|
||||
:value="dict.value"></el-option>
|
||||
<el-option v-for="dict in sys_user_sex" :key="dict.value" :label="dict.label" :value="JSON.parse(dict.value) "></el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
|
||||
Reference in New Issue
Block a user