mirror of
https://gitee.com/dotnetchina/OpenAuth.Net.git
synced 2026-06-27 14:53:08 +08:00
同步openauth.Core:
采用代码生成器的表结构控制前端显示,删除以前按照dbset获取数据库结构 优化注释 升级EF及所有三方的版本
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using OpenAuth.App.Interface;
|
||||
using OpenAuth.App.Request;
|
||||
using OpenAuth.Repository;
|
||||
@@ -39,7 +40,7 @@ namespace OpenAuth.App
|
||||
{
|
||||
var applications = UnitWork.Find<Application>(null);
|
||||
|
||||
return applications.ToList();
|
||||
return await applications.ToListAsync();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -63,17 +63,7 @@ namespace OpenAuth.App
|
||||
{
|
||||
get { return _strategy.Orgs; }
|
||||
}
|
||||
/// <summary>
|
||||
/// 获取角色可以访问的字段信息,只是单纯的获取数据库
|
||||
/// </summary>
|
||||
/// <param name="moduleCode"></param>
|
||||
/// <returns></returns>
|
||||
[Obsolete("请使用GetTableColumns代替")]
|
||||
public List<KeyDescription> GetProperties(string moduleCode)
|
||||
{
|
||||
return _strategy.GetProperties(moduleCode);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 获取角色可以访问的字段信息
|
||||
/// </summary>
|
||||
|
||||
@@ -117,29 +117,7 @@ namespace OpenAuth.App
|
||||
_userRoleIds = UnitWork.Find<Relevance>(u => u.FirstId == _user.Id && u.Key == Define.USERROLE).Select(u => u.SecondId).ToList();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取用户可访问的字段列表
|
||||
/// </summary>
|
||||
/// <param name="moduleCode">模块的code</param>
|
||||
/// <returns></returns>
|
||||
public List<KeyDescription> GetProperties(string moduleCode)
|
||||
{
|
||||
var allprops = _dbExtension.GetProperties(moduleCode);
|
||||
|
||||
//如果是系统模块,直接返回所有字段。防止开发者把模块配置成系统模块,还在外层调用loginContext.GetProperties("xxxx");
|
||||
bool? isSysModule = UnitWork.FirstOrDefault<Module>(u => u.Code == moduleCode)?.IsSys;
|
||||
if (isSysModule!= null && isSysModule.Value)
|
||||
{
|
||||
return allprops;
|
||||
}
|
||||
|
||||
var props =UnitWork.Find<Relevance>(u =>
|
||||
u.Key == Define.ROLEDATAPROPERTY && _userRoleIds.Contains(u.FirstId) && u.SecondId == moduleCode)
|
||||
.Select(u => u.ThirdId);
|
||||
|
||||
return allprops.Where(u => props.Contains(u.Key)).ToList();
|
||||
}
|
||||
|
||||
|
||||
public List<BuilderTableColumn> GetTableColumns(string moduleCode)
|
||||
{
|
||||
|
||||
@@ -91,11 +91,7 @@ namespace OpenAuth.App
|
||||
throw new Exception("超级管理员,禁止设置用户");
|
||||
}
|
||||
}
|
||||
|
||||
public List<KeyDescription> GetProperties(string moduleCode)
|
||||
{
|
||||
return _dbExtension.GetProperties(moduleCode);
|
||||
}
|
||||
|
||||
|
||||
public List<BuilderTableColumn> GetTableColumns(string moduleCode)
|
||||
{
|
||||
|
||||
@@ -34,7 +34,7 @@ namespace OpenAuth.App
|
||||
/// <summary>
|
||||
/// 获取当前登录用户的数据访问权限
|
||||
/// </summary>
|
||||
/// <param name=""parameterName>linq表达式参数的名称,如u=>u.name中的"u"</param>
|
||||
/// <param name="parametername">linq表达式参数的名称,如u=>u.name中的"u"</param>
|
||||
/// <returns></returns>
|
||||
protected IQueryable<T> GetDataPrivilege(string parametername)
|
||||
{
|
||||
|
||||
@@ -15,6 +15,7 @@ namespace OpenAuth.App
|
||||
/// 业务层基类,UnitWork用于事务操作,Repository用于普通的数据库操作
|
||||
/// </summary>
|
||||
/// <typeparam name="T"></typeparam>
|
||||
/// <typeparam name="TDbContext"></typeparam>
|
||||
public class BaseIntAutoGenApp<T, TDbContext> :BaseApp<T,TDbContext> where T : IntAutoGenEntity where TDbContext: DbContext
|
||||
{
|
||||
public BaseIntAutoGenApp(IUnitWork<TDbContext> unitWork, IRepository<T,TDbContext> repository, IAuth auth) : base(unitWork, repository, auth)
|
||||
|
||||
@@ -14,6 +14,7 @@ namespace OpenAuth.App
|
||||
/// 业务层基类,UnitWork用于事务操作,Repository用于普通的数据库操作
|
||||
/// </summary>
|
||||
/// <typeparam name="T"></typeparam>
|
||||
/// <typeparam name="TDbContext"></typeparam>
|
||||
public class BaseLongApp<T, TDbContext> :BaseApp<T,TDbContext> where T : LongEntity where TDbContext: DbContext
|
||||
{
|
||||
|
||||
|
||||
@@ -11,9 +11,10 @@ namespace OpenAuth.App
|
||||
{
|
||||
/// <summary>
|
||||
/// 业务层基类,UnitWork用于事务操作,Repository用于普通的数据库操作
|
||||
/// <para>如用户管理:Class UserManagerApp:BaseApp<User></para>
|
||||
/// <para>如用户管理:Class UserManagerApp:BaseApp<User></para>
|
||||
/// </summary>
|
||||
/// <typeparam name="T"></typeparam>
|
||||
/// <typeparam name="TDbContext"></typeparam>
|
||||
public class BaseStringApp<T, TDbContext> :BaseApp<T,TDbContext> where T : StringEntity where TDbContext: DbContext
|
||||
{
|
||||
|
||||
|
||||
@@ -10,6 +10,7 @@ namespace OpenAuth.App
|
||||
/// 树状结构处理
|
||||
/// </summary>
|
||||
/// <typeparam name="T"></typeparam>
|
||||
/// /// <typeparam name="TDbContext"></typeparam>
|
||||
public class BaseTreeApp<T,TDbContext> :BaseStringApp<T,TDbContext> where T : TreeEntity where TDbContext :DbContext
|
||||
{
|
||||
|
||||
|
||||
@@ -11,6 +11,7 @@ using Infrastructure;
|
||||
using Infrastructure.Extensions;
|
||||
using Infrastructure.Helpers;
|
||||
using Infrastructure.Utilities;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.DependencyModel;
|
||||
using Microsoft.Extensions.Options;
|
||||
using OpenAuth.App.Interface;
|
||||
@@ -29,8 +30,7 @@ namespace OpenAuth.App
|
||||
private BuilderTableColumnApp _builderTableColumnApp;
|
||||
private CategoryApp _categoryApp;
|
||||
private DbExtension _dbExtension;
|
||||
private string _webProject = null;
|
||||
private string _apiNameSpace = null;
|
||||
private string _webProject = string.Empty;
|
||||
private string _startName = "";
|
||||
private IOptions<AppSetting> _appConfiguration;
|
||||
|
||||
@@ -61,12 +61,12 @@ namespace OpenAuth.App
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_webProject != null)
|
||||
if (string.IsNullOrEmpty(_webProject))
|
||||
return _webProject;
|
||||
_webProject = ProjectPath.GetLastIndexOfDirectoryName(".WebApi") ??
|
||||
ProjectPath.GetLastIndexOfDirectoryName("Api") ??
|
||||
ProjectPath.GetLastIndexOfDirectoryName(".Mvc");
|
||||
if (_webProject == null)
|
||||
if (string.IsNullOrEmpty(_webProject))
|
||||
{
|
||||
throw new Exception("未获取到以.WebApi结尾的项目名称,无法创建页面");
|
||||
}
|
||||
@@ -93,10 +93,10 @@ namespace OpenAuth.App
|
||||
objs = objs.Where(u => u.Id.Contains(request.key));
|
||||
}
|
||||
|
||||
result.data = objs.OrderBy(u => u.Id)
|
||||
result.data =await objs.OrderBy(u => u.Id)
|
||||
.Skip((request.page - 1) * request.limit)
|
||||
.Take(request.limit).ToList();
|
||||
result.count = objs.Count();
|
||||
.Take(request.limit).ToListAsync();
|
||||
result.count =await objs.CountAsync();
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -764,8 +764,8 @@ namespace OpenAuth.App
|
||||
Name = u.TableName
|
||||
});
|
||||
|
||||
result.data = objs.OrderBy(u => u.Id).ToList();
|
||||
result.count = objs.Count();
|
||||
result.data =await objs.OrderBy(u => u.Id).ToListAsync();
|
||||
result.count =await objs.CountAsync();
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using OpenAuth.App.Interface;
|
||||
using OpenAuth.App.Request;
|
||||
using OpenAuth.App.Response;
|
||||
@@ -36,10 +37,10 @@ namespace OpenAuth.App
|
||||
objs = objs.Where(u => u.ColumnName.Contains(request.key));
|
||||
}
|
||||
|
||||
result.data = objs.OrderBy(u => u.ColumnName)
|
||||
result.data =await objs.OrderBy(u => u.ColumnName)
|
||||
.Skip((request.page - 1) * request.limit)
|
||||
.Take(request.limit).ToList();
|
||||
result.count = objs.Count();
|
||||
.Take(request.limit).ToListAsync();
|
||||
result.count =await objs.CountAsync();
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using OpenAuth.App.Interface;
|
||||
using OpenAuth.App.Request;
|
||||
using OpenAuth.App.Response;
|
||||
@@ -25,12 +26,11 @@ namespace OpenAuth.App
|
||||
{
|
||||
throw new CommonException("登录已过期", Define.INVALID_TOKEN);
|
||||
}
|
||||
|
||||
var properties = loginContext.GetProperties("Category");
|
||||
|
||||
if (properties == null || properties.Count == 0)
|
||||
|
||||
var columnFields = loginContext.GetTableColumns("Category");
|
||||
if (columnFields == null || columnFields.Count == 0)
|
||||
{
|
||||
throw new Exception("当前登录用户没有访问该模块字段的权限,请联系管理员配置");
|
||||
throw new Exception("请在代码生成界面配置Category表的字段属性");
|
||||
}
|
||||
|
||||
var result = new TableData();
|
||||
@@ -45,12 +45,12 @@ namespace OpenAuth.App
|
||||
objs = objs.Where(u => u.Id.Contains(request.key) || u.Name.Contains(request.key));
|
||||
}
|
||||
|
||||
var propertyStr = string.Join(',', properties.Select(u =>u.Key));
|
||||
result.columnHeaders = properties;
|
||||
var propertyStr = string.Join(',', columnFields.Select(u =>u.ColumnName));
|
||||
result.columnFields = columnFields;
|
||||
result.data = objs.OrderBy(u => u.DtCode)
|
||||
.Skip((request.page - 1) * request.limit)
|
||||
.Take(request.limit).Select($"new ({propertyStr})");
|
||||
result.count = objs.Count();
|
||||
result.count = await objs.CountAsync();
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using OpenAuth.App.Interface;
|
||||
using OpenAuth.App.Request;
|
||||
using OpenAuth.App.Response;
|
||||
@@ -29,10 +30,10 @@ namespace OpenAuth.App
|
||||
objs = objs.Where(u => u.Id.Contains(request.key) || u.Name.Contains(request.key));
|
||||
}
|
||||
|
||||
result.data = objs.OrderBy(u => u.Name)
|
||||
result.data =await objs.OrderBy(u => u.Name)
|
||||
.Skip((request.page - 1) * request.limit)
|
||||
.Take(request.limit);
|
||||
result.count = objs.Count();
|
||||
.Take(request.limit).ToListAsync();
|
||||
result.count =await objs.CountAsync();
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@ using System;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using OpenAuth.App.Interface;
|
||||
using OpenAuth.App.Request;
|
||||
using OpenAuth.App.Response;
|
||||
@@ -25,15 +26,13 @@ namespace OpenAuth.App
|
||||
{
|
||||
throw new CommonException("登录已过期", Define.INVALID_TOKEN);
|
||||
}
|
||||
|
||||
var properties = loginContext.GetProperties("DataPrivilegeRule");
|
||||
|
||||
if (properties == null || properties.Count == 0)
|
||||
|
||||
var columnFields = loginContext.GetTableColumns("DataPrivilegeRule");
|
||||
if (columnFields == null || columnFields.Count == 0)
|
||||
{
|
||||
throw new Exception("当前登录用户没有访问该模块字段的权限,请联系管理员配置");
|
||||
throw new Exception("请在代码生成界面配置DataPrivilegeRule表的字段属性");
|
||||
}
|
||||
|
||||
|
||||
var result = new TableData();
|
||||
var objs = UnitWork.Find<DataPrivilegeRule>(null);
|
||||
if (!string.IsNullOrEmpty(request.key))
|
||||
@@ -41,13 +40,12 @@ namespace OpenAuth.App
|
||||
objs = objs.Where(u => u.Id.Contains(request.key) || u.SourceCode.Contains(request.key) || u.Description.Contains(request.key));
|
||||
}
|
||||
|
||||
|
||||
var propertyStr = string.Join(',', properties.Select(u => u.Key));
|
||||
result.columnHeaders = properties;
|
||||
var propertyStr = string.Join(',', columnFields.Select(u => u.ColumnName));
|
||||
result.columnFields = columnFields;
|
||||
result.data = objs.OrderBy(u => u.Id)
|
||||
.Skip((request.page - 1) * request.limit)
|
||||
.Take(request.limit).Select($"new ({propertyStr})");
|
||||
result.count = objs.Count();
|
||||
result.count = await objs.CountAsync();
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
@@ -173,7 +173,7 @@ select utc.column_name as COLUMNNAME,
|
||||
|
||||
foreach (var context in _contexts)
|
||||
{
|
||||
var columns = context.Query<SysTableColumn>().FromSqlRaw(sql);
|
||||
var columns = context.Set<SysTableColumn>().FromSqlRaw(sql);
|
||||
var columnList = columns?.ToList();
|
||||
if (columnList != null && columnList.Any())
|
||||
{
|
||||
@@ -238,7 +238,7 @@ select utc.column_name as COLUMNNAME,
|
||||
|
||||
foreach (var context in _contexts)
|
||||
{
|
||||
var columns = context.Query<SysTableColumn>().FromSqlRaw(sql);
|
||||
var columns = context.Set<SysTableColumn>().FromSqlRaw(sql);
|
||||
var columnList = columns?.ToList();
|
||||
if (columnList != null && columnList.Any())
|
||||
{
|
||||
@@ -344,7 +344,7 @@ select utc.column_name as COLUMNNAME,
|
||||
|
||||
foreach (var context in _contexts)
|
||||
{
|
||||
var columns = context.Query<SysTableColumn>().FromSqlRaw(sql);
|
||||
var columns = context.Set<SysTableColumn>().FromSqlRaw(sql);
|
||||
var columnList = columns?.ToList();
|
||||
if (columnList != null && columnList.Any())
|
||||
{
|
||||
|
||||
@@ -7,6 +7,7 @@ using Infrastructure;
|
||||
using Infrastructure.Extensions;
|
||||
using Infrastructure.Helpers;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Microsoft.Extensions.Options;
|
||||
using OpenAuth.App.Interface;
|
||||
@@ -52,10 +53,10 @@ namespace OpenAuth.App
|
||||
objs = objs.Where(u => u.FileName.Contains(request.key) || u.FilePath.Contains(request.key));
|
||||
}
|
||||
|
||||
result.data = objs.OrderByDescending(u => u.CreateTime)
|
||||
result.data =await objs.OrderByDescending(u => u.CreateTime)
|
||||
.Skip((request.page - 1) * request.limit)
|
||||
.Take(request.limit);
|
||||
result.count = objs.Count();
|
||||
.Take(request.limit).ToListAsync();
|
||||
result.count =await objs.CountAsync();
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
@@ -27,6 +27,7 @@ using System.Net.Http;
|
||||
using System.Threading.Tasks;
|
||||
using Infrastructure.Const;
|
||||
using Infrastructure.Helpers;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using OpenAuth.Repository;
|
||||
|
||||
namespace OpenAuth.App
|
||||
@@ -632,9 +633,9 @@ namespace OpenAuth.App
|
||||
waitExp = waitExp.And(t => t.CustomName.Contains(request.key));
|
||||
}
|
||||
|
||||
result.count = UnitWork.Find(waitExp).Count();
|
||||
result.count = await UnitWork.Find(waitExp).CountAsync();
|
||||
|
||||
result.data = UnitWork.Find(request.page, request.limit, "CreateDate descending", waitExp).ToList();
|
||||
result.data =await UnitWork.Find(request.page, request.limit, "CreateDate descending", waitExp).ToListAsync();
|
||||
}
|
||||
else if (request.type == "disposed") //已办事项(即我参与过的流程)
|
||||
{
|
||||
@@ -650,10 +651,10 @@ namespace OpenAuth.App
|
||||
query = query.Where(t => t.CustomName.Contains(request.key));
|
||||
}
|
||||
|
||||
result.data = query.OrderByDescending(u => u.CreateDate)
|
||||
result.data = await query.OrderByDescending(u => u.CreateDate)
|
||||
.Skip((request.page - 1) * request.limit)
|
||||
.Take(request.limit).ToList();
|
||||
result.count = instances.Count();
|
||||
.Take(request.limit).ToListAsync();
|
||||
result.count =await instances.CountAsync();
|
||||
}
|
||||
else //我的流程
|
||||
{
|
||||
@@ -665,9 +666,9 @@ namespace OpenAuth.App
|
||||
myFlowExp = myFlowExp.And(t => t.CustomName.Contains(request.key));
|
||||
}
|
||||
|
||||
result.count = UnitWork.Find(myFlowExp).Count();
|
||||
result.data = UnitWork.Find(request.page, request.limit,
|
||||
"CreateDate descending", myFlowExp).ToList();
|
||||
result.count =await UnitWork.Find(myFlowExp).CountAsync();
|
||||
result.data = await UnitWork.Find(request.page, request.limit,
|
||||
"CreateDate descending", myFlowExp).ToListAsync();
|
||||
}
|
||||
|
||||
return result;
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using OpenAuth.App.Interface;
|
||||
using OpenAuth.App.Request;
|
||||
using OpenAuth.App.Response;
|
||||
@@ -59,10 +60,10 @@ namespace OpenAuth.App
|
||||
objs = objs.Where(u => u.SchemeName.Contains(request.key) || u.Id.Contains(request.key));
|
||||
}
|
||||
|
||||
result.data = objs.OrderByDescending(u => u.CreateDate)
|
||||
result.data = await objs.OrderByDescending(u => u.CreateDate)
|
||||
.Skip((request.page - 1) * request.limit)
|
||||
.Take(request.limit).ToList();
|
||||
result.count = objs.Count();
|
||||
.Take(request.limit).ToListAsync();
|
||||
result.count = await objs.CountAsync();
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@ using System.Threading.Tasks;
|
||||
using Infrastructure;
|
||||
using Infrastructure.Utilities;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Options;
|
||||
using OpenAuth.App.Interface;
|
||||
using OpenAuth.App.Request;
|
||||
@@ -17,7 +18,6 @@ namespace OpenAuth.App
|
||||
{
|
||||
public class FormApp : BaseStringApp<Form,OpenAuthDBContext>
|
||||
{
|
||||
private IAuth _auth;
|
||||
private IOptions<AppSetting> _appConfiguration;
|
||||
private IHttpContextAccessor _httpContextAccessor;
|
||||
/// <summary>
|
||||
@@ -35,7 +35,7 @@ namespace OpenAuth.App
|
||||
result.data = forms.OrderByDescending(u => u.CreateDate)
|
||||
.Skip((request.page - 1) * request.limit)
|
||||
.Take(request.limit).ToList();
|
||||
result.count = forms.Count();
|
||||
result.count = await forms.CountAsync();
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using System.Threading.Tasks;
|
||||
using Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using OpenAuth.App.Interface;
|
||||
using OpenAuth.App.Request;
|
||||
using OpenAuth.App.Response;
|
||||
@@ -21,8 +22,8 @@ namespace OpenAuth.App
|
||||
{
|
||||
return new TableData
|
||||
{
|
||||
count = Repository.Count(null),
|
||||
data = Repository.Find(request.page, request.limit, "Id desc")
|
||||
count = await Repository.CountAsync(null),
|
||||
data = await Repository.Find(request.page, request.limit, "Id desc").ToListAsync()
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -39,15 +39,7 @@ namespace OpenAuth.App
|
||||
{
|
||||
get;set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 根据模块id获取可访问的模块字段
|
||||
/// </summary>
|
||||
/// <param name="moduleCode"></param>
|
||||
/// <returns></returns>
|
||||
[Obsolete("请使用GetTableColumns代替")]
|
||||
List<KeyDescription> GetProperties(string moduleCode);
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 获取角色可以访问的字段信息
|
||||
/// </summary>
|
||||
|
||||
@@ -4,6 +4,7 @@ using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Infrastructure;
|
||||
using Infrastructure.Const;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using OpenAuth.App.Extensions;
|
||||
using OpenAuth.App.Interface;
|
||||
@@ -39,10 +40,10 @@ namespace OpenAuth.App
|
||||
objs = objs.Where(u => u.Id.Contains(request.key));
|
||||
}
|
||||
|
||||
result.data = objs.OrderBy(u => u.Id)
|
||||
result.data =await objs.OrderBy(u => u.Id)
|
||||
.Skip((request.page - 1) * request.limit)
|
||||
.Take(request.limit);
|
||||
result.count = objs.Count();
|
||||
.Take(request.limit).ToListAsync();
|
||||
result.count =await objs.CountAsync();
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -53,13 +54,12 @@ namespace OpenAuth.App
|
||||
/// <returns></returns>
|
||||
public async Task StartAll()
|
||||
{
|
||||
var jobs = Repository.Find(u => u.Status == (int) JobStatus.Running);
|
||||
var jobs = await Repository.Find(u => u.Status == (int) JobStatus.Running).ToListAsync();
|
||||
foreach (var job in jobs)
|
||||
{
|
||||
job.Start(_scheduler);
|
||||
}
|
||||
_logger.LogInformation("所有状态为正在运行的任务已启动");
|
||||
|
||||
}
|
||||
|
||||
public void Add(AddOrUpdateOpenJobReq req)
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
|
||||
<DocumentationFile>bin\Debug\net5.0\OpenAuth.App.xml</DocumentationFile>
|
||||
<NoWarn>1701;1702;1591;1573;1572;1570</NoWarn>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
@@ -15,15 +16,15 @@
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Autofac" Version="5.1.2" />
|
||||
<PackageReference Include="Autofac" Version="5.2.0" />
|
||||
<PackageReference Include="Autofac.Extensions.DependencyInjection" Version="6.0.0" />
|
||||
<PackageReference Include="Autofac.Extras.Quartz" Version="5.1.0" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="3.1.2" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Authentication.OpenIdConnect" Version="3.1.2" />
|
||||
<PackageReference Include="Microsoft.Extensions.DependencyModel" Version="2.0.4" />
|
||||
<PackageReference Include="Microsoft.Extensions.Http" Version="3.1.2" />
|
||||
<PackageReference Include="Microsoft.Extensions.DependencyModel" Version="5.0.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Http" Version="5.0.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Logging.Log4Net.AspNetCore" Version="3.1.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Options.ConfigurationExtensions" Version="3.1.2" />
|
||||
<PackageReference Include="Microsoft.Extensions.Options.ConfigurationExtensions" Version="5.0.0" />
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.5.0" />
|
||||
<PackageReference Include="Moq" Version="4.13.1" />
|
||||
<PackageReference Include="NUnit" Version="3.13.1" />
|
||||
|
||||
@@ -3,6 +3,7 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using OpenAuth.App.Interface;
|
||||
using OpenAuth.App.Request;
|
||||
using OpenAuth.App.Response;
|
||||
@@ -90,7 +91,7 @@ namespace OpenAuth.App
|
||||
result.data = resources.OrderBy(u => u.TypeId)
|
||||
.Skip((request.page - 1) * request.limit)
|
||||
.Take(request.limit).Select($"new ({propertyStr})");
|
||||
result.count = resources.Count();
|
||||
result.count = await resources.CountAsync();
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@ using OpenAuth.Repository.Interface;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using OpenAuth.App.Request;
|
||||
using OpenAuth.Repository;
|
||||
|
||||
@@ -44,10 +45,10 @@ namespace OpenAuth.App
|
||||
objs = objs.Where(u => u.Name.Contains(request.key));
|
||||
}
|
||||
|
||||
result.data = objs.OrderBy(u => u.Name)
|
||||
result.data = await objs.OrderBy(u => u.Name)
|
||||
.Skip((request.page - 1) * request.limit)
|
||||
.Take(request.limit).ToList();
|
||||
result.count = objs.Count();
|
||||
.Take(request.limit).ToListAsync();
|
||||
result.count = await objs.CountAsync();
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -79,6 +80,21 @@ namespace OpenAuth.App
|
||||
});
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 删除角色时,需要删除角色对应的权限
|
||||
/// </summary>
|
||||
/// <param name="ids"></param>
|
||||
public override void Delete(string[] ids)
|
||||
{
|
||||
UnitWork.ExecuteWithTransaction(() =>
|
||||
{
|
||||
UnitWork.Delete<Relevance>(u=>(u.Key == Define.ROLEMODULE || u.Key == Define.ROLEELEMENT) && ids.Contains(u.FirstId));
|
||||
UnitWork.Delete<Relevance>(u=>u.Key == Define.USERROLE && ids.Contains(u.SecondId));
|
||||
UnitWork.Delete<Role>(u =>ids.Contains(u.Id));
|
||||
UnitWork.Save();
|
||||
});
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 更新角色属性
|
||||
/// </summary>
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using OpenAuth.App.Request;
|
||||
using OpenAuth.App.Response;
|
||||
using OpenAuth.Repository;
|
||||
@@ -25,10 +26,10 @@ namespace OpenAuth.App
|
||||
objs = objs.Where(u => u.Content.Contains(request.key) || u.Id.Contains(request.key));
|
||||
}
|
||||
|
||||
result.data = objs.OrderByDescending(u => u.CreateTime)
|
||||
result.data = await objs.OrderByDescending(u => u.CreateTime)
|
||||
.Skip((request.page - 1) * request.limit)
|
||||
.Take(request.limit);
|
||||
result.count = objs.Count();
|
||||
.Take(request.limit).ToListAsync();
|
||||
result.count = await objs.CountAsync();
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using OpenAuth.App.Interface;
|
||||
using OpenAuth.App.Request;
|
||||
@@ -43,10 +44,10 @@ namespace OpenAuth.App
|
||||
objs = objs.Where(u => u.ToStatus == request.Status);
|
||||
}
|
||||
|
||||
result.data = objs.OrderByDescending(u => u.CreateTime)
|
||||
result.data =await objs.OrderByDescending(u => u.CreateTime)
|
||||
.Skip((request.page - 1) * request.limit)
|
||||
.Take(request.limit);
|
||||
result.count = objs.Count();
|
||||
.Take(request.limit).ToListAsync();
|
||||
result.count = await objs.CountAsync();
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@ using System.Threading.Tasks;
|
||||
using Castle.Core.Internal;
|
||||
using Infrastructure;
|
||||
using Infrastructure.Extensions;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using OpenAuth.App.Interface;
|
||||
using OpenAuth.App.Request;
|
||||
using OpenAuth.App.Response;
|
||||
@@ -108,8 +109,8 @@ namespace OpenAuth.App
|
||||
|
||||
return new TableData
|
||||
{
|
||||
count = userViews.Count(),
|
||||
data = userViews.OrderBy(u => u.Name)
|
||||
count =userViews.Count(),
|
||||
data =userViews.OrderBy(u => u.Name)
|
||||
.Skip((request.page - 1) * request.limit)
|
||||
.Take(request.limit),
|
||||
};
|
||||
@@ -282,8 +283,8 @@ namespace OpenAuth.App
|
||||
|
||||
return new TableData
|
||||
{
|
||||
count = users.Count(),
|
||||
data = users.Skip((request.page - 1) * request.limit).Take(request.limit)
|
||||
count =await users.CountAsync(),
|
||||
data =await users.Skip((request.page - 1) * request.limit).Take(request.limit).ToListAsync()
|
||||
};
|
||||
}
|
||||
|
||||
@@ -302,8 +303,8 @@ namespace OpenAuth.App
|
||||
|
||||
return new TableData
|
||||
{
|
||||
count = users.Count(),
|
||||
data = users.Skip((request.page - 1) * request.limit).Take(request.limit)
|
||||
count =await users.CountAsync(),
|
||||
data =await users.Skip((request.page - 1) * request.limit).Take(request.limit).ToListAsync()
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using OpenAuth.App.Interface;
|
||||
using OpenAuth.App.Request;
|
||||
using OpenAuth.App.Response;
|
||||
@@ -51,7 +52,7 @@ namespace OpenAuth.App
|
||||
result.data = objs.OrderBy(u => u.Id)
|
||||
.Skip((request.page - 1) * request.limit)
|
||||
.Take(request.limit).Select($"new ({propertyStr})");
|
||||
result.count = objs.Count();
|
||||
result.count = await objs.CountAsync();
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using OpenAuth.App.Interface;
|
||||
using OpenAuth.App.Request;
|
||||
using OpenAuth.App.Response;
|
||||
@@ -48,7 +49,7 @@ namespace OpenAuth.App
|
||||
result.data = objs.OrderBy(u => u.Id)
|
||||
.Skip((request.page - 1) * request.limit)
|
||||
.Take(request.limit).Select($"new ({propertyStr})");
|
||||
result.count = objs.Count();
|
||||
result.count = await objs.CountAsync();
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user