sync with OpenAuth.Core

This commit is contained in:
yubaolee 2020-12-20 23:14:09 +08:00
parent 7217e7a924
commit 7540baa322
25 changed files with 347 additions and 169 deletions

View File

@ -2,76 +2,49 @@
// Copyright (c) 2019 openauth.me. All rights reserved. // Copyright (c) 2019 openauth.me. All rights reserved.
// </copyright> // </copyright>
// <author>www.cnblogs.com/yubaolee</author> // <author>www.cnblogs.com/yubaolee</author>
// <date>2019-03-07</date>
// <summary>生成缩略图</summary> // <summary>生成缩略图</summary>
using SixLabors.ImageSharp;
using SixLabors.ImageSharp.Processing;
namespace Infrastructure.Helpers namespace Infrastructure.Helpers
{ {
public class ImgHelper public class ImgHelper
{ {
//MakeThumbnail(path, tpath, 120, 90, "H"); /// <summary>
public static void MakeThumbnail(string originalImagePath, /// 根据已有图片生成缩略图
/// <para>用法MakeThumbnail(path, tpath, 120, 90, "H");</para>
/// </summary>
/// <param name="originalImagePath">源图片路径</param>
/// <param name="thumbnailPath">缩略图保存路径</param>
/// <param name="width">缩略图的宽度</param>
/// <param name="height">缩略图高度</param>
/// <param name="mode">缩略模式H:指定高度宽度按比例处理W指定宽度高度按比例处理HW按参数指定的高度和宽度</param>
public static void MakeThumbnail(string originalImagePath,
string thumbnailPath, string thumbnailPath,
int width=120, int height=90, string mode="H") int width = 120, int height = 90, string mode = "H")
{ {
//Image originalImage = Image.FromFile(originalImagePath); using (var originalImage = Image.Load(originalImagePath))
//int towidth = width; {
//int toheight = height; int towidth = width; //缩略图宽度
//int x = 0; int toheight = height; //缩略图高度
//int y = 0; switch (mode)
//int ow = originalImage.Width; {
//int oh = originalImage.Height; case "HW": //指定高宽缩放(可能变形)
//switch (mode) break;
//{ case "W": //指定宽,高按比例
// case "HW"://指定高宽缩放(可能变形) toheight = originalImage.Height * width / originalImage.Width;
// break; break;
// case "W"://指定宽,高按比例 case "H": //指定高,宽按比例
// toheight = originalImage.Height * width / originalImage.Width; towidth = originalImage.Width * height / originalImage.Height;
// break; break;
// case "H"://指定高,宽按比例 default:
// towidth = originalImage.Width * height / originalImage.Height; break;
// break; }
// case "Cut"://指定高宽裁减(不变形)
// if ((double)originalImage.Width / (double)originalImage.Height > (double)towidth / (double)toheight) originalImage.Mutate(x => x.Resize(towidth, toheight));
// { originalImage.Save(thumbnailPath);
// oh = originalImage.Height; }
// ow = originalImage.Height * towidth / toheight;
// y = 0;
// x = (originalImage.Width - ow) / 2;
// }
// else
// {
// ow = originalImage.Width;
// oh = originalImage.Width * height / towidth;
// x = 0;
// y = (originalImage.Height - oh) / 2;
// }
// break;
// default:
// break;
//}
//MediaTypeNames.Image bitmap = new System.Drawing.Bitmap(towidth, toheight);
//Graphics g = System.Drawing.Graphics.FromImage(bitmap);
//g.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.High;
//g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
//g.Clear(Color.Transparent);
//g.DrawImage(originalImage, new Rectangle(0, 0, towidth, toheight),
// new Rectangle(x, y, ow, oh),
// GraphicsUnit.Pixel);
//try
//{
// bitmap.Save(thumbnailPath, System.Drawing.Imaging.ImageFormat.Png);
//}
//catch (System.Exception e)
//{
// throw e;
//}
//finally
//{
// originalImage.Dispose();
// bitmap.Dispose();
// g.Dispose();
//}
} }
} }
} }

