fix issue #I3YVBH 兼容oracle 11g

add load all users/roles for flowinstance
fix issue #I3W5YR
This commit is contained in:
yubaolee 2021-07-05 21:44:35 +08:00
parent b94fba7c19
commit 38a62595ba
15 changed files with 205 additions and 60 deletions

View File

@ -27,12 +27,12 @@ namespace OpenAuth.App
/// 按id批量删除
/// </summary>
/// <param name="ids"></param>
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);
}

View File

@ -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) //是否自增
{

View File

@ -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;
}
/// <summary>
/// 获取所有的角色
/// 为了控制权限通常只用于流程实例选择执行角色其他地方请使用Load
/// </summary>
public async Task<TableResp<Role>> LoadAll(QueryRoleListReq request)
{
var result = new TableResp<Role>();
var objs = UnitWork.Find<Role>(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;
}
/// <summary>
@ -80,5 +101,7 @@ namespace OpenAuth.App
{
_revelanceApp = app;
}
}
}

View File

@ -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();

View File

@ -39,16 +39,15 @@ namespace OpenAuth.App
public async Task<TableData> Load(QueryUserListReq request)
{
var loginUser = _auth.GetCurrentUser();
IQueryable<User> query = UnitWork.Find<User>(null);
if (!string.IsNullOrEmpty(request.key))
{
query = UnitWork.Find<User>(u => u.Name.Contains(request.key) || u.Account.Contains(request.key));
}
var userOrgs = from user in query
join relevance in UnitWork.Find<Relevance>(u =>u.Key=="UserOrg")
join relevance in UnitWork.Find<Relevance>(u => u.Key == "UserOrg")
on user.Id equals relevance.FirstId into temp
from r in temp.DefaultIfEmpty()
join org in UnitWork.Find<Org>(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),
};
}
/// <summary>
/// 获取所有的用户
/// 为了控制权限通常只用于流程实例选择执行角色其他地方请使用Load
/// </summary>
public async Task<TableResp<UserView>> LoadAll(QueryUserListReq request)
{
IQueryable<User> query = UnitWork.Find<User>(null);
if (!string.IsNullOrEmpty(request.key))
{
query = UnitWork.Find<User>(u => u.Name.Contains(request.key) || u.Account.Contains(request.key));
}
var userOrgs = from user in query
join relevance in UnitWork.Find<Relevance>(u => u.Key == "UserOrg")
on user.Id equals relevance.FirstId into temp
from r in temp.DefaultIfEmpty()
join org in UnitWork.Find<Org>(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<UserView>()
{
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
});
}
/// <summary>
/// 获取指定角色包含的用户列表
/// </summary>
@ -228,9 +294,9 @@ namespace OpenAuth.App
/// <returns></returns>
public async Task<TableData> LoadByOrg(QueryUserListByOrgReq request)
{
var users = from userRole in UnitWork.Find<Relevance>(u =>
var users = from userOrg in UnitWork.Find<Relevance>(u =>
u.SecondId == request.orgId && u.Key == Define.USERORG)
join user in UnitWork.Find<User>(null) on userRole.FirstId equals user.Id into temp
join user in UnitWork.Find<User>(null) on userOrg.FirstId equals user.Id into temp
from c in temp.Where(u =>u.Id != null)
select c;

View File

@ -88,7 +88,7 @@ namespace OpenAuth.IdentityServer
else //oracle
{
services.AddDbContext<OpenAuthDBContext>(options =>
options.UseOracle(Configuration.GetConnectionString("OpenAuthDBContext")));
options.UseOracle(Configuration.GetConnectionString("OpenAuthDBContext"), o=>o.UseOracleSQLCompatibility("11")));
}
}

View File

