mirror of
https://gitee.com/dotnetchina/OpenAuth.Net.git
synced 2025-08-23 22:11:35 +08:00
同步OpenAuth.Core最新代码
This commit is contained in:
parent
7ce8a219cf
commit
7217e7a924
296
.gitignore
vendored
296
.gitignore
vendored
@ -1,36 +1,264 @@
|
||||
################################################################################
|
||||
# 此 .gitignore 文件已由 Microsoft(R) Visual Studio 自动创建。
|
||||
################################################################################
|
||||
## Ignore Visual Studio temporary files, build results, and
|
||||
## files generated by popular Visual Studio add-ons.
|
||||
|
||||
/OpenAuth.Mvc/bin
|
||||
/OpenAuth.Repository/bin/Debug
|
||||
/OpenAuth.Repository/obj/Debug
|
||||
/OpenAuth.UnitTest/bin/Debug
|
||||
/OpenAuth.UnitTest/obj/Debug
|
||||
/OpenAuth.WebApi/bin
|
||||
/OpenAuth.WebTest/bin
|
||||
/OpenAuth.WebTest/obj/Debug
|
||||
/packages
|
||||
/OpenAuth.WebApi/obj/Debug
|
||||
/OpenAuth.Mvc/log
|
||||
/OpenAuth.Mvc/obj/Debug
|
||||
# User-specific files
|
||||
*.suo
|
||||
*.user
|
||||
/OpenAuth.Domain/obj/Debug
|
||||
/OpenAuth.App/obj/Debug
|
||||
/OpenAuth.Domain/bin/Debug
|
||||
/OpenAuth.App/bin
|
||||
/Infrastructure/bin/Debug
|
||||
/Infrastructure/obj/Debug
|
||||
/.vs
|
||||
/OpenAuth.sln.GhostDoc.xml
|
||||
/类结构.mdj
|
||||
/数据库设计关系图/OpenAuthDB.pdb
|
||||
/OpenAuth.WebTest/obj/Release
|
||||
/OpenAuth.UnitTest/obj/Release
|
||||
/OpenAuth.WebApi/obj/Release
|
||||
/OpenAuth.Repository/bin/Release
|
||||
/OpenAuth.Repository/obj/Release
|
||||
/OpenAuth.Mvc/obj/Release
|
||||
/OpenAuth.App/obj/Release
|
||||
/Infrastructure/bin/Release
|
||||
/Infrastructure/obj/Release
|
||||
*.userosscache
|
||||
*.sln.docstates
|
||||
|
||||
# User-specific files (MonoDevelop/Xamarin Studio)
|
||||
*.userprefs
|
||||
|
||||
# Build results
|
||||
[Dd]ebug/
|
||||
[Dd]ebugPublic/
|
||||
[Rr]elease/
|
||||
[Rr]eleases/
|
||||
x64/
|
||||
x86/
|
||||
bld/
|
||||
[Bb]in/
|
||||
[Oo]bj/
|
||||
[Ll]og/
|
||||
|
||||
# Visual Studio 2015 cache/options directory
|
||||
.vs/
|
||||
# Uncomment if you have tasks that create the project's static files in wwwroot
|
||||
#wwwroot/
|
||||
|
||||
# MSTest test Results
|
||||
[Tt]est[Rr]esult*/
|
||||
[Bb]uild[Ll]og.*
|
||||
|
||||
# NUNIT
|
||||
*.VisualState.xml
|
||||
TestResult.xml
|
||||
|
||||
# Build Results of an ATL Project
|
||||
[Dd]ebugPS/
|
||||
[Rr]eleasePS/
|
||||
dlldata.c
|
||||
|
||||
# DNX
|
||||
project.lock.json
|
||||
project.fragment.lock.json
|
||||
artifacts/
|
||||
|
||||
*_i.c
|
||||
*_p.c
|
||||
*_i.h
|
||||
*.ilk
|
||||
*.meta
|
||||
*.obj
|
||||
*.pch
|
||||
*.pdb
|
||||
*.pgc
|
||||
*.pgd
|
||||
*.rsp
|
||||
*.sbr
|
||||
*.tlb
|
||||
*.tli
|
||||
*.tlh
|
||||
*.tmp
|
||||
*.tmp_proj
|
||||
*.log
|
||||
*.vspscc
|
||||
*.vssscc
|
||||
.builds
|
||||
*.pidb
|
||||
*.svclog
|
||||
*.scc
|
||||
|
||||
# Chutzpah Test files
|
||||
_Chutzpah*
|
||||
|
||||
# Visual C++ cache files
|
||||
ipch/
|
||||
*.aps
|
||||
*.ncb
|
||||
*.opendb
|
||||
*.opensdf
|
||||
*.sdf
|
||||
*.cachefile
|
||||
*.VC.db
|
||||
*.VC.VC.opendb
|
||||
|
||||
# Visual Studio profiler
|
||||
*.psess
|
||||
*.vsp
|
||||
*.vspx
|
||||
*.sap
|
||||
|
||||
# TFS 2012 Local Workspace
|
||||
$tf/
|
||||
|
||||
# Guidance Automation Toolkit
|
||||
*.gpState
|
||||
|
||||
# ReSharper is a .NET coding add-in
|
||||
_ReSharper*/
|
||||
*.[Rr]e[Ss]harper
|
||||
*.DotSettings.user
|
||||
|
||||
# JustCode is a .NET coding add-in
|
||||
.JustCode
|
||||
|
||||
# TeamCity is a build add-in
|
||||
_TeamCity*
|
||||
|
||||
# DotCover is a Code Coverage Tool
|
||||
*.dotCover
|
||||
|
||||
# NCrunch
|
||||
_NCrunch_*
|
||||
.*crunch*.local.xml
|
||||
nCrunchTemp_*
|
||||
|
||||
# MightyMoose
|
||||
*.mm.*
|
||||
AutoTest.Net/
|
||||
|
||||
# Web workbench (sass)
|
||||
.sass-cache/
|
||||
|
||||
# Installshield output folder
|
||||
[Ee]xpress/
|
||||
|
||||
# DocProject is a documentation generator add-in
|
||||
DocProject/buildhelp/
|
||||
DocProject/Help/*.HxT
|
||||
DocProject/Help/*.HxC
|
||||
DocProject/Help/*.hhc
|
||||
DocProject/Help/*.hhk
|
||||
DocProject/Help/*.hhp
|
||||
DocProject/Help/Html2
|
||||
DocProject/Help/html
|
||||
|
||||
# Click-Once directory
|
||||
publish/
|
||||
|
||||
# Publish Web Output
|
||||
*.[Pp]ublish.xml
|
||||
*.azurePubxml
|
||||
# TODO: Comment the next line if you want to checkin your web deploy settings
|
||||
# but database connection strings (with potential passwords) will be unencrypted
|
||||
#*.pubxml
|
||||
*.publishproj
|
||||
|
||||
# Microsoft Azure Web App publish settings. Comment the next line if you want to
|
||||
# checkin your Azure Web App publish settings, but sensitive information contained
|
||||
# in these scripts will be unencrypted
|
||||
PublishScripts/
|
||||
|
||||
# NuGet Packages
|
||||
*.nupkg
|
||||
# The packages folder can be ignored because of Package Restore
|
||||
**/packages/*
|
||||
# except build/, which is used as an MSBuild target.
|
||||
!**/packages/build/
|
||||
# Uncomment if necessary however generally it will be regenerated when needed
|
||||
#!**/packages/repositories.config
|
||||
# NuGet v3's project.json files produces more ignoreable files
|
||||
*.nuget.props
|
||||
*.nuget.targets
|
||||
|
||||
# Microsoft Azure Build Output
|
||||
csx/
|
||||
*.build.csdef
|
||||
|
||||
# Microsoft Azure Emulator
|
||||
ecf/
|
||||
rcf/
|
||||
|
||||
# Windows Store app package directories and files
|
||||
AppPackages/
|
||||
BundleArtifacts/
|
||||
Package.StoreAssociation.xml
|
||||
_pkginfo.txt
|
||||
|
||||
# Visual Studio cache files
|
||||
# files ending in .cache can be ignored
|
||||
*.[Cc]ache
|
||||
# but keep track of directories ending in .cache
|
||||
!*.[Cc]ache/
|
||||
|
||||
# Others
|
||||
ClientBin/
|
||||
~$*
|
||||
*~
|
||||
*.dbmdl
|
||||
*.dbproj.schemaview
|
||||
*.jfm
|
||||
*.pfx
|
||||
*.publishsettings
|
||||
node_modules/
|
||||
orleans.codegen.cs
|
||||
|
||||
# Since there are multiple workflows, uncomment next line to ignore bower_components
|
||||
# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
|
||||
#bower_components/
|
||||
|
||||
# RIA/Silverlight projects
|
||||
Generated_Code/
|
||||
|
||||
# Backup & report files from converting an old project file
|
||||
# to a newer Visual Studio version. Backup files are not needed,
|
||||
# because we have git ;-)
|
||||
_UpgradeReport_Files/
|
||||
Backup*/
|
||||
UpgradeLog*.XML
|
||||
UpgradeLog*.htm
|
||||
|
||||
# SQL Server files
|
||||
*.mdf
|
||||
*.ldf
|
||||
|
||||
# Business Intelligence projects
|
||||
*.rdl.data
|
||||
*.bim.layout
|
||||
*.bim_*.settings
|
||||
|
||||
# Microsoft Fakes
|
||||
FakesAssemblies/
|
||||
|
||||
# GhostDoc plugin setting file
|
||||
*.GhostDoc.xml
|
||||
|
||||
# Node.js Tools for Visual Studio
|
||||
.ntvs_analysis.dat
|
||||
|
||||
# Visual Studio 6 build log
|
||||
*.plg
|
||||
|
||||
# Visual Studio 6 workspace options file
|
||||
*.opt
|
||||
|
||||
# Visual Studio LightSwitch build output
|
||||
**/*.HTMLClient/GeneratedArtifacts
|
||||
**/*.DesktopClient/GeneratedArtifacts
|
||||
**/*.DesktopClient/ModelManifest.xml
|
||||
**/*.Server/GeneratedArtifacts
|
||||
**/*.Server/ModelManifest.xml
|
||||
_Pvt_Extensions
|
||||
|
||||
# Paket dependency manager
|
||||
.paket/paket.exe
|
||||
paket-files/
|
||||
|
||||
# FAKE - F# Make
|
||||
.fake/
|
||||
|
||||
# JetBrains Rider
|
||||
.idea/
|
||||
*.sln.iml
|
||||
|
||||
# CodeRush
|
||||
.cr/
|
||||
|
||||
# Python Tools for Visual Studio (PTVS)
|
||||
__pycache__/
|
||||
*.pyc
|
||||
/OpenAuth.Mvc/Properties/PublishProfiles
|
||||
*.pubxml
|
||||
/OpenAuth.WebApi/temp-keys
|
||||
|
@ -1,6 +1,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using OpenAuth.App.Interface;
|
||||
using OpenAuth.App.Request;
|
||||
using OpenAuth.Repository.Domain;
|
||||
@ -28,7 +29,7 @@ namespace OpenAuth.App
|
||||
}
|
||||
|
||||
|
||||
public List<Application> GetList(QueryAppListReq request)
|
||||
public async Task<List<Application>> GetList(QueryAppListReq request)
|
||||
{
|
||||
var applications = UnitWork.Find<Application>(null) ;
|
||||
|
||||
|
@ -50,7 +50,7 @@ namespace OpenAuth.App
|
||||
else
|
||||
{
|
||||
service = _normalAuthStrategy;
|
||||
service.User = _unitWork.FindSingle<User>(u => u.Account == username);
|
||||
service.User = _unitWork.FirstOrDefault<User>(u => u.Account == username);
|
||||
}
|
||||
|
||||
return new AuthStrategyContext(service);
|
||||
|
@ -18,13 +18,12 @@ namespace OpenAuth.App
|
||||
/// <summary>
|
||||
/// 用于普通的数据库操作
|
||||
/// </summary>
|
||||
/// <value>The repository.</value>
|
||||
protected IRepository<T> Repository;
|
||||
|
||||
/// <summary>
|
||||
/// 用于事务操作
|
||||
/// <para>使用详见:http://doc.openauth.me/core/unitwork.html</para>
|
||||
/// </summary>
|
||||
/// <value>The unit work.</value>
|
||||
protected IUnitWork UnitWork;
|
||||
|
||||
protected IAuth _auth;
|
||||
@ -47,7 +46,7 @@ namespace OpenAuth.App
|
||||
if (loginUser.User.Account == Define.SYSTEM_USERNAME) return UnitWork.Find<T>(null); //超级管理员特权
|
||||
|
||||
var moduleName = typeof(T).Name;
|
||||
var rule = UnitWork.FindSingle<DataPrivilegeRule>(u => u.SourceCode == moduleName);
|
||||
var rule = UnitWork.FirstOrDefault<DataPrivilegeRule>(u => u.SourceCode == moduleName);
|
||||
if (rule == null) return UnitWork.Find<T>(null); //没有设置数据规则,那么视为该资源允许被任何主体查看
|
||||
if (rule.PrivilegeRules.Contains(Define.DATAPRIVILEGE_LOGINUSER) ||
|
||||
rule.PrivilegeRules.Contains(Define.DATAPRIVILEGE_LOGINROLE)||
|
||||
@ -82,7 +81,7 @@ namespace OpenAuth.App
|
||||
|
||||
public T Get(string id)
|
||||
{
|
||||
return Repository.FindSingle(u => u.Id == id);
|
||||
return Repository.FirstOrDefault(u => u.Id == id);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -104,7 +103,7 @@ namespace OpenAuth.App
|
||||
|
||||
if (!string.IsNullOrEmpty(entity.ParentId))
|
||||
{
|
||||
var parentOrg = UnitWork.FindSingle<U>(o => o.Id == entity.ParentId);
|
||||
var parentOrg = UnitWork.FirstOrDefault<U>(o => o.Id == entity.ParentId);
|
||||
if (parentOrg != null)
|
||||
{
|
||||
cascadeId = parentOrg.CascadeId + currentCascadeId + ".";
|
||||
|
@ -29,7 +29,7 @@ namespace OpenAuth.App
|
||||
CaculateCascade(obj);
|
||||
|
||||
//获取旧的的CascadeId
|
||||
var cascadeId = Repository.FindSingle(o => o.Id == obj.Id).CascadeId;
|
||||
var cascadeId = Repository.FirstOrDefault(o => o.Id == obj.Id).CascadeId;
|
||||
//根据CascadeId查询子部门
|
||||
var objs = Repository.Find(u => u.CascadeId.Contains(cascadeId) && u.Id != obj.Id)
|
||||
.OrderBy(u => u.CascadeId).ToList();
|
||||
|
@ -6,6 +6,7 @@ using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Runtime.Loader;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Infrastructure;
|
||||
using Infrastructure.Extensions;
|
||||
using Infrastructure.Helpers;
|
||||
@ -76,7 +77,7 @@ namespace OpenAuth.App
|
||||
/// <summary>
|
||||
/// 加载列表
|
||||
/// </summary>
|
||||
public TableResp<BuilderTable> Load(QueryBuilderTableListReq request)
|
||||
public async Task<TableResp<BuilderTable>> Load(QueryBuilderTableListReq request)
|
||||
{
|
||||
var loginContext = _auth.GetCurrentUser();
|
||||
if (loginContext == null)
|
||||
@ -192,9 +193,12 @@ namespace OpenAuth.App
|
||||
/// <param name="ids"></param>
|
||||
public void DelTableAndcolumns(string[] ids)
|
||||
{
|
||||
UnitWork.Delete<BuilderTable>(u => ids.Contains(u.Id));
|
||||
UnitWork.Delete<BuilderTableColumn>(u => ids.Contains(u.TableId));
|
||||
UnitWork.Save();
|
||||
UnitWork.ExecuteWithTransaction(() =>
|
||||
{
|
||||
UnitWork.Delete<BuilderTable>(u => ids.Contains(u.Id));
|
||||
UnitWork.Delete<BuilderTableColumn>(u => ids.Contains(u.TableId));
|
||||
UnitWork.Save();
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@ -204,7 +208,7 @@ namespace OpenAuth.App
|
||||
/// <returns></returns>
|
||||
public void CreateEntity(CreateEntityReq req)
|
||||
{
|
||||
var sysTableInfo = Repository.FindSingle(u => u.Id == req.Id);
|
||||
var sysTableInfo = Repository.FirstOrDefault(u => u.Id == req.Id);
|
||||
var tableColumns = _builderTableColumnApp.Find(req.Id);
|
||||
if (sysTableInfo == null
|
||||
|| tableColumns == null
|
||||
@ -223,7 +227,7 @@ namespace OpenAuth.App
|
||||
/// <returns></returns>
|
||||
public void CreateBusiness(CreateBusiReq req)
|
||||
{
|
||||
var sysTableInfo = Repository.FindSingle(u => u.Id == req.Id);
|
||||
var sysTableInfo = Repository.FirstOrDefault(u => u.Id == req.Id);
|
||||
var tableColumns = _builderTableColumnApp.Find(req.Id);
|
||||
if (sysTableInfo == null
|
||||
|| tableColumns == null
|
||||
@ -512,7 +516,7 @@ namespace OpenAuth.App
|
||||
{
|
||||
throw new Exception("请提供vue项目的根目录,如:C:\\OpenAuth.Pro\\Client");
|
||||
}
|
||||
var sysTableInfo = Repository.FindSingle(u => u.Id == req.Id);
|
||||
var sysTableInfo = Repository.FirstOrDefault(u => u.Id == req.Id);
|
||||
var tableColumns = _builderTableColumnApp.Find(req.Id);
|
||||
if (sysTableInfo == null
|
||||
|| tableColumns == null
|
||||
@ -617,7 +621,7 @@ namespace OpenAuth.App
|
||||
.Replace("{Temp}", tempBuilder.ToString())
|
||||
.Replace("{DialogFormItem}", dialogStrBuilder.ToString());
|
||||
|
||||
FileHelper.WriteFile(Path.Combine(req.VueProjRootPath, $"src/views/{sysTableInfo.ClassName.ToCamelCase()}s/"),
|
||||
FileHelper.WriteFile(Path.Combine(req.VueProjRootPath, $"src/views/{sysTableInfo.ClassName.ToLower()}s/"),
|
||||
$"index.vue",
|
||||
domainContent);
|
||||
}
|
||||
@ -633,7 +637,7 @@ namespace OpenAuth.App
|
||||
{
|
||||
throw new Exception("请提供vue项目的根目录,如:C:\\OpenAuth.Pro\\Client");
|
||||
}
|
||||
var sysTableInfo = Repository.FindSingle(u => u.Id == req.Id);
|
||||
var sysTableInfo = Repository.FirstOrDefault(u => u.Id == req.Id);
|
||||
var tableColumns = _builderTableColumnApp.Find(req.Id);
|
||||
if (sysTableInfo == null
|
||||
|| tableColumns == null
|
||||
|
@ -1,6 +1,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Infrastructure;
|
||||
using OpenAuth.App.Interface;
|
||||
using OpenAuth.App.Request;
|
||||
@ -21,7 +22,7 @@ namespace OpenAuth.App
|
||||
/// <summary>
|
||||
/// 加载列表
|
||||
/// </summary>
|
||||
public TableResp<BuilderTableColumn> Load(QueryBuilderTableColumnListReq request)
|
||||
public async Task<TableResp<BuilderTableColumn>> Load(QueryBuilderTableColumnListReq request)
|
||||
{
|
||||
if (string.IsNullOrEmpty(request.BuilderTableId))
|
||||
{
|
||||
|
@ -1,6 +1,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Infrastructure;
|
||||
using OpenAuth.App.Interface;
|
||||
using OpenAuth.App.Request;
|
||||
@ -16,7 +17,7 @@ namespace OpenAuth.App
|
||||
/// <summary>
|
||||
/// 加载列表
|
||||
/// </summary>
|
||||
public TableData Load(QueryCategoryListReq request)
|
||||
public async Task<TableData> Load(QueryCategoryListReq request)
|
||||
{
|
||||
var loginContext = _auth.GetCurrentUser();
|
||||
if (loginContext == null)
|
||||
|
@ -1,6 +1,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Infrastructure;
|
||||
using OpenAuth.App.Interface;
|
||||
using OpenAuth.App.Request;
|
||||
@ -18,7 +19,7 @@ namespace OpenAuth.App
|
||||
/// <summary>
|
||||
/// 加载列表
|
||||
/// </summary>
|
||||
public TableData Load(QueryCategoryTypeListReq request)
|
||||
public async Task<TableData> Load(QueryCategoryTypeListReq request)
|
||||
{
|
||||
var result = new TableData();
|
||||
var objs = UnitWork.Find<CategoryType>(null);
|
||||
@ -56,9 +57,13 @@ namespace OpenAuth.App
|
||||
|
||||
public new void Delete(string[] ids)
|
||||
{
|
||||
UnitWork.Delete<CategoryType>(u=>ids.Contains(u.Id));
|
||||
UnitWork.Delete<Category>(u=>ids.Contains(u.TypeId));
|
||||
UnitWork.Save();
|
||||
UnitWork.ExecuteWithTransaction(() =>
|
||||
{
|
||||
UnitWork.Delete<CategoryType>(u=>ids.Contains(u.Id));
|
||||
UnitWork.Delete<Category>(u=>ids.Contains(u.TypeId));
|
||||
UnitWork.Save();
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
public List<CategoryType> AllTypes()
|
||||
|
@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Infrastructure;
|
||||
using OpenAuth.App.Interface;
|
||||
using OpenAuth.App.Request;
|
||||
@ -16,7 +17,7 @@ namespace OpenAuth.App
|
||||
/// <summary>
|
||||
/// 加载列表
|
||||
/// </summary>
|
||||
public TableData Load(QueryDataPrivilegeRuleListReq request)
|
||||
public async Task<TableData> Load(QueryDataPrivilegeRuleListReq request)
|
||||
{
|
||||
var loginContext = _auth.GetCurrentUser();
|
||||
if (loginContext == null)
|
||||
@ -51,7 +52,7 @@ namespace OpenAuth.App
|
||||
|
||||
public void Add(AddOrUpdateDataPriviReq req)
|
||||
{
|
||||
if (Repository.IsExist(u => u.SourceCode == req.SourceCode))
|
||||
if (Repository.Any(u => u.SourceCode == req.SourceCode))
|
||||
{
|
||||
throw new Exception($"已经存在{req.SourceCode}的数据规则,如果想调整规制请直接修改");
|
||||
}
|
||||
@ -85,7 +86,7 @@ namespace OpenAuth.App
|
||||
|
||||
public DataPrivilegeRule GetByModuleName(string moduleName)
|
||||
{
|
||||
return Repository.FindSingle(u=>u.SourceCode == moduleName);
|
||||
return Repository.FirstOrDefault(u=>u.SourceCode == moduleName);
|
||||
}
|
||||
|
||||
public void Clear()
|
||||
|
@ -134,7 +134,7 @@ namespace OpenAuth.App
|
||||
END AS EntityType,
|
||||
case WHEN CHARACTER_MAXIMUM_LENGTH>8000 THEN 0 ELSE CHARACTER_MAXIMUM_LENGTH end AS Maxlength,
|
||||
CASE
|
||||
WHEN COLUMN_KEY <> '' THEN
|
||||
WHEN COLUMN_KEY = 'PRI' THEN
|
||||
1 ELSE 0
|
||||
END AS IsKey,
|
||||
CASE
|
||||
|
@ -24,6 +24,7 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Linq.Expressions;
|
||||
using System.Net.Http;
|
||||
using System.Threading.Tasks;
|
||||
using Infrastructure.Helpers;
|
||||
|
||||
namespace OpenAuth.App
|
||||
@ -472,7 +473,7 @@ namespace OpenAuth.App
|
||||
Repository.Update(flowScheme);
|
||||
}
|
||||
|
||||
public TableData Load(QueryFlowInstanceListReq request)
|
||||
public async Task<TableData> Load(QueryFlowInstanceListReq request)
|
||||
{
|
||||
var result = new TableData();
|
||||
var user = _auth.GetCurrentUser();
|
||||
|
@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using OpenAuth.App.Interface;
|
||||
using OpenAuth.App.Request;
|
||||
using OpenAuth.App.Response;
|
||||
@ -12,7 +13,7 @@ namespace OpenAuth.App
|
||||
{
|
||||
public void Add(FlowScheme flowScheme)
|
||||
{
|
||||
if (Repository.IsExist(u => u.SchemeName == flowScheme.SchemeName))
|
||||
if (Repository.Any(u => u.SchemeName == flowScheme.SchemeName))
|
||||
{
|
||||
throw new Exception("流程名称已经存在");
|
||||
}
|
||||
@ -25,12 +26,12 @@ namespace OpenAuth.App
|
||||
|
||||
public FlowScheme FindByCode(string code)
|
||||
{
|
||||
return Repository.FindSingle(u => u.SchemeCode == code);
|
||||
return Repository.FirstOrDefault(u => u.SchemeCode == code);
|
||||
}
|
||||
|
||||
public void Update(FlowScheme flowScheme)
|
||||
{
|
||||
if (Repository.IsExist(u => u.SchemeName == flowScheme.SchemeName && u.Id != flowScheme.Id))
|
||||
if (Repository.Any(u => u.SchemeName == flowScheme.SchemeName && u.Id != flowScheme.Id))
|
||||
{
|
||||
throw new Exception("流程名称已经存在");
|
||||
}
|
||||
@ -48,7 +49,7 @@ namespace OpenAuth.App
|
||||
});
|
||||
}
|
||||
|
||||
public TableData Load(QueryFlowSchemeListReq request)
|
||||
public async Task<TableData> Load(QueryFlowSchemeListReq request)
|
||||
{
|
||||
var result = new TableData();
|
||||
var objs = GetDataPrivilege("u");
|
||||
|
@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Infrastructure;
|
||||
using Microsoft.Extensions.Options;
|
||||
using OpenAuth.App.Interface;
|
||||
@ -18,7 +19,7 @@ namespace OpenAuth.App
|
||||
/// <summary>
|
||||
/// 加载列表
|
||||
/// </summary>
|
||||
public TableData Load(QueryFormListReq request)
|
||||
public async Task<TableData> Load(QueryFormListReq request)
|
||||
{
|
||||
var result = new TableData();
|
||||
var forms = GetDataPrivilege("u");
|
||||
|
@ -1,4 +1,5 @@
|
||||
using Infrastructure;
|
||||
using System.Threading.Tasks;
|
||||
using Infrastructure;
|
||||
using OpenAuth.App.Interface;
|
||||
using OpenAuth.App.Request;
|
||||
using OpenAuth.App.Response;
|
||||
@ -15,11 +16,11 @@ namespace OpenAuth.App
|
||||
/// <summary>
|
||||
/// 加载列表
|
||||
/// </summary>
|
||||
public TableData Load(QueryFrmLeaveReqListReq request)
|
||||
public async Task<TableData> Load(QueryFrmLeaveReqListReq request)
|
||||
{
|
||||
return new TableData
|
||||
{
|
||||
count = Repository.GetCount(null),
|
||||
count = Repository.Count(null),
|
||||
data = Repository.Find(request.page, request.limit, "Id desc")
|
||||
};
|
||||
}
|
||||
|
@ -8,9 +8,10 @@ using OpenAuth.Repository.Interface;
|
||||
|
||||
namespace OpenAuth.App
|
||||
{
|
||||
public class ModuleManagerApp :BaseTreeApp<Module>
|
||||
public class ModuleManagerApp : BaseTreeApp<Module>
|
||||
{
|
||||
private RevelanceManagerApp _revelanceApp;
|
||||
|
||||
public void Add(Module model)
|
||||
{
|
||||
var loginContext = _auth.GetCurrentUser();
|
||||
@ -18,20 +19,22 @@ namespace OpenAuth.App
|
||||
{
|
||||
throw new CommonException("登录已过期", Define.INVALID_TOKEN);
|
||||
}
|
||||
|
||||
CaculateCascade(model);
|
||||
|
||||
Repository.Add(model);
|
||||
|
||||
AddDefaultMenus(model);
|
||||
//当前登录用户的所有角色自动分配模块
|
||||
loginContext.Roles.ForEach(u =>
|
||||
{
|
||||
_revelanceApp.Assign(new AssignReq
|
||||
{
|
||||
type=Define.ROLEMODULE,
|
||||
type = Define.ROLEMODULE,
|
||||
firstId = u.Id,
|
||||
secIds = new[]{model.Id}
|
||||
secIds = new[] {model.Id}
|
||||
});
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
public void Update(Module obj)
|
||||
@ -40,10 +43,8 @@ namespace OpenAuth.App
|
||||
}
|
||||
|
||||
|
||||
|
||||
#region 用户/角色分配模块
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 加载特定角色的模块
|
||||
/// </summary>
|
||||
@ -67,7 +68,7 @@ namespace OpenAuth.App
|
||||
var query = UnitWork.Find<ModuleElement>(u => elementIds.Contains(u.Id));
|
||||
if (!string.IsNullOrEmpty(moduleId))
|
||||
{
|
||||
query = query.Where(u => u.ModuleId == moduleId);
|
||||
query = query.Where(u => u.ModuleId == moduleId);
|
||||
}
|
||||
|
||||
return query;
|
||||
@ -77,6 +78,7 @@ namespace OpenAuth.App
|
||||
|
||||
|
||||
#region 菜单操作
|
||||
|
||||
/// <summary>
|
||||
/// 删除指定的菜单
|
||||
/// </summary>
|
||||
@ -87,6 +89,7 @@ namespace OpenAuth.App
|
||||
UnitWork.Save();
|
||||
}
|
||||
|
||||
|
||||
public void AddMenu(ModuleElement model)
|
||||
{
|
||||
var loginContext = _auth.GetCurrentUser();
|
||||
@ -94,21 +97,24 @@ namespace OpenAuth.App
|
||||
{
|
||||
throw new CommonException("登录已过期", Define.INVALID_TOKEN);
|
||||
}
|
||||
UnitWork.Add(model);
|
||||
|
||||
//当前登录用户的所有角色自动分配菜单
|
||||
loginContext.Roles.ForEach(u =>
|
||||
UnitWork.ExecuteWithTransaction(() =>
|
||||
{
|
||||
_revelanceApp.Assign(new AssignReq
|
||||
UnitWork.Add(model);
|
||||
|
||||
//当前登录用户的所有角色自动分配菜单
|
||||
loginContext.Roles.ForEach(u =>
|
||||
{
|
||||
type=Define.ROLEELEMENT,
|
||||
firstId = u.Id,
|
||||
secIds = new[]{model.Id}
|
||||
_revelanceApp.Assign(new AssignReq
|
||||
{
|
||||
type = Define.ROLEELEMENT,
|
||||
firstId = u.Id,
|
||||
secIds = new[] {model.Id}
|
||||
});
|
||||
});
|
||||
UnitWork.Save();
|
||||
});
|
||||
UnitWork.Save();
|
||||
}
|
||||
#endregion
|
||||
|
||||
public void UpdateMenu(ModuleElement model)
|
||||
{
|
||||
@ -116,8 +122,51 @@ namespace OpenAuth.App
|
||||
UnitWork.Save();
|
||||
}
|
||||
|
||||
//添加默认按钮
|
||||
private void AddDefaultMenus(Module module)
|
||||
{
|
||||
AddMenu(new ModuleElement
|
||||
{
|
||||
ModuleId = module.Id,
|
||||
DomId = "btnAdd",
|
||||
Script = "add()",
|
||||
Name = "添加",
|
||||
Sort = 1,
|
||||
Icon = "xinzeng",
|
||||
Class = "success",
|
||||
Remark = "新增" + module.Name
|
||||
});
|
||||
AddMenu(new ModuleElement
|
||||
{
|
||||
ModuleId = module.Id,
|
||||
DomId = "btnEdit",
|
||||
Script = "edit()",
|
||||
Name = "编辑",
|
||||
Sort = 2,
|
||||
Icon = "bianji-copy",
|
||||
Class = "primary",
|
||||
Remark = "修改" + module.Name
|
||||
});
|
||||
AddMenu(new ModuleElement
|
||||
{
|
||||
ModuleId = module.Id,
|
||||
DomId = "btnDel",
|
||||
Script = "del()",
|
||||
Name = "删除",
|
||||
Sort = 3,
|
||||
Icon = "shanchu",
|
||||
Class = "danger",
|
||||
Remark = "删除" + module.Name
|
||||
});
|
||||
|
||||
//todo:可以自己添加更多默认按钮
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
public ModuleManagerApp(IUnitWork unitWork, IRepository<Module> repository
|
||||
,RevelanceManagerApp app,IAuth auth) : base(unitWork, repository, auth)
|
||||
, RevelanceManagerApp app, IAuth auth) : base(unitWork, repository, auth)
|
||||
{
|
||||
_revelanceApp = app;
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Infrastructure;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using OpenAuth.App.Interface;
|
||||
@ -23,7 +24,7 @@ namespace OpenAuth.App
|
||||
/// <summary>
|
||||
/// 加载列表
|
||||
/// </summary>
|
||||
public TableData Load(QueryOpenJobListReq request)
|
||||
public async Task<TableData> Load(QueryOpenJobListReq request)
|
||||
{
|
||||
var result = new TableData();
|
||||
var objs = Repository.Find(null);
|
||||
@ -86,7 +87,7 @@ namespace OpenAuth.App
|
||||
|
||||
public void ChangeJobStatus(ChangeJobStatusReq req)
|
||||
{
|
||||
var job = Repository.FindSingle(u => u.Id == req.Id);
|
||||
var job = Repository.FirstOrDefault(u => u.Id == req.Id);
|
||||
if (job == null)
|
||||
{
|
||||
throw new Exception("任务不存在");
|
||||
@ -140,7 +141,7 @@ namespace OpenAuth.App
|
||||
/// <param name="jobId"></param>
|
||||
public void RecordRun(string jobId)
|
||||
{
|
||||
var job = Repository.FindSingle(u =>u.Id == jobId);
|
||||
var job = Repository.FirstOrDefault(u =>u.Id == jobId);
|
||||
if (job == null)
|
||||
{
|
||||
_sysLogApp.Add(new SysLog
|
||||
|
@ -1,6 +1,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Infrastructure;
|
||||
using OpenAuth.App.Interface;
|
||||
using OpenAuth.App.Request;
|
||||
@ -47,7 +48,7 @@ namespace OpenAuth.App
|
||||
return UnitWork.Find<Resource>(u => elementIds.Contains(u.Id) && (appId == null || appId =="" || u.AppId == appId));
|
||||
}
|
||||
|
||||
public TableData Load(QueryResourcesReq request)
|
||||
public async Task<TableData> Load(QueryResourcesReq request)
|
||||
{
|
||||
var loginContext = _auth.GetCurrentUser();
|
||||
if (loginContext == null)
|
||||
|
@ -51,7 +51,7 @@ namespace OpenAuth.App.SSO
|
||||
}
|
||||
else
|
||||
{
|
||||
userInfo = _app.FindSingle(u =>u.Account == model.Account);
|
||||
userInfo = _app.FirstOrDefault(u =>u.Account == model.Account);
|
||||
}
|
||||
|
||||
if (userInfo == null)
|
||||
@ -63,6 +63,11 @@ namespace OpenAuth.App.SSO
|
||||
throw new Exception("密码错误");
|
||||
}
|
||||
|
||||
if (userInfo.Status != 0)
|
||||
{
|
||||
throw new Exception("账号状态异常,可能已停用");
|
||||
}
|
||||
|
||||
var currentSession = new UserAuthSession
|
||||
{
|
||||
Account = model.Account,
|
||||
|
@ -1,5 +1,6 @@
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Threading.Tasks;
|
||||
using OpenAuth.App.Request;
|
||||
using OpenAuth.App.Response;
|
||||
using OpenAuth.Repository.Domain;
|
||||
@ -14,7 +15,7 @@ namespace OpenAuth.App
|
||||
/// <summary>
|
||||
/// 加载列表
|
||||
/// </summary>
|
||||
public TableData Load(QuerySysLogListReq request)
|
||||
public async Task<TableData> Load(QuerySysLogListReq request)
|
||||
{
|
||||
var result = new TableData();
|
||||
var objs = UnitWork.Find<SysLog>(null);
|
||||
|
@ -1,4 +1,5 @@
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Infrastructure;
|
||||
using OpenAuth.App.Interface;
|
||||
using OpenAuth.App.Request;
|
||||
@ -16,7 +17,7 @@ namespace OpenAuth.App
|
||||
/// <summary>
|
||||
/// 加载列表
|
||||
/// </summary>
|
||||
public TableData Load(QuerySysMessageListReq request)
|
||||
public async Task<TableData> Load(QuerySysMessageListReq request)
|
||||
{
|
||||
var loginContext = _auth.GetCurrentUser();
|
||||
if (loginContext == null)
|
||||
|
68
OpenAuth.App/Test/TestAsync.cs
Normal file
68
OpenAuth.App/Test/TestAsync.cs
Normal file
@ -0,0 +1,68 @@
|
||||
using System;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Infrastructure.Cache;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Moq;
|
||||
using NUnit.Framework;
|
||||
using OpenAuth.App.Request;
|
||||
using OpenAuth.App.SSO;
|
||||
using OpenAuth.Repository.Domain;
|
||||
using OpenAuth.Repository.Interface;
|
||||
|
||||
namespace OpenAuth.App.Test
|
||||
{
|
||||
public class TestDynamic : TestBase
|
||||
{
|
||||
public override ServiceCollection GetService()
|
||||
{
|
||||
var services = new ServiceCollection();
|
||||
|
||||
var cachemock = new Mock<ICacheContext>();
|
||||
cachemock.Setup(x => x.Get<UserAuthSession>("tokentest"))
|
||||
.Returns(new UserAuthSession { Account = "System" });
|
||||
services.AddScoped(x => cachemock.Object);
|
||||
|
||||
var httpContextAccessorMock = new Mock<IHttpContextAccessor>();
|
||||
httpContextAccessorMock.Setup(x => x.HttpContext.Request.Query[Define.TOKEN_NAME])
|
||||
.Returns("tokentest");
|
||||
|
||||
services.AddScoped(x => httpContextAccessorMock.Object);
|
||||
|
||||
return services;
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Async()
|
||||
{
|
||||
Console.WriteLine($"开始异步测试");
|
||||
|
||||
AddOrUpdate();
|
||||
|
||||
Console.WriteLine("异步测试结束");
|
||||
|
||||
//延长主线程,防止程序退出
|
||||
Thread.Sleep(3000);
|
||||
}
|
||||
|
||||
private async Task AddOrUpdate()
|
||||
{
|
||||
var repository = _autofacServiceProvider.GetService<IRepository<User>>();
|
||||
|
||||
var account = "user_" + DateTime.Now.ToString("yyyy_MM_dd HH:mm:ss");
|
||||
|
||||
var user = new User
|
||||
{
|
||||
Account = account,
|
||||
Name = account
|
||||
};
|
||||
await repository.AddAsync(user);
|
||||
|
||||
user.Account = "new_" + user.Account;
|
||||
|
||||
await repository.UpdateAsync(user);
|
||||
Console.WriteLine($"更新完成");
|
||||
}
|
||||
}
|
||||
}
|
@ -1,6 +1,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Castle.Core.Internal;
|
||||
using OpenAuth.App.Interface;
|
||||
using OpenAuth.App.Request;
|
||||
@ -25,14 +26,14 @@ namespace OpenAuth.App
|
||||
|
||||
public User GetByAccount(string account)
|
||||
{
|
||||
return Repository.FindSingle(u => u.Account == account);
|
||||
return Repository.FirstOrDefault(u => u.Account == account);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 加载当前登录用户可访问的一个部门及子部门全部用户
|
||||
/// 如果请求的request.OrgId为空,则可以获取到已被删除机构的用户(即:没有分配任何机构的用户)
|
||||
/// </summary>
|
||||
public TableData Load(QueryUserListReq request)
|
||||
public async Task<TableData> Load(QueryUserListReq request)
|
||||
{
|
||||
var loginUser = _auth.GetCurrentUser();
|
||||
|
||||
@ -120,7 +121,7 @@ namespace OpenAuth.App
|
||||
requser.CreateId = _auth.GetCurrentUser().User.Id;
|
||||
if (string.IsNullOrEmpty(request.Id))
|
||||
{
|
||||
if (UnitWork.IsExist<User>(u => u.Account == request.Account))
|
||||
if (UnitWork.Any<User>(u => u.Account == request.Account))
|
||||
{
|
||||
throw new Exception("用户账号已存在");
|
||||
}
|
||||
@ -191,7 +192,7 @@ namespace OpenAuth.App
|
||||
/// </summary>
|
||||
/// <param name="request"></param>
|
||||
/// <returns></returns>
|
||||
public TableData LoadByRole(QueryUserListByRoleReq request)
|
||||
public async Task<TableData> LoadByRole(QueryUserListByRoleReq request)
|
||||
{
|
||||
var users = from userRole in UnitWork.Find<Relevance>(u =>
|
||||
u.SecondId == request.roleId && u.Key == Define.USERROLE)
|
||||
@ -211,7 +212,7 @@ namespace OpenAuth.App
|
||||
/// </summary>
|
||||
/// <param name="request"></param>
|
||||
/// <returns></returns>
|
||||
public TableData LoadByOrg(QueryUserListByOrgReq request)
|
||||
public async Task<TableData> LoadByOrg(QueryUserListByOrgReq request)
|
||||
{
|
||||
var users = from userRole in UnitWork.Find<Relevance>(u =>
|
||||
u.SecondId == request.orgId && u.Key == Define.USERORG)
|
||||
|
@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Infrastructure;
|
||||
using OpenAuth.App.Interface;
|
||||
using OpenAuth.App.Request;
|
||||
@ -18,7 +19,7 @@ namespace OpenAuth.App
|
||||
/// <summary>
|
||||
/// 加载列表
|
||||
/// </summary>
|
||||
public TableData Load(QueryWmsInboundOrderDtblListReq request)
|
||||
public async Task<TableData> Load(QueryWmsInboundOrderDtblListReq request)
|
||||
{
|
||||
|
||||
var loginContext = _auth.GetCurrentUser();
|
||||
|
@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Infrastructure;
|
||||
using OpenAuth.App.Interface;
|
||||
using OpenAuth.App.Request;
|
||||
@ -18,7 +19,7 @@ namespace OpenAuth.App
|
||||
/// <summary>
|
||||
/// 加载列表
|
||||
/// </summary>
|
||||
public TableData Load(QueryWmsInboundOrderTblListReq request)
|
||||
public async Task<TableData> Load(QueryWmsInboundOrderTblListReq request)
|
||||
{
|
||||
var loginContext = _auth.GetCurrentUser();
|
||||
if (loginContext == null)
|
||||
@ -71,65 +72,67 @@ namespace OpenAuth.App
|
||||
UnitWork.Save();
|
||||
}
|
||||
|
||||
public void Update(AddOrUpdateWmsInboundOrderTblReq obj)
|
||||
public void Update(AddOrUpdateWmsInboundOrderTblReq obj)
|
||||
{
|
||||
var user = _auth.GetCurrentUser().User;
|
||||
|
||||
if (obj.WmsInboundOrderDtblReqs != null && obj.WmsInboundOrderDtblReqs.Any())
|
||||
UnitWork.ExecuteWithTransaction(() =>
|
||||
{
|
||||
//id为空的添加
|
||||
foreach (var detail in obj.WmsInboundOrderDtblReqs.Where(u =>string.IsNullOrEmpty(u.Id)))
|
||||
if (obj.WmsInboundOrderDtblReqs != null && obj.WmsInboundOrderDtblReqs.Any())
|
||||
{
|
||||
detail.OrderId = obj.Id;
|
||||
_wmsInboundOrderDtblApp.AddNoSave(detail);
|
||||
//id为空的添加
|
||||
foreach (var detail in obj.WmsInboundOrderDtblReqs.Where(u => string.IsNullOrEmpty(u.Id)))
|
||||
{
|
||||
detail.OrderId = obj.Id;
|
||||
_wmsInboundOrderDtblApp.AddNoSave(detail);
|
||||
}
|
||||
|
||||
//id比数据库少的,删除
|
||||
var containids = obj.WmsInboundOrderDtblReqs.Select(u => u.Id)
|
||||
.Where(u => !string.IsNullOrEmpty(u)).ToList();
|
||||
if (containids.Any())
|
||||
{
|
||||
UnitWork.Delete<WmsInboundOrderDtbl>(u => (!containids.Contains(u.Id)) && u.OrderId == obj.Id);
|
||||
}
|
||||
|
||||
//更新id相同的
|
||||
foreach (var detail in obj.WmsInboundOrderDtblReqs.Where(u => !string.IsNullOrEmpty(u.Id)))
|
||||
{
|
||||
_wmsInboundOrderDtblApp.Update(detail);
|
||||
}
|
||||
}
|
||||
|
||||
//id比数据库少的,删除
|
||||
var containids = obj.WmsInboundOrderDtblReqs.Select(u => u.Id)
|
||||
.Where(u =>!string.IsNullOrEmpty(u)).ToList();
|
||||
if (containids.Any())
|
||||
UnitWork.Update<WmsInboundOrderTbl>(u => u.Id == obj.Id, u => new WmsInboundOrderTbl
|
||||
{
|
||||
UnitWork.Delete<WmsInboundOrderDtbl>(u =>(!containids.Contains(u.Id)) && u.OrderId == obj.Id);
|
||||
}
|
||||
ExternalNo = obj.ExternalNo,
|
||||
ExternalType = obj.ExternalType,
|
||||
Status = obj.Status,
|
||||
OrderType = obj.OrderType,
|
||||
GoodsType = obj.GoodsType,
|
||||
PurchaseNo = obj.PurchaseNo,
|
||||
StockId = obj.StockId,
|
||||
OwnerId = obj.OwnerId,
|
||||
ShipperId = obj.ShipperId,
|
||||
SupplierId = obj.SupplierId,
|
||||
ScheduledInboundTime = obj.ScheduledInboundTime,
|
||||
Remark = obj.Remark,
|
||||
Enable = obj.Enable,
|
||||
TransferType = obj.TransferType,
|
||||
InBondedArea = obj.InBondedArea,
|
||||
ReturnBoxNum = obj.ReturnBoxNum,
|
||||
UpdateTime = DateTime.Now,
|
||||
UpdateUserId = user.Id,
|
||||
UpdateUserName = user.Name
|
||||
//todo:补充或调整自己需要的字段
|
||||
});
|
||||
|
||||
|
||||
//更新id相同的
|
||||
foreach (var detail in obj.WmsInboundOrderDtblReqs.Where(u =>!string.IsNullOrEmpty(u.Id)))
|
||||
{
|
||||
_wmsInboundOrderDtblApp.Update(detail);
|
||||
}
|
||||
}
|
||||
|
||||
UnitWork.Update<WmsInboundOrderTbl>(u => u.Id == obj.Id, u => new WmsInboundOrderTbl
|
||||
{
|
||||
ExternalNo = obj.ExternalNo,
|
||||
ExternalType = obj.ExternalType,
|
||||
Status = obj.Status,
|
||||
OrderType = obj.OrderType,
|
||||
GoodsType = obj.GoodsType,
|
||||
PurchaseNo = obj.PurchaseNo,
|
||||
StockId = obj.StockId,
|
||||
OwnerId = obj.OwnerId,
|
||||
ShipperId = obj.ShipperId,
|
||||
SupplierId = obj.SupplierId,
|
||||
ScheduledInboundTime = obj.ScheduledInboundTime,
|
||||
Remark = obj.Remark,
|
||||
Enable = obj.Enable,
|
||||
TransferType = obj.TransferType,
|
||||
InBondedArea = obj.InBondedArea,
|
||||
ReturnBoxNum = obj.ReturnBoxNum,
|
||||
UpdateTime = DateTime.Now,
|
||||
UpdateUserId = user.Id,
|
||||
UpdateUserName = user.Name
|
||||
//todo:补充或调整自己需要的字段
|
||||
UnitWork.Save();
|
||||
});
|
||||
|
||||
UnitWork.Save();
|
||||
|
||||
}
|
||||
|
||||
public WmsInboundOrderTblApp(IUnitWork unitWork, IRepository<WmsInboundOrderTbl> repository,
|
||||
RevelanceManagerApp app, IAuth auth, WmsInboundOrderDtblApp wmsInboundOrderDtblApp) : base(unitWork, repository,auth)
|
||||
RevelanceManagerApp app, IAuth auth, WmsInboundOrderDtblApp wmsInboundOrderDtblApp) : base(unitWork,
|
||||
repository, auth)
|
||||
{
|
||||
_revelanceApp = app;
|
||||
_wmsInboundOrderDtblApp = wmsInboundOrderDtblApp;
|
||||
|
@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using Infrastructure;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using OpenAuth.App;
|
||||
@ -14,12 +15,12 @@ namespace OpenAuth.Mvc.Controllers
|
||||
private readonly AppManager _app;
|
||||
|
||||
|
||||
public string GetList([FromQuery]QueryAppListReq request)
|
||||
public async Task<string> GetList([FromQuery]QueryAppListReq request)
|
||||
{
|
||||
var resp = new Response<List<Application>>();
|
||||
try
|
||||
{
|
||||
resp.Result = _app.GetList(request);
|
||||
resp.Result = await _app.GetList(request);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
|
@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using Infrastructure;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using OpenAuth.App;
|
||||
@ -25,10 +26,10 @@ namespace OpenAuth.Mvc.Controllers
|
||||
return View();
|
||||
}
|
||||
|
||||
public string All([FromQuery]QueryCategoryListReq request)
|
||||
public async Task<string> All([FromQuery]QueryCategoryListReq request)
|
||||
{
|
||||
TableData data = new TableData();
|
||||
data = _app.Load(request);
|
||||
data = await _app.Load(request);
|
||||
return JsonHelper.Instance.Serialize(data);
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using Infrastructure;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using OpenAuth.App;
|
||||
@ -95,9 +96,10 @@ namespace OpenAuth.Mvc.Controllers
|
||||
/// <summary>
|
||||
/// 加载组织下面的所有用户
|
||||
/// </summary>
|
||||
public string Load([FromQuery]QueryUserListReq request)
|
||||
public async Task<string> Load([FromQuery]QueryUserListReq request)
|
||||
{
|
||||
return JsonHelper.Instance.Serialize(_app.Load(request));
|
||||
var load = await _app.Load(request);
|
||||
return JsonHelper.Instance.Serialize(load);
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
@ -120,11 +122,11 @@ namespace OpenAuth.Mvc.Controllers
|
||||
|
||||
/// <summary>
|
||||
/// 获取用户可访问的账号
|
||||
/// <para>李玉宝于2017-02-28 15:12:19</para>
|
||||
/// </summary>
|
||||
public string GetAccessedUsers()
|
||||
public async Task<string> GetAccessedUsers()
|
||||
{
|
||||
IEnumerable<UserView> users = _app.Load(new QueryUserListReq()).data;
|
||||
var data = await _app.Load(new QueryUserListReq());
|
||||
IEnumerable<UserView> users = data.data;
|
||||
var result = new Dictionary<string, object>();
|
||||
foreach (var user in users)
|
||||
{
|
||||
|
@ -107,4 +107,4 @@
|
||||
</div>
|
||||
|
||||
<script type="text/javascript" src="/layui/layui.js"></script>
|
||||
<script type="text/javascript" src="/userJs/users.js?v1.6"></script>
|
||||
<script type="text/javascript" src="/userJs/users.js?v2.0"></script>
|
@ -121,6 +121,9 @@ layui.config({
|
||||
|
||||
$(that.config.idDOM).val(ids.join(","));
|
||||
$(that.config.nameDOM).val(names.join(","));
|
||||
if(options.callback){
|
||||
options.callback(ids.join(","), names.join(","));
|
||||
}
|
||||
$(that.config.idDOM).change();
|
||||
if(flag){
|
||||
layer.close(index);
|
||||
@ -135,14 +138,17 @@ layui.config({
|
||||
text: 'Name',
|
||||
key: 'Id',
|
||||
parentKey: 'ParentId',
|
||||
callback:null, //选中后的回调
|
||||
selectedMulti: true //默认是多选
|
||||
|
||||
};
|
||||
|
||||
exports('droptree', function (url, name, id, selectedMulti) {
|
||||
exports('droptree', function (url, name, id, selectedMulti,callback) {
|
||||
var options = {
|
||||
nameDOM: name, //显示的文本框ID,如:"#catetoryName"
|
||||
idDOM: id, //隐藏的文本框,如:"#categoryId"
|
||||
url: url,
|
||||
callback:callback, //选中后的回调
|
||||
selectedMulti: selectedMulti //是否为多选
|
||||
}
|
||||
inst = new DropTree(options);
|
||||
|
@ -386,6 +386,10 @@ layui.define(['laypage', 'form'], function (exports) {
|
||||
var p = $('*[lay-filter='+ filter +']').next().find('.layui-iconpicker-item .layui-icon'),
|
||||
c = iconName;
|
||||
|
||||
if(c == undefined){
|
||||
return;
|
||||
}
|
||||
|
||||
if (c.indexOf('#xe') > 0){
|
||||
p.html(c);
|
||||
} else {
|
||||
|
@ -6,12 +6,57 @@ layui.config({
|
||||
$ = layui.jquery;
|
||||
var iconPicker = layui.iconPicker;
|
||||
var btnIconPicker = layui.iconPicker;
|
||||
var vmMenu = new Vue({
|
||||
el: "#mfromEdit",
|
||||
data(){
|
||||
return {
|
||||
tmp: {}
|
||||
}
|
||||
},
|
||||
watch:{
|
||||
tmp(val){
|
||||
this.$nextTick(function () {
|
||||
form.render(); //刷新select等
|
||||
btnIconPicker.checkIcon('btnIconPicker', this.tmp.Icon);
|
||||
})
|
||||
}
|
||||
},
|
||||
mounted(){
|
||||
form.render();
|
||||
}
|
||||
});
|
||||
var vmModule = new Vue({
|
||||
el: "#formEdit",
|
||||
data(){
|
||||
return {
|
||||
tmp: {} //使用一个tmp封装一下,后面可以直接用vm.tmp赋值
|
||||
}
|
||||
},
|
||||
watch:{
|
||||
tmp(val){
|
||||
this.$nextTick(function () {
|
||||
form.render(); //刷新select等
|
||||
layui.droptree("/UserSession/GetModules", "#ParentName", "#ParentId", false);
|
||||
|
||||
iconPicker.checkIcon('iconPicker', this.tmp.IconName);
|
||||
})
|
||||
}
|
||||
},
|
||||
mounted(){
|
||||
form.render();
|
||||
layui.droptree("/UserSession/GetModules", "#ParentName", "#ParentId", false);
|
||||
}
|
||||
});
|
||||
iconPicker.render({
|
||||
// 选择器,推荐使用input
|
||||
elem: '#IconName',
|
||||
type: 'fontClass',
|
||||
// 每个图标格子的宽度:'43px'或'20%'
|
||||
cellWidth: '43px',
|
||||
// 点击回调
|
||||
click: function (data) {
|
||||
vmModule.tmp.IconName = data.icon;
|
||||
}
|
||||
});
|
||||
btnIconPicker.render({ //按钮的图标
|
||||
// 选择器,推荐使用input
|
||||
@ -19,6 +64,10 @@ layui.config({
|
||||
type: 'fontClass',
|
||||
// 每个图标格子的宽度:'43px'或'20%'
|
||||
cellWidth: '43px',
|
||||
// 点击回调
|
||||
click: function (data) {
|
||||
vmMenu.tmp.Icon = data.icon;
|
||||
}
|
||||
});
|
||||
|
||||
var table = layui.table;
|
||||
@ -98,7 +147,6 @@ layui.config({
|
||||
$("#tree").height($("div.layui-table-view").height());
|
||||
//添加(编辑)模块对话框
|
||||
var editDlg = function() {
|
||||
var vm;
|
||||
var update = false; //是否为更新
|
||||
var show = function (data) {
|
||||
var title = update ? "编辑信息" : "添加";
|
||||
@ -108,34 +156,12 @@ layui.config({
|
||||
type: 1,
|
||||
content: $('#divEdit'),
|
||||
success: function() {
|
||||
if(vm == undefined){
|
||||
vm = new Vue({
|
||||
el: "#formEdit",
|
||||
data(){
|
||||
return {
|
||||
tmp:data //使用一个tmp封装一下,后面可以直接用vm.tmp赋值
|
||||
}
|
||||
},
|
||||
watch:{
|
||||
tmp(val){
|
||||
this.$nextTick(function () {
|
||||
form.render(); //刷新select等
|
||||
layui.droptree("/UserSession/GetModules", "#ParentName", "#ParentId", false);
|
||||
|
||||
iconPicker.checkIcon('iconPicker', this.tmp.IconName);
|
||||
})
|
||||
}
|
||||
},
|
||||
mounted(){
|
||||
form.render();
|
||||
layui.droptree("/UserSession/GetModules", "#ParentName", "#ParentId", false);
|
||||
|
||||
iconPicker.checkIcon('iconPicker', data.IconName);
|
||||
if(data.Id ==''){
|
||||
for(var key in vmModule.tmp){
|
||||
delete vmModule.tmp[key];
|
||||
}
|
||||
});
|
||||
}else{
|
||||
vm.tmp = Object.assign({}, vm.tmp,data)
|
||||
}
|
||||
}
|
||||
vmModule.tmp = Object.assign({}, vmModule.tmp,data)
|
||||
},
|
||||
end: mainList
|
||||
});
|
||||
@ -176,7 +202,6 @@ layui.config({
|
||||
|
||||
//添加菜单对话框
|
||||
var meditDlg = function () {
|
||||
var vm ;
|
||||
var update = false; //是否为更新
|
||||
var show = function (data) {
|
||||
var title = update ? "编辑信息" : "添加";
|
||||
@ -186,30 +211,12 @@ layui.config({
|
||||
type: 1,
|
||||
content: $('#divMenuEdit'),
|
||||
success: function () {
|
||||
if(vm == undefined){
|
||||
vm = new Vue({
|
||||
el: "#mfromEdit",
|
||||
data(){
|
||||
return {
|
||||
tmp:data //使用一个tmp封装一下,后面可以直接用vm.tmp赋值
|
||||
}
|
||||
},
|
||||
watch:{
|
||||
tmp(val){
|
||||
this.$nextTick(function () {
|
||||
form.render(); //刷新select等
|
||||
btnIconPicker.checkIcon('btnIconPicker', this.tmp.Icon);
|
||||
})
|
||||
}
|
||||
},
|
||||
mounted(){
|
||||
form.render();
|
||||
btnIconPicker.checkIcon('btnIconPicker', data.Icon);
|
||||
}
|
||||
});
|
||||
}else{
|
||||
vm.tmp = Object.assign({}, vm.tmp,data)
|
||||
}
|
||||
if(data.Id ==''){
|
||||
for(var key in vmMenu.tmp){
|
||||
delete vmMenu.tmp[key];
|
||||
}
|
||||
}
|
||||
vmMenu.tmp = Object.assign({}, vmMenu.tmp,data)
|
||||
},
|
||||
end: menuList
|
||||
});
|
||||
@ -235,7 +242,8 @@ layui.config({
|
||||
show({
|
||||
Id: "",
|
||||
ModuleId:moduleId,
|
||||
Sort: 1
|
||||
Sort: 1,
|
||||
Icon:'layui-icon-app'
|
||||
});
|
||||
},
|
||||
update: function (data) { //弹出编辑框
|
||||
|
@ -93,7 +93,11 @@
|
||||
},
|
||||
mounted(){
|
||||
form.render();
|
||||
layui.droptree("/UserSession/GetOrgs", "#ParentName", "#ParentId", false);
|
||||
var _this = this;
|
||||
layui.droptree("/UserSession/GetOrgs", "#ParentName", "#ParentId", false,function (ids, names) {
|
||||
_this.tmp.ParentId = ids;
|
||||
_this.tmp.ParentName = names;
|
||||
});
|
||||
|
||||
}
|
||||
});
|
||||
|
@ -90,13 +90,17 @@ layui.config({
|
||||
tmp(val){
|
||||
this.$nextTick(function () {
|
||||
form.render(); //刷新select等
|
||||
layui.droptree("/UserSession/GetOrgs", "#Organizations", "#OrganizationIds");
|
||||
//layui.droptree("/UserSession/GetOrgs", "#Organizations", "#OrganizationIds");
|
||||
})
|
||||
}
|
||||
},
|
||||
mounted(){
|
||||
form.render();
|
||||
layui.droptree("/UserSession/GetOrgs", "#Organizations", "#OrganizationIds");
|
||||
var _this = this;
|
||||
layui.droptree("/UserSession/GetOrgs", "#Organizations", "#OrganizationIds", true,function (ids, names) {
|
||||
_this.tmp.OrganizationIds = ids;
|
||||
_this.tmp.Organizations = names;
|
||||
});
|
||||
}
|
||||
});
|
||||
}else{
|
||||
|
@ -2,6 +2,7 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Linq;
|
||||
using System.Linq.Expressions;
|
||||
using System.Threading.Tasks;
|
||||
using Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using OpenAuth.Repository.Core;
|
||||
@ -29,7 +30,7 @@ namespace OpenAuth.Repository
|
||||
return Filter(exp);
|
||||
}
|
||||
|
||||
public bool IsExist(Expression<Func<T, bool>> exp)
|
||||
public bool Any(Expression<Func<T, bool>> exp)
|
||||
{
|
||||
return _context.Set<T>().Any(exp);
|
||||
}
|
||||
@ -37,7 +38,7 @@ namespace OpenAuth.Repository
|
||||
/// <summary>
|
||||
/// 查找单个,且不被上下文所跟踪
|
||||
/// </summary>
|
||||
public T FindSingle(Expression<Func<T, bool>> exp)
|
||||
public T FirstOrDefault(Expression<Func<T, bool>> exp)
|
||||
{
|
||||
return _context.Set<T>().AsNoTracking().FirstOrDefault(exp);
|
||||
}
|
||||
@ -61,7 +62,7 @@ namespace OpenAuth.Repository
|
||||
/// <summary>
|
||||
/// 根据过滤条件获取记录数
|
||||
/// </summary>
|
||||
public int GetCount(Expression<Func<T, bool>> exp = null)
|
||||
public int Count(Expression<Func<T, bool>> exp = null)
|
||||
{
|
||||
return Filter(exp).Count();
|
||||
}
|
||||
@ -116,7 +117,6 @@ namespace OpenAuth.Repository
|
||||
Save();
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 实现按需要只更新部分更新
|
||||
/// <para>如:Update(u =>u.Id==1,u =>new User{Name="ok"});</para>
|
||||
@ -169,7 +169,7 @@ namespace OpenAuth.Repository
|
||||
return dbSet;
|
||||
}
|
||||
|
||||
public int ExecuteSql(string sql)
|
||||
public int ExecuteSqlRaw(string sql)
|
||||
{
|
||||
return _context.Database.ExecuteSqlRaw(sql);
|
||||
}
|
||||
@ -193,5 +193,129 @@ namespace OpenAuth.Repository
|
||||
{
|
||||
return _context.Query<T>().FromSqlRaw(sql, parameters);
|
||||
}
|
||||
|
||||
#region 异步实现
|
||||
|
||||
/// <summary>
|
||||
/// 异步执行sql
|
||||
/// </summary>
|
||||
/// <param name="sql"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<int> ExecuteSqlRawAsync(string sql)
|
||||
{
|
||||
return await _context.Database.ExecuteSqlRawAsync(sql);
|
||||
}
|
||||
|
||||
public async Task<int> AddAsync(T entity)
|
||||
{
|
||||
if (entity.KeyIsNull())
|
||||
{
|
||||
entity.GenerateDefaultKeyVal();
|
||||
}
|
||||
|
||||
_context.Set<T>().Add(entity);
|
||||
return await SaveAsync();
|
||||
//_context.Entry(entity).State = EntityState.Detached;
|
||||
}
|
||||
|
||||
public async Task<int> BatchAddAsync(T[] entities)
|
||||
{
|
||||
foreach (var entity in entities)
|
||||
{
|
||||
if (entity.KeyIsNull())
|
||||
{
|
||||
entity.GenerateDefaultKeyVal();
|
||||
}
|
||||
}
|
||||
|
||||
await _context.Set<T>().AddRangeAsync(entities);
|
||||
return await SaveAsync();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 异步更新
|
||||
/// </summary>
|
||||
/// <param name="entity"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<int> UpdateAsync(T entity)
|
||||
{
|
||||
var entry = this._context.Entry(entity);
|
||||
entry.State = EntityState.Modified;
|
||||
|
||||
//如果数据没有发生变化
|
||||
if (!this._context.ChangeTracker.HasChanges())
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
return await SaveAsync();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 异步删除
|
||||
/// </summary>
|
||||
/// <param name="entity"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<int> DeleteAsync(T entity)
|
||||
{
|
||||
_context.Set<T>().Remove(entity);
|
||||
return await SaveAsync();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 异步保存
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
/// <exception cref="Exception"></exception>
|
||||
public async Task<int> SaveAsync()
|
||||
{
|
||||
try
|
||||
{
|
||||
var entities = _context.ChangeTracker.Entries()
|
||||
.Where(e => e.State == EntityState.Added
|
||||
|| e.State == EntityState.Modified)
|
||||
.Select(e => e.Entity);
|
||||
|
||||
foreach (var entity in entities)
|
||||
{
|
||||
var validationContext = new ValidationContext(entity);
|
||||
Validator.ValidateObject(entity, validationContext, validateAllProperties: true);
|
||||
}
|
||||
|
||||
return await _context.SaveChangesAsync();
|
||||
}
|
||||
catch (ValidationException exc)
|
||||
{
|
||||
Console.WriteLine($"{nameof(Save)} validation exception: {exc?.Message}");
|
||||
throw (exc.InnerException as Exception ?? exc);
|
||||
}
|
||||
catch (Exception ex) //DbUpdateException
|
||||
{
|
||||
throw (ex.InnerException as Exception ?? ex);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 根据过滤条件获取记录数
|
||||
/// </summary>
|
||||
public async Task<int> CountAsync(Expression<Func<T, bool>> exp = null)
|
||||
{
|
||||
return await Filter(exp).CountAsync();
|
||||
}
|
||||
|
||||
public async Task<bool> AnyAsync(Expression<Func<T, bool>> exp)
|
||||
{
|
||||
return await _context.Set<T>().AnyAsync(exp);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查找单个,且不被上下文所跟踪
|
||||
/// </summary>
|
||||
public async Task<T> FirstOrDefaultAsync(Expression<Func<T, bool>> exp)
|
||||
{
|
||||
return await _context.Set<T>().AsNoTracking().FirstOrDefaultAsync(exp);
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
@ -15,29 +15,30 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Linq.Expressions;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace OpenAuth.Repository.Interface
|
||||
{
|
||||
public interface IRepository<T> where T : class
|
||||
{
|
||||
T FindSingle(Expression<Func<T, bool>> exp = null);
|
||||
bool IsExist(Expression<Func<T, bool>> exp);
|
||||
/// <summary>
|
||||
/// 返回一个单独的实体,如果记录多于1个则取第一个
|
||||
/// </summary>
|
||||
T FirstOrDefault(Expression<Func<T, bool>> exp = null);
|
||||
/// <summary>
|
||||
/// 判断指定条件的记录是否存在
|
||||
/// </summary>
|
||||
bool Any(Expression<Func<T, bool>> exp);
|
||||
IQueryable<T> Find(Expression<Func<T, bool>> exp = null);
|
||||
|
||||
IQueryable<T> Find(int pageindex = 1, int pagesize = 10, string orderby = "",
|
||||
Expression<Func<T, bool>> exp = null);
|
||||
|
||||
int GetCount(Expression<Func<T, bool>> exp = null);
|
||||
|
||||
int Count(Expression<Func<T, bool>> exp = null);
|
||||
void Add(T entity);
|
||||
|
||||
void BatchAdd(T[] entities);
|
||||
|
||||
/// <summary>
|
||||
/// 更新一个实体的所有属性
|
||||
/// </summary>
|
||||
void Update(T entity);
|
||||
|
||||
void Delete(T entity);
|
||||
|
||||
|
||||
@ -48,6 +49,7 @@ namespace OpenAuth.Repository.Interface
|
||||
/// <param name="where">更新条件</param>
|
||||
/// <param name="entity">更新后的实体</param>
|
||||
void Update(Expression<Func<T, bool>> where, Expression<Func<T, T>> entity);
|
||||
|
||||
/// <summary>
|
||||
/// 批量删除
|
||||
/// </summary>
|
||||
@ -55,19 +57,35 @@ namespace OpenAuth.Repository.Interface
|
||||
|
||||
void Save();
|
||||
|
||||
int ExecuteSql(string sql);
|
||||
int ExecuteSqlRaw(string sql);
|
||||
|
||||
/// <summary>
|
||||
/// <summary>
|
||||
/// 使用SQL脚本查询
|
||||
/// </summary>
|
||||
/// <typeparam name="T"> T为数据库实体</typeparam>
|
||||
/// <returns></returns>
|
||||
IQueryable<T> FromSql(string sql, params object[] parameters);
|
||||
/// <summary>
|
||||
/// 使用SQL脚本查询
|
||||
/// </summary>
|
||||
/// <typeparam name="T"> T为非数据库实体,需要在DbContext中增加对应的DbQuery</typeparam>
|
||||
/// <returns></returns>
|
||||
|
||||
/// <summary>
|
||||
/// 使用SQL脚本查询
|
||||
/// </summary>
|
||||
/// <typeparam name="T"> T为非数据库实体,需要在DbContext中增加对应的DbQuery</typeparam>
|
||||
/// <returns></returns>
|
||||
IQueryable<T> Query(string sql, params object[] parameters);
|
||||
|
||||
|
||||
#region 异步接口
|
||||
|
||||
Task<int> ExecuteSqlRawAsync(string sql);
|
||||
Task<int> AddAsync(T entity);
|
||||
Task<int> BatchAddAsync(T[] entities);
|
||||
Task<int> UpdateAsync(T entity);
|
||||
Task<int> DeleteAsync(T entity);
|
||||
Task<int> SaveAsync();
|
||||
Task<int> CountAsync(Expression<Func<T, bool>> exp = null);
|
||||
Task<bool> AnyAsync(Expression<Func<T, bool>> exp);
|
||||
Task<T> FirstOrDefaultAsync(Expression<Func<T, bool>> exp);
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
@ -4,7 +4,7 @@
|
||||
// Created : 04-29-2016
|
||||
//
|
||||
// Last Modified By : yubaolee
|
||||
// Last Modified On : 04-29-2016
|
||||
// Last Modified On : 12-15-2020
|
||||
// Contact : Microsoft
|
||||
// File: IUnitWork.cs
|
||||
// ***********************************************************************
|
||||
@ -12,12 +12,14 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Linq.Expressions;
|
||||
using System.Threading.Tasks;
|
||||
using OpenAuth.Repository.Core;
|
||||
|
||||
namespace OpenAuth.Repository.Interface
|
||||
{
|
||||
/// <summary>
|
||||
/// 工作单元接口
|
||||
/// 使用详见:http://doc.openauth.me/core/unitwork.html
|
||||
/// <para> 适合在一下情况使用:</para>
|
||||
/// <para>1 在同一事务中进行多表操作</para>
|
||||
/// <para>2 需要多表联合查询</para>
|
||||
@ -25,18 +27,39 @@ namespace OpenAuth.Repository.Interface
|
||||
/// </summary>
|
||||
public interface IUnitWork
|
||||
{
|
||||
/// <summary>
|
||||
/// EF默认情况下,每调用一次SaveChanges()都会执行一个单独的事务
|
||||
/// 本接口实现在一个事务中可以多次执行SaveChanges()方法
|
||||
/// </summary>
|
||||
void ExecuteWithTransaction(Action action);
|
||||
/// <summary>
|
||||
/// 返回DbContext,用于多线程等极端情况
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
OpenAuthDBContext GetDbContext();
|
||||
T FindSingle<T>(Expression<Func<T, bool>> exp = null) where T:class;
|
||||
bool IsExist<T>(Expression<Func<T, bool>> exp) where T:class;
|
||||
/// <summary>
|
||||
/// 返回一个单独的实体,如果记录多于1个则取第一个
|
||||
/// </summary>
|
||||
T FirstOrDefault<T>(Expression<Func<T, bool>> exp = null) where T:class;
|
||||
/// <summary>
|
||||
/// 判断指定条件的记录是否存在
|
||||
/// </summary>
|
||||
bool Any<T>(Expression<Func<T, bool>> exp) where T:class;
|
||||
IQueryable<T> Find<T>(Expression<Func<T, bool>> exp = null) where T:class;
|
||||
|
||||
IQueryable<T> Find<T>(int pageindex = 1, int pagesize = 10, string orderby = "",
|
||||
Expression<Func<T, bool>> exp = null) where T:class;
|
||||
|
||||
int GetCount<T>(Expression<Func<T, bool>> exp = null) where T:class;
|
||||
int Count<T>(Expression<Func<T, bool>> exp = null) where T:class;
|
||||
|
||||
/// <summary>
|
||||
/// 新增对象,如果Id为空,则会自动创建默认Id
|
||||
/// </summary>
|
||||
void Add<T>(T entity) where T:BaseEntity;
|
||||
|
||||
/// <summary>
|
||||
/// 批量新增对象,如果对象Id为空,则会自动创建默认Id
|
||||
/// </summary>
|
||||
void BatchAdd<T>(T[] entities) where T:BaseEntity;
|
||||
|
||||
/// <summary>
|
||||
@ -49,18 +72,25 @@ namespace OpenAuth.Repository.Interface
|
||||
|
||||
/// <summary>
|
||||
/// 实现按需要只更新部分更新
|
||||
/// <para>如:Update<T>(u =>u.Id==1,u =>new User{Name="ok"}) where T:class;</para>
|
||||
/// <para>如:Update<User>(u =>u.Id==1,u =>new User{Name="ok"})</para>
|
||||
/// <para>该方法内部自动调用了SaveChanges(),需要ExecuteWithTransaction配合才能实现事务控制</para>
|
||||
/// </summary>
|
||||
/// <param name="where">更新条件</param>
|
||||
/// <param name="entity">更新后的实体</param>
|
||||
void Update<T>(Expression<Func<T, bool>> where, Expression<Func<T, T>> entity) where T:class;
|
||||
/// <summary>
|
||||
/// 批量删除
|
||||
/// <para>该方法内部自动调用了SaveChanges(),需要ExecuteWithTransaction配合才能实现事务控制</para>
|
||||
/// </summary>
|
||||
void Delete<T>(Expression<Func<T, bool>> exp) where T:class;
|
||||
|
||||
void Save();
|
||||
|
||||
/// <summary>
|
||||
/// 该方法不支持EF自带的事务,需要ExecuteWithTransaction配合才能实现事务控制,详见:http://doc.openauth.me/core/unitwork.html
|
||||
/// </summary>
|
||||
/// <param name="sql"></param>
|
||||
/// <returns></returns>
|
||||
int ExecuteSql(string sql);
|
||||
|
||||
/// <summary>
|
||||
@ -75,5 +105,15 @@ namespace OpenAuth.Repository.Interface
|
||||
/// <typeparam name="T"> T为非数据库实体,需要在DbContext中增加对应的DbQuery</typeparam>
|
||||
/// <returns></returns>
|
||||
IQueryable<T> Query<T>(string sql, params object[] parameters) where T : class;
|
||||
|
||||
#region 异步接口
|
||||
|
||||
Task<int> ExecuteSqlRawAsync(string sql);
|
||||
Task<int> SaveAsync();
|
||||
Task<int> CountAsync<T>(Expression<Func<T, bool>> exp = null) where T : class;
|
||||
Task<bool> AnyAsync<T>(Expression<Func<T, bool>> exp) where T : class;
|
||||
Task<T> FirstOrDefaultAsync<T>(Expression<Func<T, bool>> exp) where T : class;
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
@ -8,6 +8,10 @@ using OpenAuth.Repository.Interface;
|
||||
|
||||
namespace OpenAuth.Repository.Test
|
||||
{
|
||||
/// <summary>
|
||||
/// Repository测试基类
|
||||
/// 测试用于测试DbContext、UnitWork、Repository,如果需要测试业务逻辑,请使用OpenAuth.App里面的单元测试
|
||||
/// </summary>
|
||||
public class TestBase
|
||||
{
|
||||
protected AutofacServiceProvider _autofacServiceProvider;
|
||||
@ -19,6 +23,7 @@ namespace OpenAuth.Repository.Test
|
||||
serviceCollection.AddMemoryCache();
|
||||
serviceCollection.AddOptions();
|
||||
serviceCollection.AddScoped(typeof(IRepository<>), typeof(BaseRepository<>));
|
||||
serviceCollection.AddScoped(typeof(IUnitWork), typeof(UnitWork));
|
||||
|
||||
serviceCollection.AddDbContext<OpenAuthDBContext>(options =>
|
||||
options.UseSqlServer("Data Source=.;Initial Catalog=OpenAuthDB;User=sa;Password=000000;Integrated Security=True"));
|
||||
@ -28,7 +33,6 @@ namespace OpenAuth.Repository.Test
|
||||
//注册repository层
|
||||
builder.RegisterAssemblyTypes(Assembly.GetExecutingAssembly());
|
||||
|
||||
// builder.RegisterGeneric(typeof(BaseRepository<>)).As(typeof(IRepository<>)).PropertiesAutowired();
|
||||
builder.Populate(serviceCollection);
|
||||
|
||||
var _container = builder.Build();
|
||||
|
@ -94,24 +94,24 @@ namespace OpenAuth.Repository.Test
|
||||
Id = id
|
||||
});
|
||||
|
||||
var user = repository.FindSingle(u => u.Id == id);
|
||||
var user = repository.FirstOrDefault(u => u.Id == id);
|
||||
Assert.NotNull(user);
|
||||
|
||||
//修改一个实体
|
||||
account = "newuser_" + DateTime.Now.ToString("yyyy_MM_dd HH:mm:ss");
|
||||
user.Account = account;
|
||||
repository.Update(user);
|
||||
var newuser = repository.FindSingle(u => u.Account == account);
|
||||
var newuser = repository.FirstOrDefault(u => u.Account == account);
|
||||
Assert.NotNull(newuser);
|
||||
|
||||
//批量修改
|
||||
repository.Update(u => u.Id == id, u =>new User{ Name = account});
|
||||
newuser = repository.FindSingle(u => u.Name == account);
|
||||
newuser = repository.FirstOrDefault(u => u.Name == account);
|
||||
Assert.NotNull(newuser);
|
||||
|
||||
//删除
|
||||
repository.Delete(u =>u.Id == id);
|
||||
newuser = repository.FindSingle(u => u.Id == id);
|
||||
newuser = repository.FirstOrDefault(u => u.Id == id);
|
||||
Assert.IsNull(newuser);
|
||||
}
|
||||
}
|
||||
|
86
OpenAuth.Repository/Test/TestTransaction.cs
Normal file
86
OpenAuth.Repository/Test/TestTransaction.cs
Normal file
@ -0,0 +1,86 @@
|
||||
using System;
|
||||
using NUnit.Framework;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using OpenAuth.Repository.Domain;
|
||||
using OpenAuth.Repository.Interface;
|
||||
|
||||
namespace OpenAuth.Repository.Test
|
||||
{
|
||||
/// <summary>
|
||||
/// 测试事务
|
||||
/// </summary>
|
||||
class TestTransaction : TestBase
|
||||
{
|
||||
/// <summary>
|
||||
/// 测试事务正常提交
|
||||
/// </summary>
|
||||
[Test]
|
||||
public void NormalSubmit()
|
||||
{
|
||||
var unitWork = _autofacServiceProvider.GetService<IUnitWork>();
|
||||
unitWork.ExecuteWithTransaction(() =>
|
||||
{
|
||||
var account = "user_" + DateTime.Now.ToString("yyyy_MM_dd HH:mm:ss");
|
||||
|
||||
AddAndUpdate(account, unitWork);
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 测试事务回滚
|
||||
/// </summary>
|
||||
[Test]
|
||||
public void SubmitWithRollback()
|
||||
{
|
||||
var unitWork = _autofacServiceProvider.GetService<IUnitWork>();
|
||||
var account = "user_" + DateTime.Now.ToString("yyyy_MM_dd HH:mm:ss");
|
||||
try
|
||||
{
|
||||
unitWork.ExecuteWithTransaction(() =>
|
||||
{
|
||||
AddAndUpdate(account, unitWork);
|
||||
|
||||
throw new Exception("模拟异常");
|
||||
});
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Console.WriteLine(e);
|
||||
}
|
||||
|
||||
//如果没有插入成功,表示事务发生了回滚
|
||||
Assert.IsFalse(unitWork.Any<User>( u=>u.Id == account));
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 测试添加,单个修改,Z.EntityFramework.Plus条件修改
|
||||
/// </summary>
|
||||
private void AddAndUpdate(string account, IUnitWork unitWork)
|
||||
{
|
||||
var user = new User
|
||||
{
|
||||
Id = account,
|
||||
Account = account,
|
||||
Name = account,
|
||||
};
|
||||
|
||||
unitWork.Add(user);
|
||||
|
||||
unitWork.Save();
|
||||
|
||||
|
||||
user.Account = "Trans_" + user.Account;
|
||||
user.Name = "Trans_" + user.Name;
|
||||
unitWork.Update(user);
|
||||
|
||||
unitWork.Save();
|
||||
|
||||
unitWork.Update<User>(u => u.Id == account, u => new User
|
||||
{
|
||||
Account = "Trans2_" + user.Account
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
@ -2,8 +2,10 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Linq;
|
||||
using System.Linq.Expressions;
|
||||
using System.Threading.Tasks;
|
||||
using Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Storage;
|
||||
using OpenAuth.Repository.Core;
|
||||
using OpenAuth.Repository.Interface;
|
||||
using Z.EntityFramework.Plus;
|
||||
@ -18,6 +20,31 @@ namespace OpenAuth.Repository
|
||||
{
|
||||
_context = context;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// EF默认情况下,每调用一次SaveChanges()都会执行一个单独的事务
|
||||
/// 本接口实现在一个事务中可以多次执行SaveChanges()方法
|
||||
/// </summary>
|
||||
public void ExecuteWithTransaction(Action action)
|
||||
{
|
||||
using (IDbContextTransaction transaction = _context.Database.BeginTransaction())
|
||||
{
|
||||
try
|
||||
{
|
||||
action();
|
||||
transaction.Commit();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
transaction.Rollback();
|
||||
throw ex;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 返回DbContext,用于多线程等极端情况
|
||||
/// </summary>
|
||||
public OpenAuthDBContext GetDbContext()
|
||||
{
|
||||
return _context;
|
||||
@ -32,7 +59,7 @@ namespace OpenAuth.Repository
|
||||
return Filter(exp);
|
||||
}
|
||||
|
||||
public bool IsExist<T>(Expression<Func<T, bool>> exp) where T : class
|
||||
public bool Any<T>(Expression<Func<T, bool>> exp) where T : class
|
||||
{
|
||||
return _context.Set<T>().Any(exp);
|
||||
}
|
||||
@ -40,7 +67,7 @@ namespace OpenAuth.Repository
|
||||
/// <summary>
|
||||
/// 查找单个
|
||||
/// </summary>
|
||||
public T FindSingle<T>(Expression<Func<T, bool>> exp) where T:class
|
||||
public T FirstOrDefault<T>(Expression<Func<T, bool>> exp) where T:class
|
||||
{
|
||||
return _context.Set<T>().AsNoTracking().FirstOrDefault(exp);
|
||||
}
|
||||
@ -63,11 +90,14 @@ namespace OpenAuth.Repository
|
||||
/// <summary>
|
||||
/// 根据过滤条件获取记录数
|
||||
/// </summary>
|
||||
public int GetCount<T>(Expression<Func<T, bool>> exp = null) where T : class
|
||||
public int Count<T>(Expression<Func<T, bool>> exp = null) where T : class
|
||||
{
|
||||
return Filter(exp).Count();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 新增对象,如果Id为空,则会自动创建默认Id
|
||||
/// </summary>
|
||||
public void Add<T>(T entity) where T : BaseEntity
|
||||
{
|
||||
if (entity.KeyIsNull())
|
||||
@ -78,9 +108,8 @@ namespace OpenAuth.Repository
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 批量添加
|
||||
/// 批量新增对象,如果对象Id为空,则会自动创建默认Id
|
||||
/// </summary>
|
||||
/// <param name="entities">The entities.</param>
|
||||
public void BatchAdd<T>(T[] entities) where T : BaseEntity
|
||||
{
|
||||
foreach (var entity in entities)
|
||||
@ -113,18 +142,23 @@ namespace OpenAuth.Repository
|
||||
|
||||
/// <summary>
|
||||
/// 实现按需要只更新部分更新
|
||||
/// <para>如:Update(u =>u.Id==1,u =>new User{Name="ok"});</para>
|
||||
/// <para>如:Update<User>(u =>u.Id==1,u =>new User{Name="ok"})</para>
|
||||
/// <para>该方法内部自动调用了SaveChanges(),需要ExecuteWithTransaction配合才能实现事务控制</para>
|
||||
/// </summary>
|
||||
/// <param name="where">The where.</param>
|
||||
/// <param name="entity">The entity.</param>
|
||||
/// <param name="where">更新条件</param>
|
||||
/// <param name="entity">更新后的实体</param>
|
||||
public void Update<T>(Expression<Func<T, bool>> where, Expression<Func<T, T>> entity) where T:class
|
||||
{
|
||||
_context.Set<T>().Where(where).Update(entity);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 批量删除
|
||||
/// <para>该方法内部自动调用了SaveChanges(),需要ExecuteWithTransaction配合才能实现事务控制</para>
|
||||
/// </summary>
|
||||
public virtual void Delete<T>(Expression<Func<T, bool>> exp) where T : class
|
||||
{
|
||||
_context.Set<T>().RemoveRange(Filter(exp));
|
||||
_context.Set<T>().Where(exp).Delete();
|
||||
}
|
||||
|
||||
public void Save()
|
||||
@ -178,5 +212,74 @@ namespace OpenAuth.Repository
|
||||
{
|
||||
return _context.Query<T>().FromSqlRaw(sql, parameters);
|
||||
}
|
||||
|
||||
#region 异步实现
|
||||
|
||||
/// <summary>
|
||||
/// 异步执行sql
|
||||
/// </summary>
|
||||
/// <param name="sql"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<int> ExecuteSqlRawAsync(string sql)
|
||||
{
|
||||
return await _context.Database.ExecuteSqlRawAsync(sql);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 异步保存
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
/// <exception cref="Exception"></exception>
|
||||
public async Task<int> SaveAsync()
|
||||
{
|
||||
try
|
||||
{
|
||||
var entities = _context.ChangeTracker.Entries()
|
||||
.Where(e => e.State == EntityState.Added
|
||||
|| e.State == EntityState.Modified)
|
||||
.Select(e => e.Entity);
|
||||
|
||||
foreach (var entity in entities)
|
||||
{
|
||||
var validationContext = new ValidationContext(entity);
|
||||
Validator.ValidateObject(entity, validationContext, validateAllProperties: true);
|
||||
}
|
||||
|
||||
return await _context.SaveChangesAsync();
|
||||
}
|
||||
catch (ValidationException exc)
|
||||
{
|
||||
Console.WriteLine($"{nameof(Save)} validation exception: {exc?.Message}");
|
||||
throw (exc.InnerException as Exception ?? exc);
|
||||
}
|
||||
catch (Exception ex) //DbUpdateException
|
||||
{
|
||||
throw (ex.InnerException as Exception ?? ex);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 根据过滤条件获取记录数
|
||||
/// </summary>
|
||||
public async Task<int> CountAsync<T>(Expression<Func<T, bool>> exp = null) where T : class
|
||||
{
|
||||
return await Filter(exp).CountAsync();
|
||||
}
|
||||
|
||||
public async Task<bool> AnyAsync<T>(Expression<Func<T, bool>> exp) where T : class
|
||||
{
|
||||
return await _context.Set<T>().AnyAsync(exp);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查找单个,且不被上下文所跟踪
|
||||
/// </summary>
|
||||
public async Task<T> FirstOrDefaultAsync<T>(Expression<Func<T, bool>> exp) where T : class
|
||||
{
|
||||
return await _context.Set<T>().AsNoTracking().FirstOrDefaultAsync(exp);
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,5 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using OpenAuth.App;
|
||||
using OpenAuth.App.Request;
|
||||
using OpenAuth.App.Response;
|
||||
@ -23,9 +24,9 @@ namespace OpenAuth.WebApi.Controllers
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpGet]
|
||||
public TableData Load([FromQuery]QueryAppListReq request)
|
||||
public async Task<TableData> Load([FromQuery]QueryAppListReq request)
|
||||
{
|
||||
var applications = _app.GetList(request);
|
||||
var applications =await _app.GetList(request);
|
||||
return new TableData
|
||||
{
|
||||
data = applications,
|
||||
|
@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using Infrastructure;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using OpenAuth.App;
|
||||
@ -59,9 +60,10 @@ namespace OpenAuth.WebApi.Controllers
|
||||
/// 加载列表
|
||||
/// </summary>
|
||||
[HttpGet]
|
||||
public TableResp<BuilderTableColumn> Load([FromQuery]QueryBuilderTableColumnListReq request)
|
||||
public async Task<TableResp<BuilderTableColumn>> Load([FromQuery]QueryBuilderTableColumnListReq request)
|
||||
{
|
||||
return _app.Load(request);
|
||||
var tableResp = await _app.Load(request);
|
||||
return tableResp;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using Infrastructure;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using OpenAuth.App;
|
||||
@ -67,9 +68,9 @@ namespace OpenAuth.WebApi.Controllers
|
||||
/// 加载列表
|
||||
/// </summary>
|
||||
[HttpGet]
|
||||
public TableResp<BuilderTable> Load([FromQuery]QueryBuilderTableListReq request)
|
||||
public async Task<TableResp<BuilderTable>> Load([FromQuery]QueryBuilderTableListReq request)
|
||||
{
|
||||
return _app.Load(request);
|
||||
return await _app.Load(request);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using Infrastructure;
|
||||
using System.Threading.Tasks;
|
||||
using Infrastructure;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using OpenAuth.App;
|
||||
using OpenAuth.App.Request;
|
||||
@ -58,9 +59,9 @@ using OpenAuth.App.Response;
|
||||
/// 加载列表
|
||||
/// </summary>
|
||||
[HttpGet]
|
||||
public TableData Load([FromQuery]QueryCategoryTypeListReq request)
|
||||
public async Task<TableData> Load([FromQuery]QueryCategoryTypeListReq request)
|
||||
{
|
||||
return _app.Load(request);
|
||||
return await _app.Load(request);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using Infrastructure;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using OpenAuth.App;
|
||||
@ -87,9 +88,9 @@ namespace OpenAuth.WebApi.Controllers
|
||||
/// 加载列表
|
||||
/// </summary>
|
||||
[HttpGet]
|
||||
public TableData Load([FromQuery]QueryCategoryListReq request)
|
||||
public async Task<TableData> Load([FromQuery]QueryCategoryListReq request)
|
||||
{
|
||||
return _app.Load(request);
|
||||
return await _app.Load(request);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using Infrastructure;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using OpenAuth.App;
|
||||
@ -86,9 +87,9 @@ namespace OpenAuth.WebApi.Controllers
|
||||
/// 加载列表
|
||||
/// </summary>
|
||||
[HttpGet]
|
||||
public TableData Load([FromQuery]QueryDataPrivilegeRuleListReq request)
|
||||
public async Task<TableData> Load([FromQuery]QueryDataPrivilegeRuleListReq request)
|
||||
{
|
||||
return _app.Load(request);
|
||||
return await _app.Load(request);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -7,6 +7,7 @@
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using Infrastructure;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using OpenAuth.App;
|
||||
@ -128,9 +129,9 @@ namespace OpenAuth.WebApi.Controllers
|
||||
/// 加载列表
|
||||
/// </summary>
|
||||
[HttpGet]
|
||||
public TableData Load([FromQuery]QueryFlowInstanceListReq request)
|
||||
public async Task<TableData> Load([FromQuery]QueryFlowInstanceListReq request)
|
||||
{
|
||||
return _app.Load(request);
|
||||
return await _app.Load(request);
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
|
@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using Infrastructure;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using OpenAuth.App;
|
||||
@ -76,9 +77,9 @@ namespace OpenAuth.WebApi.Controllers
|
||||
/// 加载列表
|
||||
/// </summary>
|
||||
[HttpGet]
|
||||
public TableData Load([FromQuery]QueryFlowSchemeListReq request)
|
||||
public async Task<TableData> Load([FromQuery]QueryFlowSchemeListReq request)
|
||||
{
|
||||
return _app.Load(request);
|
||||
return await _app.Load(request);
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
|
@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using Infrastructure;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using OpenAuth.App;
|
||||
@ -76,9 +77,9 @@ namespace OpenAuth.WebApi.Controllers
|
||||
/// 加载列表
|
||||
/// </summary>
|
||||
[HttpGet]
|
||||
public TableData Load([FromQuery]QueryFormListReq request)
|
||||
public async Task<TableData> Load([FromQuery]QueryFormListReq request)
|
||||
{
|
||||
return _app.Load(request);
|
||||
return await _app.Load(request);
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
|
@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using Infrastructure;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using OpenAuth.App;
|
||||
@ -87,9 +88,9 @@ namespace OpenAuth.WebApi.Controllers
|
||||
/// 加载列表
|
||||
/// </summary>
|
||||
[HttpGet]
|
||||
public TableData Load([FromQuery]QueryOpenJobListReq request)
|
||||
public async Task<TableData> Load([FromQuery]QueryOpenJobListReq request)
|
||||
{
|
||||
return _app.Load(request);
|
||||
return await _app.Load(request);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -1,6 +1,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Infrastructure;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using OpenAuth.App;
|
||||
@ -25,9 +26,9 @@ namespace OpenAuth.WebApi.Controllers
|
||||
_app = app;
|
||||
}
|
||||
[HttpGet]
|
||||
public TableData Load([FromQuery]QueryResourcesReq request)
|
||||
public async Task<TableData> Load([FromQuery]QueryResourcesReq request)
|
||||
{
|
||||
return _app.Load(request);
|
||||
return await _app.Load(request);
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
|
@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using Infrastructure;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using OpenAuth.App;
|
||||
@ -81,9 +82,9 @@ namespace OpenAuth.WebApi.Controllers
|
||||
/// 加载列表
|
||||
/// </summary>
|
||||
[HttpGet]
|
||||
public TableData Load([FromQuery]QuerySysLogListReq request)
|
||||
public async Task<TableData> Load([FromQuery]QuerySysLogListReq request)
|
||||
{
|
||||
return _app.Load(request);
|
||||
return await _app.Load(request);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using Infrastructure;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using OpenAuth.App;
|
||||
@ -77,9 +78,9 @@ namespace OpenAuth.WebApi.Controllers
|
||||
/// 加载列表
|
||||
/// </summary>
|
||||
[HttpGet]
|
||||
public TableData Load([FromQuery]QuerySysMessageListReq request)
|
||||
public async Task<TableData> Load([FromQuery]QuerySysMessageListReq request)
|
||||
{
|
||||
return _app.Load(request);
|
||||
return await _app.Load(request);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using Infrastructure;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using OpenAuth.App;
|
||||
@ -104,9 +105,9 @@ namespace OpenAuth.WebApi.Controllers
|
||||
/// 获取当前登录用户可访问的一个部门及子部门全部用户
|
||||
/// </summary>
|
||||
[HttpGet]
|
||||
public TableData Load([FromQuery]QueryUserListReq request)
|
||||
public async Task<TableData> Load([FromQuery]QueryUserListReq request)
|
||||
{
|
||||
return _app.Load(request);
|
||||
return await _app.Load(request);
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
@ -131,9 +132,9 @@ namespace OpenAuth.WebApi.Controllers
|
||||
/// 加载指定角色的用户
|
||||
/// </summary>
|
||||
[HttpGet]
|
||||
public TableData LoadByRole([FromQuery]QueryUserListByRoleReq request)
|
||||
public async Task<TableData> LoadByRole([FromQuery]QueryUserListByRoleReq request)
|
||||
{
|
||||
return _app.LoadByRole(request);
|
||||
return await _app.LoadByRole(request);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -141,9 +142,9 @@ namespace OpenAuth.WebApi.Controllers
|
||||
/// 不包含下级部门的用户
|
||||
/// </summary>
|
||||
[HttpGet]
|
||||
public TableData LoadByOrg([FromQuery]QueryUserListByOrgReq request)
|
||||
public async Task<TableData> LoadByOrg([FromQuery]QueryUserListByOrgReq request)
|
||||
{
|
||||
return _app.LoadByOrg(request);
|
||||
return await _app.LoadByOrg(request);
|
||||
}
|
||||
|
||||
public UsersController(UserManagerApp app)
|
||||
|
@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using Infrastructure;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
@ -83,9 +84,9 @@ namespace OpenAuth.WebApi.Controllers
|
||||
/// </summary>
|
||||
[HttpGet]
|
||||
[AllowAnonymous]
|
||||
public TableData Load([FromQuery]QueryWmsInboundOrderDtblListReq request)
|
||||
public async Task<TableData> Load([FromQuery]QueryWmsInboundOrderDtblListReq request)
|
||||
{
|
||||
return _app.Load(request);
|
||||
return await _app.Load(request);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using Infrastructure;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using OpenAuth.App;
|
||||
@ -88,9 +89,9 @@ namespace OpenAuth.WebApi.Controllers
|
||||
/// 加载列表
|
||||
/// </summary>
|
||||
[HttpGet]
|
||||
public TableData Load([FromQuery]QueryWmsInboundOrderTblListReq request)
|
||||
public async Task<TableData> Load([FromQuery]QueryWmsInboundOrderTblListReq request)
|
||||
{
|
||||
return _app.Load(request);
|
||||
return await _app.Load(request);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -16,7 +16,7 @@ namespace OpenAuth.App
|
||||
/// <summary>
|
||||
/// 加载列表
|
||||
/// </summary>
|
||||
public TableData Load(Query{ClassName}ListReq request)
|
||||
public async Task<TableData> Load(Query{ClassName}ListReq request)
|
||||
{
|
||||
var loginContext = _auth.GetCurrentUser();
|
||||
if (loginContext == null)
|
||||
@ -35,7 +35,7 @@ namespace OpenAuth.App
|
||||
var objs = GetDataPrivilege("u");
|
||||
if (!string.IsNullOrEmpty(request.key))
|
||||
{
|
||||
objs = objs.Where(u => u.Name.Contains(request.key) || u.Id.Contains(request.key));
|
||||
objs = objs.Where(u => u.Id.Contains(request.key));
|
||||
}
|
||||
|
||||
var propertyStr = string.Join(',', properties.Select(u => u.Key));
|
||||
|
@ -77,9 +77,9 @@ namespace OpenAuth.WebApi.Controllers
|
||||
/// 加载列表
|
||||
/// </summary>
|
||||
[HttpGet]
|
||||
public TableData Load([FromQuery]Query{ClassName}ListReq request)
|
||||
public async Task<TableData> Load([FromQuery]Query{ClassName}ListReq request)
|
||||
{
|
||||
return _app.Load(request);
|
||||
return await _app.Load(request);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -1,6 +1,6 @@
|
||||
## ❤❤❤郑重声明❤❤❤
|
||||
|
||||
已成功在.Net SDK 5.0.100-rc.2.20479.15 运行
|
||||
主分支main运行环境为 **.Net SDK 5.0.100**
|
||||
|
||||
需要.Net 4.0/4.5开发环境的同学请查看本项目4.0分支
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
{
|
||||
"sdk": {
|
||||
"version": "5.0.100-rc.2.20479.15"
|
||||
"version": "5.0.100"
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user