View File

@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup> <PropertyGroup>
<TargetFramework>netcoreapp5.0</TargetFramework> <TargetFramework>netcoreapp3.1</TargetFramework>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
@ -18,6 +18,7 @@
<PackageReference Include="NUnit" Version="3.12.0" /> <PackageReference Include="NUnit" Version="3.12.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.5.0" /> <PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.5.0" />
<PackageReference Include="NUnit3TestAdapter" Version="3.16.0" /> <PackageReference Include="NUnit3TestAdapter" Version="3.16.0" />
<PackageReference Include="SixLabors.ImageSharp" Version="1.0.2" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>

View File

@ -1,29 +1,35 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO; using System.IO;
using System.Linq;
using System.Threading.Tasks;
using Infrastructure; using Infrastructure;
using Infrastructure.Extensions;
using Infrastructure.Helpers; using Infrastructure.Helpers;
using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options; using Microsoft.Extensions.Options;
using OpenAuth.App.Interface; using OpenAuth.App.Interface;
using OpenAuth.App.Request;
using OpenAuth.App.Response;
using OpenAuth.Repository.Domain; using OpenAuth.Repository.Domain;
using OpenAuth.Repository.Interface; using OpenAuth.Repository.Interface;
namespace OpenAuth.App namespace OpenAuth.App
{ {
/// <summary> /// <summary>
/// 文件 /// 文件管理
/// </summary> /// </summary>
public class FileApp : BaseApp<UploadFile> public class FileApp : BaseApp<UploadFile>
{ {
private ILogger<FileApp> _logger; private ILogger<FileApp> _logger;
private string _filePath; private string _filePath;
private string _dbFilePath; //数据库中的文件路径 private string _dbFilePath; //数据库中的文件路径
private string _dbThumbnail; //数据库中的缩略图路径 private string _dbThumbnail; //数据库中的缩略图路径
public FileApp( IOptions<AppSetting> setOptions, IUnitWork unitWork, IRepository<UploadFile> repository, ILogger<FileApp> logger, IAuth auth) public FileApp(IOptions<AppSetting> setOptions, IUnitWork unitWork, IRepository<UploadFile> repository,
:base(unitWork, repository, auth) ILogger<FileApp> logger, IAuth auth)
: base(unitWork, repository, auth)
{ {
_logger = logger; _logger = logger;
_filePath = setOptions.Value.UploadPath; _filePath = setOptions.Value.UploadPath;
@ -33,6 +39,30 @@ namespace OpenAuth.App
} }
} }
/// <summary>
/// 加载附件列表
/// </summary>
public async Task<TableData> Load(QueryFileListReq request)
{
var result = new TableData();
var objs = UnitWork.Find<UploadFile>(null);
if (!string.IsNullOrEmpty(request.key))
{
objs = objs.Where(u => u.FileName.Contains(request.key) || u.FilePath.Contains(request.key));
}
result.data = objs.OrderByDescending(u => u.CreateTime)
.Skip((request.page - 1) * request.limit)
.Take(request.limit);
result.count = objs.Count();
return result;
}
/// <summary>
/// 批量添加附件
/// </summary>
/// <param name="files"></param>
/// <returns></returns>
public List<UploadFile> Add(IFormFileCollection files) public List<UploadFile> Add(IFormFileCollection files)
{ {
var result = new List<UploadFile>(); var result = new List<UploadFile>();
@ -55,20 +85,22 @@ namespace OpenAuth.App
{ {
_logger.LogWarning("收到新文件为空"); _logger.LogWarning("收到新文件为空");
} }
if (file != null && file.Length > 0 && file.Length < 10485760) if (file != null && file.Length > 0 && file.Length < 10485760)
{ {
using (var binaryReader = new BinaryReader(file.OpenReadStream())) using (var binaryReader = new BinaryReader(file.OpenReadStream()))
{ {
var fileName = Path.GetFileName(file.FileName); var fileName = Path.GetFileName(file.FileName);
var data = binaryReader.ReadBytes((int)file.Length); var data = binaryReader.ReadBytes((int) file.Length);
UploadFile(fileName, data); SaveFile(fileName, data);
var filedb = new UploadFile var filedb = new UploadFile
{ {
FilePath = _dbFilePath, FilePath = _dbFilePath,
Thumbnail = _dbThumbnail, Thumbnail = _dbThumbnail,
FileName = fileName, FileName = fileName,
FileSize = file.Length, FileSize = file.Length.ToInt(),
CreateUserName = _auth.GetUserName(),
FileType = Path.GetExtension(fileName), FileType = Path.GetExtension(fileName),
Extension = Path.GetExtension(fileName) Extension = Path.GetExtension(fileName)
}; };
@ -81,8 +113,33 @@ namespace OpenAuth.App
throw new Exception("文件过大"); throw new Exception("文件过大");
} }
} }
/// <summary>
/// 删除附件
/// </summary>
/// <param name="ids"></param>
public override void Delete(string[] ids)
{
var files = base.Repository.Find(u => ids.Contains(u.Id)).ToList();
for (int i = 0; i < files.Count(); i++)
{
var uploadPath = Path.Combine(_filePath, files[i].FilePath);
FileHelper.FileDel(uploadPath);
if (!string.IsNullOrEmpty(files[i].Thumbnail))
{
FileHelper.FileDel(Path.Combine(_filePath, files[i].Thumbnail));
}
Repository.Delete(u =>u.Id == files[i].Id);
}
}
private void UploadFile(string fileName, byte[] fileBuffers) /// <summary>
/// 存储文件,如果是图片文件则生成缩略图
/// </summary>
/// <param name="fileName"></param>
/// <param name="fileBuffers"></param>
/// <exception cref="Exception"></exception>
private void SaveFile(string fileName, byte[] fileBuffers)
{ {
string folder = DateTime.Now.ToString("yyyyMMdd"); string folder = DateTime.Now.ToString("yyyyMMdd");
@ -98,7 +155,7 @@ namespace OpenAuth.App
throw new Exception("文件不能为空"); throw new Exception("文件不能为空");
} }
var uploadPath = Path.Combine(_filePath , folder ); var uploadPath = Path.Combine(_filePath, folder);
_logger.LogInformation("文件写入:" + uploadPath); _logger.LogInformation("文件写入:" + uploadPath);
if (!Directory.Exists(uploadPath)) if (!Directory.Exists(uploadPath))
{ {
@ -108,21 +165,22 @@ namespace OpenAuth.App
var ext = Path.GetExtension(fileName).ToLower(); var ext = Path.GetExtension(fileName).ToLower();
string newName = GenerateId.GenerateOrderNumber() + ext; string newName = GenerateId.GenerateOrderNumber() + ext;
using (var fs = new FileStream(Path.Combine(uploadPath , newName), FileMode.Create)) using (var fs = new FileStream(Path.Combine(uploadPath, newName), FileMode.Create))
{ {
fs.Write(fileBuffers, 0, fileBuffers.Length); fs.Write(fileBuffers, 0, fileBuffers.Length);
fs.Close(); fs.Close();
//生成缩略图 //生成缩略图
if (ext.Contains(".jpg") || ext.Contains(".jpeg") || ext.Contains(".png") || ext.Contains(".bmp") || ext.Contains(".gif")) if (ext.Contains(".jpg") || ext.Contains(".jpeg") || ext.Contains(".png") || ext.Contains(".bmp") ||
ext.Contains(".gif"))
{ {
string thumbnailName = GenerateId.GenerateOrderNumber() + ext; string thumbnailName = GenerateId.GenerateOrderNumber() + ext;
ImgHelper.MakeThumbnail(Path.Combine(uploadPath , newName), Path.Combine(uploadPath , thumbnailName)); ImgHelper.MakeThumbnail(Path.Combine(uploadPath, newName), Path.Combine(uploadPath, thumbnailName));
_dbThumbnail = Path.Combine(folder , thumbnailName); _dbThumbnail = Path.Combine(folder, thumbnailName);
} }
_dbFilePath = Path.Combine(folder , newName); _dbFilePath = Path.Combine(folder, newName);
} }
} }
} }

View File

@ -62,6 +62,9 @@ namespace OpenAuth.App
return _revelanceApp.Get(Define.ROLEDATAPROPERTY, roleId, moduleCode); return _revelanceApp.Get(Define.ROLEDATAPROPERTY, roleId, moduleCode);
} }
/// <summary>
/// 根据某角色ID获取可访问某模块的菜单项
/// </summary>
public IEnumerable<ModuleElement> LoadMenusForRole(string moduleId, string roleId) public IEnumerable<ModuleElement> LoadMenusForRole(string moduleId, string roleId)
{ {
var elementIds = _revelanceApp.Get(Define.ROLEELEMENT, true, roleId); var elementIds = _revelanceApp.Get(Define.ROLEELEMENT, true, roleId);
@ -90,6 +93,10 @@ namespace OpenAuth.App
} }
/// <summary>
/// 新增菜单
/// <para>当前登录用户的所有角色会自动分配菜单</para>
/// </summary>
public void AddMenu(ModuleElement model) public void AddMenu(ModuleElement model)
{ {
var loginContext = _auth.GetCurrentUser(); var loginContext = _auth.GetCurrentUser();

View File

@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup> <PropertyGroup>
<TargetFramework>netcoreapp5.0</TargetFramework> <TargetFramework>netcoreapp3.1</TargetFramework>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">

View File

@ -0,0 +1,7 @@
namespace OpenAuth.App.Request
{
public class QueryFileListReq : PageReq
{
//todo:添加自己的请求字段
}
}

View File

@ -72,14 +72,16 @@ namespace OpenAuth.App
{ {
foreach (var value in sameVals) foreach (var value in sameVals)
{ {
Repository.Delete(u => u.Key == key && u.FirstId == sameVals.Key && u.SecondId == value); UnitWork.Delete<Relevance>(u => u.Key == key && u.FirstId == sameVals.Key && u.SecondId == value);
} }
} }
UnitWork.Save();
} }
public void DeleteBy(string key, params string[] firstIds) public void DeleteBy(string key, params string[] firstIds)
{ {
Repository.Delete(u => firstIds.Contains(u.FirstId) && u.Key == key); UnitWork.Delete<Relevance>(u => firstIds.Contains(u.FirstId) && u.Key == key);
UnitWork.Save();
} }
@ -160,11 +162,12 @@ namespace OpenAuth.App
{ {
foreach (var property in request.Properties) foreach (var property in request.Properties)
{ {
Repository.Delete(u => u.Key == Define.ROLEDATAPROPERTY UnitWork.Delete<Relevance>(u => u.Key == Define.ROLEDATAPROPERTY
&& u.FirstId == request.RoleId && u.FirstId == request.RoleId
&& u.SecondId == request.ModuleCode && u.SecondId == request.ModuleCode
&& u.ThirdId == property); && u.ThirdId == property);
} }
UnitWork.Save();
} }
} }
@ -174,18 +177,21 @@ namespace OpenAuth.App
/// <param name="request"></param> /// <param name="request"></param>
public void AssignRoleUsers(AssignRoleUsers request) public void AssignRoleUsers(AssignRoleUsers request)
{ {
//删除以前的所有用户 UnitWork.ExecuteWithTransaction(() =>
UnitWork.Delete<Relevance>(u => u.SecondId == request.RoleId && u.Key == Define.USERROLE); {
//批量分配用户角色 //删除以前的所有用户
UnitWork.BatchAdd((from firstId in request.UserIds UnitWork.Delete<Relevance>(u => u.SecondId == request.RoleId && u.Key == Define.USERROLE);
select new Relevance //批量分配用户角色
{ UnitWork.BatchAdd((from firstId in request.UserIds
Key = Define.USERROLE, select new Relevance
FirstId = firstId, {
SecondId = request.RoleId, Key = Define.USERROLE,
OperateTime = DateTime.Now FirstId = firstId,
}).ToArray()); SecondId = request.RoleId,
UnitWork.Save(); OperateTime = DateTime.Now
}).ToArray());
UnitWork.Save();
});
} }
/// <summary> /// <summary>
@ -194,18 +200,21 @@ namespace OpenAuth.App
/// <param name="request"></param> /// <param name="request"></param>
public void AssignOrgUsers(AssignOrgUsers request) public void AssignOrgUsers(AssignOrgUsers request)
{ {
//删除以前的所有用户 UnitWork.ExecuteWithTransaction(() =>
UnitWork.Delete<Relevance>(u => u.SecondId == request.OrgId && u.Key == Define.USERORG); {
//批量分配用户角色 //删除以前的所有用户
UnitWork.BatchAdd((from firstId in request.UserIds UnitWork.Delete<Relevance>(u => u.SecondId == request.OrgId && u.Key == Define.USERORG);
select new Relevance //批量分配用户角色
{ UnitWork.BatchAdd((from firstId in request.UserIds
Key = Define.USERORG, select new Relevance
FirstId = firstId, {
SecondId = request.OrgId, Key = Define.USERORG,
OperateTime = DateTime.Now FirstId = firstId,
}).ToArray()); SecondId = request.OrgId,
UnitWork.Save(); OperateTime = DateTime.Now
}).ToArray());
UnitWork.Save();
});
} }
} }
} }