@ -1,7 +1,8 @@
@section header
{
<link rel="stylesheet" href="/css/main.css" media="all" />
<link rel="stylesheet" href="/css/main.css" media="all"/>
}
<div class="panel_box row">
<div class="panel col">
<a href="javascript:;" data-url="/orgmanager/index">
@ -79,7 +80,8 @@
<p>
<a href="https://gitee.com/yubaolee/OpenAuth.Core" target="_blank" class="layui-btn layui-btn-xs layui-btn-danger">项目地址</a>
<a class="layui-btn layui-btn-xs" target="_blank" href="http://doc.openauth.me">在线文档</a>
<a class="layui-btn layui-btn-xs layui-btn-danger" target="_blank" href="http://demo.openauth.me:1803">企业版入口</a>
<a class="layui-btn layui-btn-xs layui-btn-danger" target="_blank" href="http://demo.openauth.me:1803">企业版/高级版入口</a>
<a class="layui-btn layui-btn-xs layui-btn-danger" target="_blank" href="http://demo.openauth.me:1804">企业版H5入口请使用移动模式或者直接手机查看</a>
<span style="color: #f00;">注【本框架遵循LGPL开源协议企业单位如商用请联系作者授权谢谢】</span>
</p>
<p>技术交流QQ群484498493【已满】 &nbsp; &nbsp; 626433139【已满】 &nbsp;&nbsp; 566344079</p>
@ -87,14 +89,33 @@
<div class="row">
<div class="sysNotice col">
<blockquote class="layui-elem-quote title">更新日志</blockquote>
<div class="layui-elem-quote layui-quote-nm">
<div class="layui-elem-quote layui-quote-nm">
<h3># 3.2</h3>
<p>* 【新增】增加在swagger界面查看接口调用时间及SQL执行时间</p>
<p>
* 【新增】支持同时配置多个类型数据库的连接字符串:
详见:<a href="http://doc.openauth.me/core/multidbs.html" target="_blank" class="layui-btn layui-btn-xs layui-btn-danger">http://doc.openauth.me/core/multidbs.html</a>
</p>
<p>* 【新增】增加swagger接口分组</p>
<p>* 【新增】增加流程召回功能</p>
<p>* 【新增】增加运行时选定执行人、执行角色功能</p>
<p>* 【新增】增加Redis缓存支持</p>
<p>* 【新增】新增int类型数据库主键并支持雪花算法自动生成</p>
<p>* 【新增】新增附件管理,上传图片支持生成缩略图</p>
</div>
<div class="layui-elem-quote layui-quote-nm">
<h3># 2.0</h3>
<p>* 【新增】框架升级至.net core sdk 3.1.100</p>
<p>* 【新增】增加<a href="javascript:;" data-url="/usermanager/profile"><cite>个人中心</cite></a>页面,可修改个人信息及切换当前默认部门</p>
<p>* 【优化】升级layui至2.5.6</p>
<p>
* 【新增】增加
<a href="javascript:;" data-url="/usermanager/profile">
<cite>个人中心</cite>
</a>页面,可修改个人信息及切换当前默认部门
</p>
<p>* 【优化】升级layui至2.5.6</p>
<p>* 【优化】可以灵活配置用户可访问的机构数据权限</p>
</div>
<div class="layui-elem-quote layui-quote-nm">
</div>
<div class="layui-elem-quote layui-quote-nm">
<h3># 1.6</h3>
<p>* 【新增】日志及用户消息板块</p>
<p>* 【新增】企业版代码生成器,可以快速生成带有头/明细结构的页面</p>
@ -102,7 +123,7 @@
<p>* 【新增】完整的字段权限控制可以控制字段可见及API是否返回字段值</p>
<p>* 【优化】启用数据字典功能</p>
<p>* 【优化】优化导航排序、支持多级导航</p>
</div>
</div>
<div class="layui-elem-quote layui-quote-nm">
<h3># 1.5 - 2019.7</h3>
<p>* 【优化】升级layui至2.5.4</p>
@ -111,7 +132,7 @@
<p>* 【新增】集成IdentityServer4实现基于OAuth2的登录体系</p>
<p>* 【新增】建立三方对接规范,已有系统可以无缝对接流程引擎,请参考官方<a href="http://doc.openauth.me/thirdparty" target="_top">对接说明</a></p>
</div>
<div class="layui-elem-quote layui-quote-nm">
<h3># 1.4 - 2019.3</h3>
<p>* 【优化】升级layui至2.4.5</p>
@ -133,34 +154,34 @@
<col>
</colgroup>
<tbody>
<tr>
<td>当前版本</td>
<td class="version"></td>
</tr>
<tr>
<td>开发作者</td>
<td class="author"></td>
</tr>
<tr>
<td>网站首页</td>
<td class="homePage"></td>
</tr>
<tr>
<td>服务器环境</td>
<td class="server"></td>
</tr>
<tr>
<td>数据库版本</td>
<td class="dataBase"></td>
</tr>
<tr>
<td>最大上传限制</td>
<td class="maxUpload"></td>
</tr>
<tr>
<td>当前用户权限</td>
<td class="userRights"></td>
</tr>
<tr>
<td>当前版本</td>
<td class="version"></td>
</tr>
<tr>
<td>开发作者</td>
<td class="author"></td>
</tr>
<tr>
<td>网站首页</td>
<td class="homePage"></td>
</tr>
<tr>
<td>服务器环境</td>
<td class="server"></td>
</tr>
<tr>
<td>数据库版本</td>
<td class="dataBase"></td>
</tr>
<tr>
<td>最大上传限制</td>
<td class="maxUpload"></td>
</tr>
<tr>
<td>当前用户权限</td>
<td class="userRights"></td>
</tr>
</tbody>
</table>
@ -168,4 +189,4 @@
</div>
<script type="text/javascript" src="/layui/layui.js"></script>
<script type="text/javascript" src="/userJs/main.js?v=2.0.0"></script>
<script type="text/javascript" src="/userJs/main.js?v=3.2.0"></script>

