From 38a62595bafc81d966a1123011b43a970808ce85 Mon Sep 17 00:00:00 2001 From: yubaolee Date: Mon, 5 Jul 2021 21:44:35 +0800 Subject: [PATCH] =?UTF-8?q?fix=20issue=20#I3YVBH=20=E5=85=BC=E5=AE=B9oracl?= =?UTF-8?q?e=2011g=20add=20load=20all=20users/roles=20for=20flowinstance?= =?UTF-8?q?=20fix=20issue=20#I3W5YR?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- OpenAuth.App/Base/BaseLongApp.cs | 4 +- OpenAuth.App/BuilderTable/BuilderTableApp.cs | 8 +- OpenAuth.App/RoleManager/RoleApp.cs | 23 +++++ OpenAuth.App/SysMessage/SysMessageApp.cs | 2 +- OpenAuth.App/UserManager/UserManagerApp.cs | 82 ++++++++++++++-- OpenAuth.Identity/Startup.cs | 2 +- OpenAuth.Mvc/Views/Home/Main.cshtml | 97 +++++++++++-------- OpenAuth.Mvc/Views/SysMessages/index.cshtml | 2 +- OpenAuth.Mvc/wwwroot/userJs/main.js | 2 +- OpenAuth.Mvc/wwwroot/userJs/sysmessages.js | 4 + OpenAuth.Repository/Core/LongEntity.cs | 2 +- OpenAuth.Repository/OpenAuthDBContext.cs | 6 +- .../Controllers/RolesController.cs | 13 ++- .../Controllers/UsersController.cs | 10 ++ mysql初始化脚本/mysql脚本.sql | 8 ++ 15 files changed, 205 insertions(+), 60 deletions(-) diff --git a/OpenAuth.App/Base/BaseLongApp.cs b/OpenAuth.App/Base/BaseLongApp.cs index e7175898..9317e60c 100644 --- a/OpenAuth.App/Base/BaseLongApp.cs +++ b/OpenAuth.App/Base/BaseLongApp.cs @@ -27,12 +27,12 @@ namespace OpenAuth.App /// 按id批量删除 /// /// - public void Delete(long[] ids) + public void Delete(decimal[] ids) { Repository.Delete(u => ids.Contains(u.Id)); } - public T Get(long id) + public T Get(decimal id) { return Repository.FirstOrDefault(u => u.Id == id); } diff --git a/OpenAuth.App/BuilderTable/BuilderTableApp.cs b/OpenAuth.App/BuilderTable/BuilderTableApp.cs index 256b1c6d..4d445044 100644 --- a/OpenAuth.App/BuilderTable/BuilderTableApp.cs +++ b/OpenAuth.App/BuilderTable/BuilderTableApp.cs @@ -275,7 +275,7 @@ namespace OpenAuth.App { throw new Exception($"未能找到表{sysTableInfo.TableName}的主键字段"); } - if (primarykey.ColumnType == "decimal" || primarykey.ColumnType == "numberic") //是否为数字 + if (primarykey.ColumnType == "decimal" || primarykey.ColumnType == "numeric") //是否为数字 { if(primarykey.IsIncrement) //是否自增 { @@ -386,7 +386,7 @@ namespace OpenAuth.App { throw new Exception($"未能找到表{sysTableInfo.TableName}的主键字段"); } - if (primarykey.ColumnType == "decimal" || primarykey.ColumnType == "numberic") //是否为数字 + if (primarykey.ColumnType == "decimal" || primarykey.ColumnType == "numeric") //是否为数字 { if(primarykey.IsIncrement) //是否自增 { @@ -394,7 +394,7 @@ namespace OpenAuth.App } else //普通的雪花算法生成id { - domainContent = domainContent.Replace("{KeyTypeName}", "long"); + domainContent = domainContent.Replace("{KeyTypeName}", "decimal"); } } else @@ -458,7 +458,7 @@ namespace OpenAuth.App { throw new Exception($"未能找到表{tableInfo.TableName}的主键字段"); } - if (primarykey.ColumnType == "decimal" || primarykey.ColumnType == "numberic") //是否为数字 + if (primarykey.ColumnType == "decimal" || primarykey.ColumnType == "numeric") //是否为数字 { if(primarykey.IsIncrement) //是否自增 { diff --git a/OpenAuth.App/RoleManager/RoleApp.cs b/OpenAuth.App/RoleManager/RoleApp.cs index 8522427c..1160d43e 100644 --- a/OpenAuth.App/RoleManager/RoleApp.cs +++ b/OpenAuth.App/RoleManager/RoleApp.cs @@ -5,6 +5,7 @@ using OpenAuth.App.Response; using OpenAuth.Repository.Domain; using OpenAuth.Repository.Interface; using System.Linq; +using System.Threading.Tasks; using Infrastructure; using OpenAuth.App.Request; using OpenAuth.Repository; @@ -29,6 +30,26 @@ namespace OpenAuth.App return roles; } + + /// + /// 获取所有的角色 + /// 为了控制权限,通常只用于流程实例选择执行角色,其他地方请使用Load + /// + public async Task> LoadAll(QueryRoleListReq request) + { + var result = new TableResp(); + var objs = UnitWork.Find(null); + if (!string.IsNullOrEmpty(request.key)) + { + objs = objs.Where(u => u.Name.Contains(request.key)); + } + + result.data = objs.OrderBy(u => u.Name) + .Skip((request.page - 1) * request.limit) + .Take(request.limit).ToList(); + result.count = objs.Count(); + return result; + } /// @@ -80,5 +101,7 @@ namespace OpenAuth.App { _revelanceApp = app; } + + } } \ No newline at end of file diff --git a/OpenAuth.App/SysMessage/SysMessageApp.cs b/OpenAuth.App/SysMessage/SysMessageApp.cs index de132fb2..e8df8d21 100644 --- a/OpenAuth.App/SysMessage/SysMessageApp.cs +++ b/OpenAuth.App/SysMessage/SysMessageApp.cs @@ -43,7 +43,7 @@ namespace OpenAuth.App objs = objs.Where(u => u.ToStatus == request.Status); } - result.data = objs.OrderBy(u => u.Id) + result.data = objs.OrderByDescending(u => u.CreateTime) .Skip((request.page - 1) * request.limit) .Take(request.limit); result.count = objs.Count(); diff --git a/OpenAuth.App/UserManager/UserManagerApp.cs b/OpenAuth.App/UserManager/UserManagerApp.cs index 2daf510c..97855011 100644 --- a/OpenAuth.App/UserManager/UserManagerApp.cs +++ b/OpenAuth.App/UserManager/UserManagerApp.cs @@ -39,16 +39,15 @@ namespace OpenAuth.App public async Task Load(QueryUserListReq request) { var loginUser = _auth.GetCurrentUser(); - - + IQueryable query = UnitWork.Find(null); if (!string.IsNullOrEmpty(request.key)) { query = UnitWork.Find(u => u.Name.Contains(request.key) || u.Account.Contains(request.key)); } - + var userOrgs = from user in query - join relevance in UnitWork.Find(u =>u.Key=="UserOrg") + join relevance in UnitWork.Find(u => u.Key == "UserOrg") on user.Id equals relevance.FirstId into temp from r in temp.DefaultIfEmpty() join org in UnitWork.Find(null) @@ -69,9 +68,9 @@ namespace OpenAuth.App r.Key, r.SecondId, OrgId = o.Id, - OrgName= o.Name + OrgName = o.Name }; - + //如果请求的orgId不为空 if (!string.IsNullOrEmpty(request.orgId)) { @@ -115,7 +114,73 @@ namespace OpenAuth.App .Take(request.limit), }; } + + /// + /// 获取所有的用户 + /// 为了控制权限,通常只用于流程实例选择执行角色,其他地方请使用Load + /// + public async Task> LoadAll(QueryUserListReq request) + { + IQueryable query = UnitWork.Find(null); + if (!string.IsNullOrEmpty(request.key)) + { + query = UnitWork.Find(u => u.Name.Contains(request.key) || u.Account.Contains(request.key)); + } + var userOrgs = from user in query + join relevance in UnitWork.Find(u => u.Key == "UserOrg") + on user.Id equals relevance.FirstId into temp + from r in temp.DefaultIfEmpty() + join org in UnitWork.Find(null) + on r.SecondId equals org.Id into orgtmp + from o in orgtmp.DefaultIfEmpty() + select new + { + user.Account, + user.Name, + user.Id, + user.Sex, + user.Status, + user.BizCode, + user.CreateId, + user.CreateTime, + user.TypeId, + user.TypeName, + r.Key, + r.SecondId, + OrgId = o.Id, + OrgName = o.Name + }; + + //如果请求的orgId不为空 + if (!string.IsNullOrEmpty(request.orgId)) + { + userOrgs = userOrgs.Where(u => u.Key == Define.USERORG && u.OrgId == request.orgId); + } + + var userViews = userOrgs.ToList().GroupBy(b => b.Account).Select(u =>new UserView + { + Id = u.First().Id, + Account = u.Key, + Name = u.First().Name, + Sex = u.First().Sex, + Status = u.First().Status, + CreateTime = u.First().CreateTime, + CreateUser = u.First().CreateId, + OrganizationIds = string.Join(",", u.Select(x=>x.OrgId)) + ,Organizations = string.Join(",", u.Select(x=>x.OrgName)) + + }); + + return new TableResp() + { + count = userViews.Count(), + data = userViews.OrderBy(u => u.Name) + .Skip((request.page - 1) * request.limit) + .Take(request.limit).ToList() + }; + } + public void AddOrUpdate(UpdateUserReq request) { request.ValidationEntity(u => new {u.Account,u.Name, u.OrganizationIds}); @@ -201,6 +266,7 @@ namespace OpenAuth.App }); } + /// /// 获取指定角色包含的用户列表 /// @@ -228,9 +294,9 @@ namespace OpenAuth.App /// public async Task LoadByOrg(QueryUserListByOrgReq request) { - var users = from userRole in UnitWork.Find(u => + var users = from userOrg in UnitWork.Find(u => u.SecondId == request.orgId && u.Key == Define.USERORG) - join user in UnitWork.Find(null) on userRole.FirstId equals user.Id into temp + join user in UnitWork.Find(null) on userOrg.FirstId equals user.Id into temp from c in temp.Where(u =>u.Id != null) select c; diff --git a/OpenAuth.Identity/Startup.cs b/OpenAuth.Identity/Startup.cs index bc75cec8..05c50b6a 100644 --- a/OpenAuth.Identity/Startup.cs +++ b/OpenAuth.Identity/Startup.cs @@ -88,7 +88,7 @@ namespace OpenAuth.IdentityServer else //oracle { services.AddDbContext(options => - options.UseOracle(Configuration.GetConnectionString("OpenAuthDBContext"))); + options.UseOracle(Configuration.GetConnectionString("OpenAuthDBContext"), o=>o.UseOracleSQLCompatibility("11"))); } } diff --git a/OpenAuth.Mvc/Views/Home/Main.cshtml b/OpenAuth.Mvc/Views/Home/Main.cshtml index 5f6579d2..33a8af77 100644 --- a/OpenAuth.Mvc/Views/Home/Main.cshtml +++ b/OpenAuth.Mvc/Views/Home/Main.cshtml @@ -1,7 +1,8 @@ @section header { - + } +
@@ -79,7 +80,8 @@