View File

@ -0,0 +1,52 @@
using System;
using System.Threading.Tasks;
using Castle.Core.Logging;
using Infrastructure;
using Infrastructure.Cache;
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using Moq;
using NUnit.Framework;
using OpenAuth.App.Request;
using OpenAuth.App.SSO;
namespace OpenAuth.App.Test
{
class TestFileApp :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);
var logMock = new Mock<ILogger<FileApp>>();
services.AddScoped(x => logMock.Object);
return services;
}
[Test]
public void TestLoad()
{
var app = _autofacServiceProvider.GetService<FileApp>();
var result = app.Load(new QueryFileListReq()
{
page = 1,
limit = 10
});
Console.WriteLine(JsonHelper.Instance.Serialize(result.Result));
}
}
}

View File

@ -119,47 +119,52 @@ namespace OpenAuth.App
throw new Exception("请为用户分配机构"); throw new Exception("请为用户分配机构");
User requser = request; User requser = request;
requser.CreateId = _auth.GetCurrentUser().User.Id; requser.CreateId = _auth.GetCurrentUser().User.Id;
if (string.IsNullOrEmpty(request.Id))
UnitWork.ExecuteWithTransaction(() =>
{ {
if (UnitWork.Any<User>(u => u.Account == request.Account)) if (string.IsNullOrEmpty(request.Id))
{ {
throw new Exception("用户账号已存在"); if (UnitWork.Any<User>(u => u.Account == request.Account))
{
throw new Exception("用户账号已存在");
}
if (string.IsNullOrEmpty(requser.Password))
{
requser.Password = requser.Account; //如果客户端没提供密码,默认密码同账号
}
requser.CreateTime = DateTime.Now;
UnitWork.Add(requser);
request.Id = requser.Id; //要把保存后的ID存入view
} }
else
if (string.IsNullOrEmpty(requser.Password))
{
requser.Password = requser.Account; //如果客户端没提供密码,默认密码同账号
}
requser.CreateTime = DateTime.Now;
UnitWork.Add(requser);
request.Id = requser.Id; //要把保存后的ID存入view
}
else
{
UnitWork.Update<User>(u => u.Id == request.Id, u => new User
{
Account = requser.Account,
BizCode = requser.BizCode,
Name = requser.Name,
Sex = requser.Sex,
Status = requser.Status
});
if (!string.IsNullOrEmpty(requser.Password)) //密码为空的时候,不做修改
{ {
UnitWork.Update<User>(u => u.Id == request.Id, u => new User UnitWork.Update<User>(u => u.Id == request.Id, u => new User
{ {
Password = requser.Password Account = requser.Account,
BizCode = requser.BizCode,
Name = requser.Name,
Sex = requser.Sex,
Status = requser.Status
}); });
if (!string.IsNullOrEmpty(requser.Password)) //密码为空的时候,不做修改
{
UnitWork.Update<User>(u => u.Id == request.Id, u => new User
{
Password = requser.Password
});
}
} }
}
UnitWork.Save(); UnitWork.Save();
string[] orgIds = request.OrganizationIds.Split(',').ToArray(); string[] orgIds = request.OrganizationIds.Split(',').ToArray();
_revelanceApp.DeleteBy(Define.USERORG, requser.Id); _revelanceApp.DeleteBy(Define.USERORG, requser.Id);
_revelanceApp.Assign(Define.USERORG, orgIds.ToLookup(u => requser.Id)); _revelanceApp.Assign(Define.USERORG, orgIds.ToLookup(u => requser.Id));
});
} }
/// <summary> /// <summary>
@ -168,10 +173,14 @@ namespace OpenAuth.App
/// <param name="ids"></param> /// <param name="ids"></param>
public override void Delete(string[] ids) public override void Delete(string[] ids)
{ {
UnitWork.Delete<Relevance>(u =>(u.Key == Define.USERROLE || u.Key == Define.USERORG) UnitWork.ExecuteWithTransaction(() =>
&& ids.Contains(u.FirstId)); {
UnitWork.Delete<User>(u => ids.Contains(u.Id)); UnitWork.Delete<Relevance>(u =>(u.Key == Define.USERROLE || u.Key == Define.USERORG)
UnitWork.Save(); && ids.Contains(u.FirstId));
UnitWork.Delete<User>(u => ids.Contains(u.Id));
UnitWork.Save();
});
} }