View File

@ -28,6 +28,6 @@
</div>
<script type="text/javascript" src="/layui/layui.js"></script>
<script type="text/javascript" src="/userJs/sysmessages.js"></script>
<script type="text/javascript" src="/userJs/sysmessages.js?v=3.2.1"></script>

View File

@ -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"); //服务器环境

View File

@ -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',

View File

@ -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;

View File

@ -21,14 +21,16 @@ namespace OpenAuth.Repository
private ILoggerFactory _LoggerFactory;
private IHttpContextAccessor _httpContextAccessor;
private IConfiguration _configuration;
private IOptions<AppSetting> _appConfiguration;
public OpenAuthDBContext(DbContextOptions<OpenAuthDBContext> options, ILoggerFactory loggerFactory,
IHttpContextAccessor httpContextAccessor, IConfiguration configuration)
IHttpContextAccessor httpContextAccessor, IConfiguration configuration, IOptions<AppSetting> 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"));
}
}

View File

@ -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;
}
/// <summary>
/// 获取所有的角色
/// 为了控制权限通常只用于流程实例选择执行角色其他地方请使用Load
/// </summary>
[HttpGet]
public async Task<TableResp<Role>> LoadAll([FromQuery]QueryRoleListReq request)
{
return await _app.LoadAll(request);
}
/// <summary>
/// 加载列表
/// 获取登录用户可以访问的角色
/// </summary>
[HttpGet]
public Response<List<Role>> Load([FromQuery]QueryRoleListReq request)

View File

@ -110,6 +110,16 @@ namespace OpenAuth.WebApi.Controllers
{
return await _app.Load(request);
}
/// <summary>
/// 获取所有的用户
/// 为了控制权限通常只用于流程实例选择执行角色其他地方请使用Load
/// </summary>
[HttpGet]
public async Task<TableResp<UserView>> LoadAll([FromQuery]QueryUserListReq request)
{
return await _app.LoadAll(request);
}
[HttpPost]
public Response Delete([FromBody]string[] ids)

View File

@ -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
-- ----------------------------