项目地址 在线文档 - 企业版入口 + 企业版/高级版入口 + 企业版H5入口(请使用移动模式或者直接手机查看) 注:【本框架遵循LGPL开源协议,企业单位如商用请联系作者授权,谢谢】

技术交流QQ群:484498493【已满】     626433139【已满】    566344079

@@ -87,14 +89,33 @@
更新日志
-
+
+

# 3.2

+

* 【新增】增加在swagger界面查看接口调用时间及SQL执行时间

+

+ * 【新增】支持同时配置多个类型数据库的连接字符串: + 详见:http://doc.openauth.me/core/multidbs.html +

+

* 【新增】增加swagger接口分组

+

* 【新增】增加流程召回功能

+

* 【新增】增加运行时选定执行人、执行角色功能

+

* 【新增】增加Redis缓存支持

+

* 【新增】新增int类型数据库主键,并支持雪花算法自动生成

+

* 【新增】新增附件管理,上传图片支持生成缩略图

+
+

# 2.0

* 【新增】框架升级至.net core sdk 3.1.100

-

* 【新增】增加个人中心页面,可修改个人信息及切换当前默认部门

-

* 【优化】升级layui至2.5.6

+

+ * 【新增】增加 + + 个人中心 + 页面,可修改个人信息及切换当前默认部门 +