View File

@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk.Web"> <Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup> <PropertyGroup>
<TargetFramework>netcoreapp5.0</TargetFramework> <TargetFramework>netcoreapp3.1</TargetFramework>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>

View File

@ -1,4 +1,5 @@
using System; using System;
using System.Threading.Tasks;
using Infrastructure; using Infrastructure;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using OpenAuth.App; using OpenAuth.App;
@ -59,9 +60,10 @@ namespace OpenAuth.Mvc.Controllers
/// <summary> /// <summary>
/// 加载列表 /// 加载列表
/// </summary> /// </summary>
public string Load([FromQuery]QueryDataPrivilegeRuleListReq request) public async Task<string> Load([FromQuery]QueryDataPrivilegeRuleListReq request)
{ {
return JsonHelper.Instance.Serialize(_app.Load(request)); var objs = await _app.Load(request);
return JsonHelper.Instance.Serialize(objs);
} }
[HttpPost] [HttpPost]

View File

@ -1,5 +1,6 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Threading.Tasks;
using Infrastructure; using Infrastructure;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using OpenAuth.App; using OpenAuth.App;
@ -136,9 +137,10 @@ namespace OpenAuth.Mvc.Controllers
/// <summary> /// <summary>
/// 加载列表 /// 加载列表
/// </summary> /// </summary>
public string Load([FromQuery]QueryFlowInstanceListReq request) public async Task<string> Load([FromQuery]QueryFlowInstanceListReq request)
{ {
return JsonHelper.Instance.Serialize(_app.Load(request)); var objs = await _app.Load(request);
return JsonHelper.Instance.Serialize(objs);
} }
/// <summary> /// <summary>

