diff --git a/backend/BPA.MES.Base.Application/BPA.MES.Base.Application.csproj b/backend/BPA.MES.Base.Application/BPA.MES.Base.Application.csproj
index b0a5c76..fccd63c 100644
--- a/backend/BPA.MES.Base.Application/BPA.MES.Base.Application.csproj
+++ b/backend/BPA.MES.Base.Application/BPA.MES.Base.Application.csproj
@@ -30,7 +30,6 @@
-
diff --git a/backend/BPA.MES.Base.Application/BPA.MES.Base.Application.xml b/backend/BPA.MES.Base.Application/BPA.MES.Base.Application.xml
index b42afd7..86a0af5 100644
--- a/backend/BPA.MES.Base.Application/BPA.MES.Base.Application.xml
+++ b/backend/BPA.MES.Base.Application/BPA.MES.Base.Application.xml
@@ -47,6 +47,11 @@
是否授权
+
+
+ 角色Id
+
+
微信session_key
@@ -1215,85 +1220,6 @@
员工表Id
-
-
- 名 称 授权模板表
- 创 建 人 :yangxiao
- 创建时间 : 2023/1/4 17:31:11
- 描 述 :
-
-
-
-
- 名称
-
-
-
-
- 描述
-
-
-
-
- 创建时间
-
-
-
-
- 是否删除
-
-
-
-
- 名 称 : 授权模板子项表
- 创 建 人 :yangxiao
- 创建时间 : 2023/1/4 17:31:27
- 描 述 :
-
-
-
-
- 模板编号
-
-
-
-
- 模块编号
-
-
-
-
- 是否删除
-
-
-
-
- 名 称 :授权对象表
- 创 建 人 :yangxiao
- 创建时间 : 2023/1/4 17:31:39
- 描 述 :
-
-
-
-
- 授权模板编号
-
-
-
-
- 授权对象编号(用户编号,角色编号)
-
-
-
-
- 授权类型 1:用户,2:角色
-
-
-
-
- 是否删除
-
-
名 称 :员工信息
@@ -1398,6 +1324,29 @@
是否删除
+
+
+ 名 称 :角色权限表
+ 创 建 人 :yangxiao
+ 创建时间 : 2023/8/31 15:56:02
+ 描 述 :
+
+
+
+
+ 角色Id
+
+
+
+
+ 模块Id
+
+
+
+
+ 父级模块
+
+
名 称 :接口AOP
@@ -7793,360 +7742,6 @@
已授权
-
-
- [授权模块]入参基础
-
-
-
-
- 名称
-
-
-
-
- 描述
-
-
-
-
- [授权模块]添加入参
-
-
-
-
- [授权模块]修改入参
-
-
-
-
- 主键
-
-
-
-
- [授权模块]删除入参
-
-
-
-
- 主键
-
-
-
-
- [授权模块]普通查询入参
-
-
-
-
- 主键
-
-
-
-
- [授权模块]分页查询入参
-
-
-
-
- 主键
-
-
-
-
- 关键字
-
-
-
-
- 名 称 :授权模块输出
- 创 建 人 :yangxiao
- 创建时间 : 2023/1/4 9:48:24
- 描 述 :
-
-
-
-
- 主键
-
-
-
-
- 名称
-
-
-
-
- 描述
-
-
-
-
- [授权模块]入参基础
-
-
-
-
- 子级列表
-
-
-
-
- 拥有权限
-
-
-
-
- 模块编号
-
-
-
-
- 类别 1:菜单,2:视图,3:功能
-
-
-
-
- 菜单打开方式 0:框架内嵌,1:新开页面
-
-
-
-
- 父级编号
-
-
-
-
- 名称
-
-
-
-
- 图标
-
-
-
-
- 地址
-
-
-
-
- 排序码
-
-
-
-
- 启用禁用
-
-
-
-
- 子集
-
-
-
-
- [授权模块]添加入参
-
-
-
-
- [授权模块]批量授权信息
-
-
-
-
- 模板名称
-
-
-
-
- 授权模块
-
-
-
-
- [授权模块]修改入参
-
-
-
-
- 主键
-
-
-
-
- [授权模块]删除入参
-
-
-
-
- 主键
-
-
-
-
- [授权模块]普通查询入参
-
-
-
-
- 主键
-
-
-
-
- [授权模块]分页查询入参
-
-
-
-
- 主键
-
-
-
-
- [账号信息]入参基础
-
-
-
-
- 模板Id
-
-
-
-
- 模块Id
-
-
-
-
- [账号信息]添加入参
-
-
-
-
- [账号信息]修改入参
-
-
-
-
- 主键
-
-
-
-
- [账号信息]删除入参
-
-
-
-
- 主键
-
-
-
-
- [账号信息]普通查询入参
-
-
-
-
- 主键
-
-
-
-
- [账号信息]分页查询入参
-
-
-
-
- 主键
-
-
-
-
- 名 称 :
- 创 建 人 :yangxiao
- 创建时间 : 2023/1/4 17:20:51
- 描 述 :
-
-
-
-
- 模块编号
-
-
-
-
- 名 称 :授权模块输出
- 创 建 人 :yangxiao
- 创建时间 : 2023/1/4 17:18:24
- 描 述 :
-
-
-
-
- 子级列表
-
-
-
-
- 拥有权限
-
-
-
-
- 模块编号
-
-
-
-
- 类别 1:菜单,2:视图,3:功能
-
-
-
-
- 菜单打开方式 0:框架内嵌,1:新开页面
-
-
-
-
- 父级编号
-
-
-
-
- 名称
-
-
-
-
- 图标
-
-
-
-
- 地址
-
-
-
-
- 排序码
-
-
-
-
- 启用禁用
-
-
-
-
- 子集
-
-
名 称 :
@@ -8667,6 +8262,49 @@
关键字
+
+
+ 名 称 :
+ 创 建 人 :yangxiao
+ 创建时间 : 2023/8/31 15:58:31
+ 描 述 :
+
+
+
+
+ 角色Id
+
+
+
+
+ 模块Id
+
+
+
+
+ 父级Id
+
+
+
+
+ 角色Id
+
+
+
+
+ 角色Id
+
+
+
+
+ 模块Id
+
+
+
+
+ 角色Id
+
+
名 称 :角色信息
@@ -8775,14 +8413,6 @@
-
-
- 获取权限模块编号
-
-
-
-
-
获取账户信息
@@ -8811,13 +8441,6 @@
-
-
- 获取授权模块编号
-
-
-
-
编辑员工
@@ -8839,6 +8462,20 @@
+
+
+ 分配角色权限
+
+
+
+
+
+
+ 根据角色获取权限模块
+
+
+
+
名 称 :
diff --git a/backend/BPA.MES.Base.Application/Const/ClaimConst.cs b/backend/BPA.MES.Base.Application/Const/ClaimConst.cs
index 85864cb..e3a9f13 100644
--- a/backend/BPA.MES.Base.Application/Const/ClaimConst.cs
+++ b/backend/BPA.MES.Base.Application/Const/ClaimConst.cs
@@ -37,6 +37,10 @@
///
public const string CLAINM_ISAUTH = "0";
///
+ /// 角色Id
+ ///
+ public const string CLAINM_ROLEID = "";
+ ///
/// 微信session_key
///
public const string SESSION_KEY = "session_key";
diff --git a/backend/BPA.MES.Base.Application/Entitys/Sys/AuthorizeTemplateEntity.cs b/backend/BPA.MES.Base.Application/Entitys/Sys/AuthorizeTemplateEntity.cs
deleted file mode 100644
index c95181f..0000000
--- a/backend/BPA.MES.Base.Application/Entitys/Sys/AuthorizeTemplateEntity.cs
+++ /dev/null
@@ -1,29 +0,0 @@
-namespace BPA.MES.Base.Application.Entitys
-{
- ///
- /// 名 称 授权模板表
- /// 创 建 人 :yangxiao
- /// 创建时间 : 2023/1/4 17:31:11
- /// 描 述 :
- ///
- [SugarTable("sys_authorizetemplate")]
- public class AuthorizeTemplateEntity : DEntityBase
- {
- ///
- /// 名称
- ///
- public string Name { get; set; }
- ///
- /// 描述
- ///
- public string Remark { get; set; }
- ///
- /// 创建时间
- ///
- public DateTime? CreateAt { get; set; }
- ///
- /// 是否删除
- ///
- public bool IsDeleted { get; set; }
- }
-}
diff --git a/backend/BPA.MES.Base.Application/Entitys/Sys/AuthorizeTemplateItemEntity.cs b/backend/BPA.MES.Base.Application/Entitys/Sys/AuthorizeTemplateItemEntity.cs
deleted file mode 100644
index 3a3489a..0000000
--- a/backend/BPA.MES.Base.Application/Entitys/Sys/AuthorizeTemplateItemEntity.cs
+++ /dev/null
@@ -1,27 +0,0 @@
-namespace BPA.MES.Base.Application.Entitys
-{
- ///
- /// 名 称 : 授权模板子项表
- /// 创 建 人 :yangxiao
- /// 创建时间 : 2023/1/4 17:31:27
- /// 描 述 :
- ///
- [SugarTable("sys_authorizetemplate_item")]
- public class AuthorizeTemplateItemEntity : DEntityBase
- {
- ///
- /// 模板编号
- ///
- public string TB_TemplateId { get; set; }
-
- ///
- /// 模块编号
- ///
- public string TB_ModuleId { get; set; }
-
- ///
- /// 是否删除
- ///
- public bool IsDeleted { get; set; }
- }
-}
diff --git a/backend/BPA.MES.Base.Application/Entitys/Sys/AuthorizeTemplateMapEntity.cs b/backend/BPA.MES.Base.Application/Entitys/Sys/AuthorizeTemplateMapEntity.cs
deleted file mode 100644
index 90f33fa..0000000
--- a/backend/BPA.MES.Base.Application/Entitys/Sys/AuthorizeTemplateMapEntity.cs
+++ /dev/null
@@ -1,30 +0,0 @@
-namespace BPA.MES.Base.Application.Entitys
-{
- ///
- /// 名 称 :授权对象表
- /// 创 建 人 :yangxiao
- /// 创建时间 : 2023/1/4 17:31:39
- /// 描 述 :
- ///
- [SugarTable("sys_authorizetemplatemap")]
- public class AuthorizeTemplateMapEntity : DEntityBase
- {
- ///
- /// 授权模板编号
- ///
- public string TemplateId { get; set; }
-
- ///
- /// 授权对象编号(用户编号,角色编号)
- ///
- public string ObjectId { get; set; }
- ///
- /// 授权类型 1:用户,2:角色
- ///
- public int AuthorizeType { get; set; }
- ///
- /// 是否删除
- ///
- public bool IsDeleted { get; set; }
- }
-}
diff --git a/backend/BPA.MES.Base.Application/Entitys/Sys/RoleModuleEntity.cs b/backend/BPA.MES.Base.Application/Entitys/Sys/RoleModuleEntity.cs
new file mode 100644
index 0000000..bec361f
--- /dev/null
+++ b/backend/BPA.MES.Base.Application/Entitys/Sys/RoleModuleEntity.cs
@@ -0,0 +1,26 @@
+namespace BPA.MES.Base.Application.Entitys
+{
+ ///
+ /// 名 称 :角色权限表
+ /// 创 建 人 :yangxiao
+ /// 创建时间 : 2023/8/31 15:56:02
+ /// 描 述 :
+ ///
+ [SugarTable("sys_role_module")]
+ public class RoleModuleEntity : DEntityBase
+ {
+ ///
+ /// 角色Id
+ ///
+ public string RoleId { get; set; }
+ ///
+ /// 模块Id
+ ///
+ public string ModuleId { get; set; }
+ ///
+ /// 父级模块
+ ///
+ [SugarColumn(IsNullable =true)]
+ public string ParentId { get; set; }
+ }
+}
diff --git a/backend/BPA.MES.Base.Application/Services/SystemService/Dtos/AuthorModuleInput.cs b/backend/BPA.MES.Base.Application/Services/SystemService/Dtos/AuthorModuleInput.cs
deleted file mode 100644
index 2584501..0000000
--- a/backend/BPA.MES.Base.Application/Services/SystemService/Dtos/AuthorModuleInput.cs
+++ /dev/null
@@ -1,134 +0,0 @@
-///
-/// 名 称 :[授权模块]实体基础
-/// 创 建 人 :yangxiao
-/// 创建时间 : 2023/1/3 10:21:42
-/// 描 述
-///
-namespace BPA.MES.Base.Application
-{
- ///
- /// [授权模块]入参基础
- ///
- public class AuthorModuleInput
- {
- ///
- /// 子级列表
- ///
- public List? Childrens { get; set; }
- ///
- /// 拥有权限
- ///
- public bool HasPermission { get; set; }
- ///
- /// 模块编号
- ///
- public string Id { get; set; }
-
- ///
- /// 类别 1:菜单,2:视图,3:功能
- ///
- public int Category { get; set; }
-
- ///
- /// 菜单打开方式 0:框架内嵌,1:新开页面
- ///
- public int OpenType { get; set; }
-
- ///
- /// 父级编号
- ///
- public string ParentId { get; set; }
-
- ///
- /// 名称
- ///
- public string Name { set; get; }
-
- ///
- /// 图标
- ///
- public string Icon { set; get; }
-
- ///
- /// 地址
- ///
- public string Url { set; get; }
- ///
- /// 排序码
- ///
- public int Sort { set; get; }
- ///
- /// 启用禁用
- ///
- public bool IsDisabled { get; set; }
-
- ///
- /// 子集
- ///
- public List? Children { get; set; }
- }
- ///
- /// [授权模块]添加入参
- ///
- public class AuthorModuleAddInput : AuthorModuleInput
- {
-
- }
-
- ///
- /// [授权模块]批量授权信息
- ///
- public class AuthorModulesAddInput
- {
- ///
- /// 模板名称
- ///
- public string TemplateName { set; get; }
-
- ///
- /// 授权模块
- ///
- public List ModuleIds { get; set; }
- }
-
- ///
- /// [授权模块]修改入参
- ///
- public class AuthorModuleUpdateInput : AuthorModuleInput
- {
- ///
- /// 主键
- ///
- public string? Id { get; set; }
- }
- ///
- /// [授权模块]删除入参
- ///
- public class AuthorModuleDelInput
- {
- ///
- /// 主键
- ///
- public string? Id { get; set; }
- }
- ///
- /// [授权模块]普通查询入参
- ///
- public class AuthorModuleQueryInput
- {
- ///
- /// 主键
- ///
- public string? Id { get; set; }
- }
- ///
- /// [授权模块]分页查询入参
- ///
- public class AuthorModuleQueryPageInput : RequestPage
- {
- ///
- /// 主键
- ///
- public string? Id { get; set; }
- }
-}
\ No newline at end of file
diff --git a/backend/BPA.MES.Base.Application/Services/SystemService/Dtos/AuthorModuleItemInput.cs b/backend/BPA.MES.Base.Application/Services/SystemService/Dtos/AuthorModuleItemInput.cs
deleted file mode 100644
index 0efce1f..0000000
--- a/backend/BPA.MES.Base.Application/Services/SystemService/Dtos/AuthorModuleItemInput.cs
+++ /dev/null
@@ -1,70 +0,0 @@
-///
-/// 名 称 :[账号信息]实体基础
-/// 创 建 人 :yangxiao
-/// 创建时间 : 2023/1/3 10:21:42
-/// 描 述
-///
-namespace BPA.MES.Base.Application
-{
- ///
- /// [账号信息]入参基础
- ///
- public class AuthorModuleItemInput
- {
- ///
- /// 模板Id
- ///
- public string TB_TemplateId { get; set; }
- ///
- /// 模块Id
- ///
- public List TB_ModuleIds { get; set; }
- }
- ///
- /// [账号信息]添加入参
- ///
- public class AuthorModuleItemAddInput : AuthorModuleItemInput
- {
-
- }
- ///
- /// [账号信息]修改入参
- ///
- public class AuthorModuleItemUpdateInput : AuthorModuleItemInput
- {
- ///
- /// 主键
- ///
- public string? Id { get; set; }
- }
- ///
- /// [账号信息]删除入参
- ///
- public class AuthorModuleItemDelInput
- {
- ///
- /// 主键
- ///
- public string? Id { get; set; }
- }
- ///
- /// [账号信息]普通查询入参
- ///
- public class AuthorModuleItemQueryInput
- {
- ///
- /// 主键
- ///
- public string? Id { get; set; }
- }
- ///
- /// [账号信息]分页查询入参
- ///
- public class AuthorModuleItemQueryPageInput : RequestPage
- {
- ///
- /// 主键
- ///
- public string? Id { get; set; }
- }
-}
\ No newline at end of file
diff --git a/backend/BPA.MES.Base.Application/Services/SystemService/Dtos/AuthorModuleItemOutput.cs b/backend/BPA.MES.Base.Application/Services/SystemService/Dtos/AuthorModuleItemOutput.cs
deleted file mode 100644
index 3a49ef3..0000000
--- a/backend/BPA.MES.Base.Application/Services/SystemService/Dtos/AuthorModuleItemOutput.cs
+++ /dev/null
@@ -1,17 +0,0 @@
-namespace BPA.MES.Base.Application
-{
- ///
- /// 名 称 :
- /// 创 建 人 :yangxiao
- /// 创建时间 : 2023/1/4 17:20:51
- /// 描 述 :
- ///
- public class AuthorModuleItemOutput
- {
- ///
- /// 模块编号
- ///
- public string Id { get; set; }
-
- }
-}
diff --git a/backend/BPA.MES.Base.Application/Services/SystemService/Dtos/AuthorModuleOutput.cs b/backend/BPA.MES.Base.Application/Services/SystemService/Dtos/AuthorModuleOutput.cs
deleted file mode 100644
index 2836c5e..0000000
--- a/backend/BPA.MES.Base.Application/Services/SystemService/Dtos/AuthorModuleOutput.cs
+++ /dev/null
@@ -1,68 +0,0 @@
-namespace BPA.MES.Base.Application
-{
- ///
- /// 名 称 :授权模块输出
- /// 创 建 人 :yangxiao
- /// 创建时间 : 2023/1/4 17:18:24
- /// 描 述 :
- ///
- public class AuthorModuleOutput
- {
- ///
- /// 子级列表
- ///
- public List? Childrens { get; set; }
- ///
- /// 拥有权限
- ///
- public bool HasPermission { get; set; }
- ///
- /// 模块编号
- ///
- public string Id { get; set; }
-
- ///
- /// 类别 1:菜单,2:视图,3:功能
- ///
- public int Category { get; set; }
-
- ///
- /// 菜单打开方式 0:框架内嵌,1:新开页面
- ///
- public int OpenType { get; set; }
-
- ///
- /// 父级编号
- ///
- public string ParentId { get; set; }
-
- ///
- /// 名称
- ///
- public string Name { set; get; }
-
- ///
- /// 图标
- ///
- public string Icon { set; get; }
-
- ///
- /// 地址
- ///
- public string Url { set; get; }
- ///
- /// 排序码
- ///
- public int Sort { set; get; }
- ///
- /// 启用禁用
- ///
- public bool IsDisabled { get; set; }
-
- ///
- /// 子集
- ///
- public List? Children { get; set; }
- }
-
-}
diff --git a/backend/BPA.MES.Base.Application/Services/SystemService/Dtos/AuthorizeTemplateInput.cs b/backend/BPA.MES.Base.Application/Services/SystemService/Dtos/AuthorizeTemplateInput.cs
deleted file mode 100644
index 8f6111d..0000000
--- a/backend/BPA.MES.Base.Application/Services/SystemService/Dtos/AuthorizeTemplateInput.cs
+++ /dev/null
@@ -1,74 +0,0 @@
-///
-/// 名 称 :[授权模块]实体基础
-/// 创 建 人 :yangxiao
-/// 创建时间 : 2023/1/3 10:21:42
-/// 描 述
-///
-namespace BPA.MES.Base.Application
-{
- ///
- /// [授权模块]入参基础
- ///
- public class AuthorizeTemplateInput
- {
- ///
- /// 名称
- ///
- public string Name { get; set; }
- ///
- /// 描述
- ///
- public string Remark { get; set; }
- }
- ///
- /// [授权模块]添加入参
- ///
- public class AuthorizeTemplateAddInput : AuthorizeTemplateInput
- {
-
- }
- ///
- /// [授权模块]修改入参
- ///
- public class AuthorizeTemplateUpdateInput : AuthorizeTemplateInput
- {
- ///
- /// 主键
- ///
- public string? Id { get; set; }
- }
- ///
- /// [授权模块]删除入参
- ///
- public class AuthorizeTemplateDelInput
- {
- ///
- /// 主键
- ///
- public string? Id { get; set; }
- }
- ///
- /// [授权模块]普通查询入参
- ///
- public class AuthorizeTemplateQueryInput
- {
- ///
- /// 主键
- ///
- public string? Id { get; set; }
- }
- ///
- /// [授权模块]分页查询入参
- ///
- public class AuthorizeTemplateQueryPageInput : RequestPage
- {
- ///
- /// 主键
- ///
- public string? Id { get; set; }
- ///
- /// 关键字
- ///
- public string Keyword { get; set; }
- }
-}
\ No newline at end of file
diff --git a/backend/BPA.MES.Base.Application/Services/SystemService/Dtos/AuthorizeTemplateOutput.cs b/backend/BPA.MES.Base.Application/Services/SystemService/Dtos/AuthorizeTemplateOutput.cs
deleted file mode 100644
index 17e228d..0000000
--- a/backend/BPA.MES.Base.Application/Services/SystemService/Dtos/AuthorizeTemplateOutput.cs
+++ /dev/null
@@ -1,24 +0,0 @@
-namespace BPA.MES.Base.Application
-{
- ///
- /// Ȩģ
- /// yangxiao
- /// ʱ 2023/1/4 9:48:24
- ///
- ///
- public class AuthorizeTemplateOutput
- {
- ///
- ///
- ///
- public string Id { get; set; }
- ///
- ///
- ///
- public string Name { get; set; }
- ///
- ///
- ///
- public string Remark { get; set; }
- }
-}
diff --git a/backend/BPA.MES.Base.Application/Services/SystemService/Dtos/RoleModuleDto.cs b/backend/BPA.MES.Base.Application/Services/SystemService/Dtos/RoleModuleDto.cs
new file mode 100644
index 0000000..dbb6a2c
--- /dev/null
+++ b/backend/BPA.MES.Base.Application/Services/SystemService/Dtos/RoleModuleDto.cs
@@ -0,0 +1,50 @@
+namespace BPA.MES.Base.Application
+{
+ ///
+ /// 名 称 :
+ /// 创 建 人 :yangxiao
+ /// 创建时间 : 2023/8/31 15:58:31
+ /// 描 述 :
+ ///
+ public class RoleModuleDto
+ {
+ ///
+ /// 角色Id
+ ///
+ public string RoleId { get; set; }
+ ///
+ /// 模块Id
+ ///
+ public string ModuleId { get; set; }
+ ///
+ /// 父级Id
+ ///
+ public string ParentId { get; set; }
+ }
+ public class RoleModuleAddInput
+ {
+ public List ModuleIds { get; set; }
+ ///
+ /// 角色Id
+ ///
+ public string RoleId { get; set; }
+ }
+ public class RoleModuleOutput
+ {
+ ///
+ /// 角色Id
+ ///
+ public string RoleId { get; set; }
+ ///
+ /// 模块Id
+ ///
+ public string ModuleId { get; set; }
+ }
+ public class RoleModuleQuery
+ {
+ ///
+ /// 角色Id
+ ///
+ public string RoleId { get; set; }
+ }
+}
diff --git a/backend/BPA.MES.Base.Application/Services/SystemService/Services/AuthorizeService.cs b/backend/BPA.MES.Base.Application/Services/SystemService/Services/AuthorizeService.cs
index 195343a..59df812 100644
--- a/backend/BPA.MES.Base.Application/Services/SystemService/Services/AuthorizeService.cs
+++ b/backend/BPA.MES.Base.Application/Services/SystemService/Services/AuthorizeService.cs
@@ -50,6 +50,7 @@
{ClaimConst.CLAINM_USERID, User.Id},
{ClaimConst.CLAINM_NAME,User.Name},
{ClaimConst.CLAINM_ISAUTH,User.IsAdmin},
+ {ClaimConst.CLAINM_ROLEID,User.RoleId }
}, 43200);
// 设置Swagger自动登录
_httpContextAccessor.HttpContext.SigninToSwagger(accessToken);
@@ -104,71 +105,24 @@
async Task GetJurisdictionItemsAsync()
{
- string userId = App.User?.FindFirst(ClaimConst.CLAINM_USERID)?.Value;
+ string userId = App.User?.FindFirst(ClaimConst.CLAINM_USERID)?.Value;
+ string roleId = App.User?.FindFirst(ClaimConst.CLAINM_ROLEID)?.Value;
var result = new UserRoleCacheDto();
-
- result.AuthorizationCodes = (await GetAuthorityModuleIdsAsync(userId)) ?? new List();
-
+ //根据角色获取权限Id
+ var rolemodules = await db.Queryable().Where(x => x.RoleId == roleId).ToListAsync();
+ result.AuthorizationCodes = rolemodules.Select(t => t.ModuleId).ToList();
if (result.AuthorizationCodes.HasVal())
{
- var temp = await db.Queryable().Where(t => t.Category == 1 || t.Category == 2 || t.Category == 3)
- .Where(t => result.AuthorizationCodes.Contains(t.Id) && !t.IsDisabled).OrderBy(t => t.ParentId)
+ var temp = await db.Queryable().Where(t => result.AuthorizationCodes.Contains(t.Id) && !t.IsDisabled).OrderBy(t => t.ParentId)
.ToListAsync();
result.Menus = temp.Adapt>().BuildTree();
}
-
- result.Menus = result.Menus ?? new List();
+ result.Menus ??= new List();
return result;
}
///
- /// 获取权限模块编号
- ///
- ///
- ///
- ///
- [HttpGet]
- async Task> GetAuthorityModuleIdsAsync(string userId)
- {
- List moduleIds = null;
-
- var user = await db.Queryable().Where(m => m.Id == userId).FirstAsync();
-
- if (user == null)
- {
- return moduleIds;
- }
-
- //超管用户
- if (user.IsAdmin)
- {
- moduleIds = await db.Queryable()
- .OrderBy(m => m.ParentId).OrderBy(m => m.Name)
- .ToListAsync(m => m.Id);
- }
- else
- {
- moduleIds = await GetAuthorityModuleIdsAsync((category) =>
- {
- if (category == 1)
- {
- return user.Id;
- }
- if (category == 2)
- {
- return user.RoleId;
- }
- else
- {
- throw new NotImplementedException("无效授权类别");
- }
- });
- }
-
- return moduleIds;
- }
- ///
/// 获取账户信息
///
///
@@ -211,33 +165,7 @@
var entity = input.Adapt();
return await _dbContext.Deleteable(entity).Where(x=>x.Id==input.Id).ExecuteCommandHasChangeAsync();
}
- ///
- /// 获取授权模块编号
- ///
- ///
- ///
- [HttpGet]
- async Task> GetAuthorityModuleIdsAsync(Func getObjectId)
- {
- for (int index = 1; index <= 2; index++)
- {
- var objectId = getObjectId(index);
- var templateIds = await db.Queryable().LeftJoin((t, x) => t.TemplateId == x.Id)
- .Where((t, x) => t.AuthorizeType == index && t.ObjectId == objectId).ToListAsync(t => t.TemplateId);
-
- if (!templateIds.HasVal() || templateIds.Count == 0)
- {
- continue;
- }
- return await db.Queryable().LeftJoin((t, x) => t.TB_ModuleId == x.Id)
- .Where((t, x) => templateIds.Contains(t.TB_TemplateId))
- .GroupBy((t, x) => t.TB_ModuleId).ToListAsync(t => t.TB_ModuleId);
- }
- return null;
- }
#endregion
-
-
#region 角色
[HttpPost]
public async Task AddRole(RoleAddInput input)
@@ -349,174 +277,8 @@
}
#endregion
- #region 授权模板
- [HttpPost]
- public async Task AddAuthorTemp(AuthorizeTemplateAddInput input)
- {
- if (await db.Queryable().Where(it => it.Name == input.Name && it.IsDeleted == false).AnyAsync())
- throw Oops.Bah("模板名称已经存在");
- var data = await db.Insertable(input.Adapt()).ExecuteCommandAsync();
- return data > 0;
- }
- [HttpPost]
- public async Task EditAuthorTemp(AuthorizeTemplateUpdateInput input)
- {
- if (!await db.Queryable().Where(it => it.Id == input.Id && it.IsDeleted == false).AnyAsync())
- throw Oops.Bah("模板不存在或已被删除");
- if (await db.Queryable().Where(it => it.Id != input.Id && it.Name == input.Name && it.IsDeleted == false).AnyAsync())
- throw Oops.Bah("模板名称已经存在");
- return await db.Updateable(input).Where(a => a.Id == input.Id).ExecuteCommandHasChangeAsync();
- }
- [HttpGet]
- public async Task RemoveAuthorTemp(string input)
- {
- var f1 = await db.Updateable().SetColumns(t => t.IsDeleted == true).Where(t => t.Id == input).ExecuteCommandHasChangeAsync();
- var f2 = await db.Updateable().SetColumns(T => T.IsDeleted == true).Where(t => t.TB_TemplateId == input).ExecuteCommandHasChangeAsync();
- return f1 && f2;
- }
- [HttpPost]
- public async Task> QueryAuthorTemp(AuthorizeTemplateQueryPageInput input)
- {
- RefAsync Total = 0;
- var data = await db.Queryable().Where(t => !t.IsDeleted)
- .WhereIF(!string.IsNullOrEmpty(input.Keyword), t => t.Name.Contains(input.Keyword))
- .OrderByDescending(t => t.CreateAt)
- .Select()
- .ToPagedListAsync(input.PageIndex, input.PageSize);
- return data;
- }
- public async Task GetAuthorTemp(string input)
- {
- var data = await db.Queryable().Where(it => it.Id == input && it.IsDeleted == false).FirstAsync();
- return data.Adapt();
- }
- #endregion
-
#region 授权模板详情
[HttpGet]
- public async Task> GetModuleByTemplateId(string input)
- {
- var entity =await db.Queryable().Where(m => m.TB_TemplateId == input).ToListAsync();
- return entity;
- }
- [HttpPost]
- public async Task EditTemplateItem(AuthorModuleItemUpdateInput input)
- {
- var temp = await db.Queryable().FirstAsync(t => t.Id == input.TB_TemplateId && t.IsDeleted == false);
-
- try
- {
- db.Ado.BeginTran();
- await db.Deleteable()
- .Where(t => t.TB_TemplateId == input.TB_TemplateId).ExecuteCommandAsync();
- var entity = input.TB_ModuleIds.Distinct().ToList().ConvertAll(t => new AuthorizeTemplateItemEntity
- {
- TB_ModuleId = t,
- TB_TemplateId = input.TB_TemplateId
- });
- await db.Insertable(entity).ExecuteCommandAsync();
- db.Ado.CommitTran();
- return true;
- }
- catch (Exception ex)
- {
- throw Oops.Bah(ex.Message);
- }
- }
- [HttpPost]
- public async Task> GetAuthorizeObjects(AuthorizeInput input)
- {
- List result;
- if (input.Type == 2)
- {
- var temp = await db.Queryable()
- .Where(t => t.RoleType != 1)
- .Where(t => t.IsDeleted == false)
- .WhereIF(!string.IsNullOrWhiteSpace(input.Keyword), t => t.Name.Contains(input.Keyword))
- .OrderBy(t => t.RoleType)
- .OrderBy(t => t.Name)
- .ToListAsync();
-
- result = temp.Adapt>();
- db.ThenMapper(result, item =>
- {
- item.IsAuthorized = db.Queryable()
- .Where(m => m.TemplateId == input.TemplateId && m.AuthorizeType == input.Type && m.ObjectId == item.Id).Any();
- });
- }
- else
- {
- var temp = await db.Queryable()
- .Where(t => t.IsAdmin == false)
- .WhereIF(!string.IsNullOrWhiteSpace(input.Keyword), t => t.Name.Contains(input.Keyword))
- .OrderBy(t => t.Name)
- .ToListAsync();
- result = temp.Adapt>();
- db.ThenMapper(result, item =>
- {
- item.IsAuthorized = db.Queryable().Where(t => t.IsDeleted == false)
- .Where(m => m.TemplateId == input.TemplateId && m.AuthorizeType == input.Type && m.ObjectId == item.Id).Any();
- });
- }
- if (result.HasVal())
- {
- result = result.OrderByDescending(m => m.IsAuthorized).ThenBy(m => m.Name).ToList();
- }
- return result;
- }
- [HttpPost]
- public async Task RemoveAuthorize(AuthorizeInput input)
- {
- var objectIds = input.ObjectIds.Distinct().ToArray();
- return await db.Updateable().SetColumns(t => t.IsDeleted == true)
- .Where(it => it.TemplateId == input.TemplateId && it.AuthorizeType == input.Type && objectIds.Contains(it.ObjectId))
- .ExecuteCommandHasChangeAsync();
- }
- [HttpPost]
- public async Task AddAuthorize(AuthorMapAddInput input)
- {
- foreach (var item in input.TemplateIds.Distinct())
- {
- if (!await _dbContext.Queryable().AnyAsync(m => m.TemplateId == item && m.AuthorizeType == input.AuthorizeType && m.IsDeleted == false && m.ObjectId == input.ObjectId))
- {
- await _dbContext.Insertable(new AuthorizeTemplateMapEntity()
- {
- TemplateId = item,
- ObjectId = input.ObjectId,
- AuthorizeType = input.AuthorizeType
- }).ExecuteCommandAsync();
- }
- }
- }
- [HttpPost]
- public async Task SaveAuthorize(AuthorModulesAddInput input)
- {
- if (await db.Queryable().Where(it => it.Name == input.TemplateName && it.IsDeleted == false).AnyAsync())
- {
- throw Oops.Bah("模板名称已经存在");
- }
- AuthorizeTemplateEntity Model = new AuthorizeTemplateEntity();
- Model.Name = input.TemplateName;
- List templateItems = input.ModuleIds.ConvertAll(m => new AuthorizeTemplateItemEntity
- {
- TB_TemplateId = Model.Id,
- TB_ModuleId = m
- });
- try
- {
- db.Ado.BeginTran();
- var f1 = (await db.Insertable(Model).ExecuteCommandAsync()) > 0;
- var f2 = (await _dbContext.Insertable(templateItems).ExecuteCommandAsync()) > 0;
- db.Ado.CommitTran();
- return f1 && f2;
- }
- catch (Exception)
- {
- db.Ado.RollbackTran();
- return false;
- }
- }
- [HttpGet]
public async Task RestoreAccountByUser(string input)
{
var Demo = "123456".ToMD5Encrypt();
@@ -629,6 +391,50 @@
var data = await db.Queryable().Where(t => t.IsAdmin == false).ToListAsync();
return data.Adapt>();
}
+ ///
+ /// 分配角色权限
+ ///
+ ///
+ ///
+ [HttpPost]
+ public async Task AddRoleModule(RoleModuleAddInput input)
+ {
+ List entitys = new();
+ foreach (var item in input.ModuleIds)
+ {
+ RoleModuleEntity entity = new()
+ {
+ ModuleId = item.ModuleId,
+ ParentId = item.ParentId,
+ RoleId = input.RoleId
+ };
+ entitys.Add(entity);
+ }
+ try
+ {
+ _dbContext.Ado.BeginTran();
+ await _dbContext.Deleteable().Where(x => x.RoleId == input.RoleId).ExecuteCommandAsync();
+ await _dbContext.Insertable(entitys).ExecuteCommandAsync();
+ _dbContext.Ado.CommitTran();
+ return true;
+ }
+ catch (Exception ex)
+ {
+ throw Oops.Bah(ex.Message);
+ }
+ }
+ ///
+ /// 根据角色获取权限模块
+ ///
+ ///
+ ///
+ [HttpGet]
+ public async Task> RoleModuleList(string RoleId)
+ {
+ var entitys = await _dbContext.Queryable().Where(x => x.RoleId == RoleId).ToListAsync();
+ var output = entitys.Adapt>();
+ return output;
+ }
#endregion
}
}
diff --git a/backend/BPA.MES.Base.Application/Services/SystemService/Services/IAuthorizeService.cs b/backend/BPA.MES.Base.Application/Services/SystemService/Services/IAuthorizeService.cs
index e2fc37d..2cd96d5 100644
--- a/backend/BPA.MES.Base.Application/Services/SystemService/Services/IAuthorizeService.cs
+++ b/backend/BPA.MES.Base.Application/Services/SystemService/Services/IAuthorizeService.cs
@@ -35,6 +35,8 @@ public interface IAuthorizeService
Task GetRole(string input);
Task> GetRoleList();
Task> QueryRole(RoleQueryPageInput input);
+
+ Task AddRoleModule(RoleModuleAddInput input);
#endregion
#region 模块
@@ -44,20 +46,5 @@ public interface IAuthorizeService
Task> GetTreeGrid(ModuleTreeQueryInput input);
#endregion
- #region 授权模板
- Task AddAuthorTemp(AuthorizeTemplateAddInput input);
- Task EditAuthorTemp(AuthorizeTemplateUpdateInput input);
- Task RemoveAuthorTemp(string input);
- Task> QueryAuthorTemp(AuthorizeTemplateQueryPageInput input);
- Task GetAuthorTemp(string input);
- #endregion
-
- #region 授权模板详情
- Task> GetModuleByTemplateId(string input);
- Task EditTemplateItem(AuthorModuleItemUpdateInput input);
- Task> GetAuthorizeObjects(AuthorizeInput input);
- Task RemoveAuthorize(AuthorizeInput input);
- Task SaveAuthorize(AuthorModulesAddInput input);
- Task AddAuthorize(AuthorMapAddInput input);
- #endregion
+
}