+

* 【优化】升级layui至2.5.6

* 【优化】可以灵活配置用户可访问的机构数据权限

-
-
+
+

# 1.6

* 【新增】日志及用户消息板块

* 【新增】企业版代码生成器,可以快速生成带有头/明细结构的页面

@@ -102,7 +123,7 @@

* 【新增】完整的字段权限控制,可以控制字段可见及API是否返回字段值

* 【优化】启用数据字典功能

* 【优化】优化导航排序、支持多级导航

-
+

# 1.5 - 2019.7

* 【优化】升级layui至2.5.4

@@ -111,7 +132,7 @@

* 【新增】集成IdentityServer4,实现基于OAuth2的登录体系

* 【新增】建立三方对接规范,已有系统可以无缝对接流程引擎,请参考官方对接说明

- +

# 1.4 - 2019.3

* 【优化】升级layui至2.4.5

@@ -133,34 +154,34 @@ - - 当前版本 - - - - 开发作者 - - - - 网站首页 - - - - 服务器环境 - - - - 数据库版本 - - - - 最大上传限制 - - - - 当前用户权限 - - + + 当前版本 + + + + 开发作者 + + + + 网站首页 + + + + 服务器环境 + + + + 数据库版本 + + + + 最大上传限制 + + + + 当前用户权限 + + @@ -168,4 +189,4 @@
- + \ No newline at end of file diff --git a/OpenAuth.Mvc/Views/SysMessages/index.cshtml b/OpenAuth.Mvc/Views/SysMessages/index.cshtml index 9c8d2f14..50964e25 100644 --- a/OpenAuth.Mvc/Views/SysMessages/index.cshtml +++ b/OpenAuth.Mvc/Views/SysMessages/index.cshtml @@ -28,6 +28,6 @@
- + diff --git a/OpenAuth.Mvc/wwwroot/userJs/main.js b/OpenAuth.Mvc/wwwroot/userJs/main.js index bb8538a6..a2505bb8 100644 --- a/OpenAuth.Mvc/wwwroot/userJs/main.js +++ b/OpenAuth.Mvc/wwwroot/userJs/main.js @@ -59,7 +59,7 @@ layui.config({ }) //系统基本参数 - $(".version").text("v2.0"); //当前版本 + $(".version").text("v3.2"); //当前版本 $(".author").text("yubaolee"); //开发作者 $(".homePage").text("/Home/Index"); //网站首页 $(".server").text("centos docker"); //服务器环境 diff --git a/OpenAuth.Mvc/wwwroot/userJs/sysmessages.js b/OpenAuth.Mvc/wwwroot/userJs/sysmessages.js index 2461c4ee..2a55aa33 100644 --- a/OpenAuth.Mvc/wwwroot/userJs/sysmessages.js +++ b/OpenAuth.Mvc/wwwroot/userJs/sysmessages.js @@ -21,6 +21,9 @@ , size: 'sm' //小尺寸的表格 ,page: true, url: '/SysMessages/Load', + where:{ + status:999 //全部消息 + }, cols: [[ //表头 { field: 'Title', title: '消息标题' } , { field: 'Content', title: '内容' } @@ -43,6 +46,7 @@ if (options != undefined) { $.extend(config, options); } + config.status = 999; //全部消息 table.reload('mainList', { url: '/SysMessages/Load', diff --git a/OpenAuth.Repository/Core/LongEntity.cs b/OpenAuth.Repository/Core/LongEntity.cs index bbc4ec22..26c09441 100644 --- a/OpenAuth.Repository/Core/LongEntity.cs +++ b/OpenAuth.Repository/Core/LongEntity.cs @@ -10,7 +10,7 @@ namespace OpenAuth.Repository.Core public class LongEntity :BaseEntity { [Browsable(false)] - public long Id { get; set; } + public decimal Id { get; set; } public override bool KeyIsNull() { return Id == 0; diff --git a/OpenAuth.Repository/OpenAuthDBContext.cs b/OpenAuth.Repository/OpenAuthDBContext.cs index f0968e0c..1569f051 100644 --- a/OpenAuth.Repository/OpenAuthDBContext.cs +++ b/OpenAuth.Repository/OpenAuthDBContext.cs @@ -21,14 +21,16 @@ namespace OpenAuth.Repository private ILoggerFactory _LoggerFactory; private IHttpContextAccessor _httpContextAccessor; private IConfiguration _configuration; + private IOptions _appConfiguration; public OpenAuthDBContext(DbContextOptions options, ILoggerFactory loggerFactory, - IHttpContextAccessor httpContextAccessor, IConfiguration configuration) + IHttpContextAccessor httpContextAccessor, IConfiguration configuration, IOptions appConfiguration) : base(options) { _LoggerFactory = loggerFactory; _httpContextAccessor = httpContextAccessor; _configuration = configuration; + _appConfiguration = appConfiguration; } protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) @@ -65,7 +67,7 @@ namespace OpenAuth.Repository } else { - optionsBuilder.UseOracle(connect); + optionsBuilder.UseOracle(connect,options =>options.UseOracleSQLCompatibility("11")); } } diff --git a/OpenAuth.WebApi/Controllers/RolesController.cs b/OpenAuth.WebApi/Controllers/RolesController.cs index a49d7e6c..332d4384 100644 --- a/OpenAuth.WebApi/Controllers/RolesController.cs +++ b/OpenAuth.WebApi/Controllers/RolesController.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Threading.Tasks; using Infrastructure; using Microsoft.AspNetCore.Mvc; using OpenAuth.App; @@ -86,9 +87,19 @@ namespace OpenAuth.WebApi.Controllers return result; } + + /// + /// 获取所有的角色 + /// 为了控制权限,通常只用于流程实例选择执行角色,其他地方请使用Load + /// + [HttpGet] + public async Task> LoadAll([FromQuery]QueryRoleListReq request) + { + return await _app.LoadAll(request); + } /// - /// 加载列表 + /// 获取登录用户可以访问的角色 /// [HttpGet] public Response> Load([FromQuery]QueryRoleListReq request) diff --git a/OpenAuth.WebApi/Controllers/UsersController.cs b/OpenAuth.WebApi/Controllers/UsersController.cs index 2774eac0..eeec363d 100644 --- a/OpenAuth.WebApi/Controllers/UsersController.cs +++ b/OpenAuth.WebApi/Controllers/UsersController.cs @@ -110,6 +110,16 @@ namespace OpenAuth.WebApi.Controllers { return await _app.Load(request); } + + /// + /// 获取所有的用户 + /// 为了控制权限,通常只用于流程实例选择执行角色,其他地方请使用Load + /// + [HttpGet] + public async Task> LoadAll([FromQuery]QueryUserListReq request) + { + return await _app.LoadAll(request); + } [HttpPost] public Response Delete([FromBody]string[] ids) diff --git a/mysql初始化脚本/mysql脚本.sql b/mysql初始化脚本/mysql脚本.sql index 9c64aa64..fa078596 100644 --- a/mysql初始化脚本/mysql脚本.sql +++ b/mysql初始化脚本/mysql脚本.sql @@ -1098,6 +1098,14 @@ CREATE TABLE `sysmessage` ( PRIMARY KEY (`Id`) USING BTREE ) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_bin COMMENT = '系统消息表' ROW_FORMAT = Compact; + +-- ---------------------------- +-- Records of sysmessage +-- ---------------------------- +INSERT INTO `sysmessage` VALUES ('2e34d7de-2203-42c8-80f7-7d60d7ad996b', '系统消息', 'SYS_MSG', '00000000-0000-0000-0000-000000000000', '00000000-0000-0000-0000-000000000000', '系统管理员', 'System', 0, 0, '', '', '你的流程[带分支条件/普通动态表单的模板2020-02-17 21:32:53]已被超级管理员处理。处理情况如下:【任务节点】【2021-06-13 12:02】同意,备注:同意处理', '2021-06-13 12:02:29', ''); +INSERT INTO `sysmessage` VALUES ('a0d898bd-ca62-46c8-90df-b73074e76500', '系统消息', 'SYS_MSG', '00000000-0000-0000-0000-000000000000', '00000000-0000-0000-0000-000000000000', '系统管理员', 'System', 0, 1, '', '', '你的流程[带有开发者自定义表单的流程2020-02-17 21:35:45]已被超级管理员处理。处理情况如下:【任意人可以审批】【2021-06-13 13:14】不同意,备注:不同意', '2021-06-13 13:14:39', ''); + + -- ---------------------------- -- Table structure for uploadfile -- ----------------------------