View File

@ -1,4 +1,5 @@
using System; using System;
using System.Threading.Tasks;
using Infrastructure; using Infrastructure;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using OpenAuth.App; using OpenAuth.App;
@ -86,9 +87,10 @@ namespace OpenAuth.Mvc.Controllers
/// <summary> /// <summary>
/// 加载列表 /// 加载列表
/// </summary> /// </summary>
public string Load([FromQuery]QueryFlowSchemeListReq request) public async Task<string> Load([FromQuery]QueryFlowSchemeListReq request)
{ {
return JsonHelper.Instance.Serialize(_app.Load(request)); var objs = await _app.Load(request);
return JsonHelper.Instance.Serialize(objs);
} }
[HttpPost] [HttpPost]

View File

@ -1,4 +1,5 @@
using System; using System;
using System.Threading.Tasks;
using Infrastructure; using Infrastructure;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using OpenAuth.App; using OpenAuth.App;
@ -87,9 +88,10 @@ namespace OpenAuth.Mvc.Controllers
/// <summary> /// <summary>
/// 加载列表 /// 加载列表
/// </summary> /// </summary>
public string Load([FromQuery]QueryFormListReq request) public async Task<string> Load([FromQuery]QueryFormListReq request)
{ {
return JsonHelper.Instance.Serialize(_app.Load(request)); var objs = await _app.Load(request);
return JsonHelper.Instance.Serialize(objs);
} }
[HttpPost] [HttpPost]

View File

@ -1,7 +1,8 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using Infrastructure; using System.Threading.Tasks;
using Infrastructure;
using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using OpenAuth.App; using OpenAuth.App;
@ -106,9 +107,10 @@ namespace OpenAuth.Mvc.Controllers
/// <summary> /// <summary>
/// 加载列表 /// 加载列表
/// </summary> /// </summary>
public string Load([FromQuery]QueryOpenJobListReq request) public async Task<string> Load([FromQuery]QueryOpenJobListReq request)
{ {
return JsonHelper.Instance.Serialize(_app.Load(request)); var objs = await _app.Load(request);
return JsonHelper.Instance.Serialize(objs);
} }
[HttpPost] [HttpPost]

View File

@ -1,6 +1,7 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Threading.Tasks;
using Infrastructure; using Infrastructure;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using OpenAuth.App; using OpenAuth.App;
@ -54,9 +55,10 @@ namespace OpenAuth.Mvc.Controllers
} }
public string Load([FromQuery]QueryResourcesReq request) public async Task<string> Load([FromQuery]QueryResourcesReq request)
{ {
return JsonHelper.Instance.Serialize(_app.Load(request)); var objs = await _app.Load(request);
return JsonHelper.Instance.Serialize(objs);
} }
[HttpPost] [HttpPost]

View File

@ -1,4 +1,5 @@
using System; using System;
using System.Threading.Tasks;
using Infrastructure; using Infrastructure;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using OpenAuth.App; using OpenAuth.App;
@ -60,9 +61,10 @@ namespace OpenAuth.Mvc.Controllers
/// <summary> /// <summary>
/// 加载列表 /// 加载列表
/// </summary> /// </summary>
public string Load([FromQuery]QuerySysLogListReq request) public async Task<string> Load([FromQuery]QuerySysLogListReq request)
{ {
return JsonHelper.Instance.Serialize(_app.Load(request)); var objs = await _app.Load(request);
return JsonHelper.Instance.Serialize(objs);
} }
[HttpPost] [HttpPost]

View File

@ -1,4 +1,5 @@
using System; using System;
using System.Threading.Tasks;
using Infrastructure; using Infrastructure;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using OpenAuth.App; using OpenAuth.App;
@ -60,9 +61,10 @@ namespace OpenAuth.Mvc.Controllers
/// <summary> /// <summary>
/// 加载列表 /// 加载列表
/// </summary> /// </summary>
public string Load([FromQuery]QuerySysMessageListReq request) public async Task<string> Load([FromQuery]QuerySysMessageListReq request)
{ {
return JsonHelper.Instance.Serialize(_app.Load(request)); var objs = await _app.Load(request);
return JsonHelper.Instance.Serialize(objs);
} }
[HttpPost] [HttpPost]

View File

@ -1,4 +1,5 @@
using System; using System;
using System.Threading.Tasks;
using Infrastructure; using Infrastructure;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using OpenAuth.App; using OpenAuth.App;
@ -59,9 +60,10 @@ namespace OpenAuth.Mvc.Controllers
/// <summary> /// <summary>
/// 加载列表 /// 加载列表
/// </summary> /// </summary>
public string Load([FromQuery]QueryWmsInboundOrderTblListReq request) public async Task<string> Load([FromQuery]QueryWmsInboundOrderTblListReq request)
{ {
return JsonHelper.Instance.Serialize(_app.Load(request)); var objs = await _app.Load(request);
return JsonHelper.Instance.Serialize(objs);
} }
[HttpPost] [HttpPost]

View File

@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk.Web"> <Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup> <PropertyGroup>
<TargetFramework>netcoreapp5.0</TargetFramework> <TargetFramework>netcoreapp3.1</TargetFramework>
<UseRazorBuildServer>false</UseRazorBuildServer> <UseRazorBuildServer>false</UseRazorBuildServer>
</PropertyGroup> </PropertyGroup>

View File

@ -51,7 +51,7 @@ namespace OpenAuth.Repository.Domain
/// <summary> /// <summary>
/// 文件大小 /// 文件大小
/// </summary> /// </summary>
public long FileSize { get; set; } public int? FileSize { get; set; }
/// <summary> /// <summary>
/// 扩展名称 /// 扩展名称
/// </summary> /// </summary>

View File

@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup> <PropertyGroup>
<TargetFramework>netcoreapp5.0</TargetFramework> <TargetFramework>netcoreapp3.1</TargetFramework>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">

View File

@ -1,11 +1,14 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Threading.Tasks;
using Infrastructure; using Infrastructure;
using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using OpenAuth.App; using OpenAuth.App;
using OpenAuth.App.Request;
using OpenAuth.App.Response;
using OpenAuth.Repository.Domain; using OpenAuth.Repository.Domain;
namespace OpenAuth.WebApi.Controllers namespace OpenAuth.WebApi.Controllers
@ -24,9 +27,42 @@ namespace OpenAuth.WebApi.Controllers
{ {
_app = app; _app = app;
} }
/// <summary>
/// 加载附件列表
/// </summary>
[HttpGet]
public async Task<TableData> Load([FromQuery]QueryFileListReq request)
{
return await _app.Load(request);
}
/// <summary>
/// 删除附件
/// </summary>
/// <param name="ids"></param>
/// <returns></returns>
[HttpPost]
public Response Delete([FromBody]string[] ids)
{
var result = new Response();
try
{
_app.Delete(ids);
}
catch (Exception ex)
{
result.Code = 500;
result.Message = ex.InnerException?.Message ?? ex.Message;
}
return result;
}
/// <summary> /// <summary>
/// 批量上传文件接口 /// 批量上传文件接口
/// <para>客户端文本框需设置name='files'</para>
/// </summary> /// </summary>
/// <param name="files"></param> /// <param name="files"></param>
/// <returns>服务器存储的文件信息</returns> /// <returns>服务器存储的文件信息</returns>

View File

@ -187,7 +187,10 @@ namespace OpenAuth.WebApi.Controllers
#endregion #endregion
//添加或修改 /// <summary>
/// 新增菜单
/// <para>当前登录用户的所有角色会自动分配菜单</para>
/// </summary>
[HttpPost] [HttpPost]
public Response<ModuleElement> AddMenu(ModuleElement obj) public Response<ModuleElement> AddMenu(ModuleElement obj)
{ {
@ -206,7 +209,9 @@ namespace OpenAuth.WebApi.Controllers
return result; return result;
} }
//添加或修改 /// <summary>
/// 修改菜单属性
/// </summary>
[HttpPost] [HttpPost]
public Response UpdateMenu(ModuleElement obj) public Response UpdateMenu(ModuleElement obj)
{ {
@ -226,6 +231,9 @@ namespace OpenAuth.WebApi.Controllers
} }
/// <summary>
/// 删除菜单
/// </summary>
[HttpPost] [HttpPost]
public Response DeleteMenu([FromBody]string[] ids) public Response DeleteMenu([FromBody]string[] ids)
{ {

View File

@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk.Web"> <Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup> <PropertyGroup>
<TargetFramework>netcoreapp5.0</TargetFramework> <TargetFramework>netcoreapp3.1</TargetFramework>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">