mirror of
https://gitee.com/dotnetchina/OpenAuth.Net.git
synced 2025-08-23 13:06:48 +08:00
sync with OpenAuth.Core
This commit is contained in:
parent
7217e7a924
commit
7540baa322
@ -2,76 +2,49 @@
|
||||
// Copyright (c) 2019 openauth.me. All rights reserved.
|
||||
// </copyright>
|
||||
// <author>www.cnblogs.com/yubaolee</author>
|
||||
// <date>2019-03-07</date>
|
||||
// <summary>生成缩略图</summary>
|
||||
|
||||
using SixLabors.ImageSharp;
|
||||
using SixLabors.ImageSharp.Processing;
|
||||
|
||||
namespace Infrastructure.Helpers
|
||||
{
|
||||
public class ImgHelper
|
||||
{
|
||||
//MakeThumbnail(path, tpath, 120, 90, "H");
|
||||
public static void MakeThumbnail(string originalImagePath,
|
||||
/// <summary>
|
||||
/// 根据已有图片生成缩略图
|
||||
/// <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,
|
||||
int width=120, int height=90, string mode="H")
|
||||
int width = 120, int height = 90, string mode = "H")
|
||||
{
|
||||
//Image originalImage = Image.FromFile(originalImagePath);
|
||||
//int towidth = width;
|
||||
//int toheight = height;
|
||||
//int x = 0;
|
||||
//int y = 0;
|
||||
//int ow = originalImage.Width;
|
||||
//int oh = originalImage.Height;
|
||||
//switch (mode)
|
||||
//{
|
||||
// case "HW"://指定高宽缩放(可能变形)
|
||||
// break;
|
||||
// case "W"://指定宽,高按比例
|
||||
// toheight = originalImage.Height * width / originalImage.Width;
|
||||
// break;
|
||||
// case "H"://指定高,宽按比例
|
||||
// towidth = originalImage.Width * height / originalImage.Height;
|
||||
// break;
|
||||
// case "Cut"://指定高宽裁减(不变形)
|
||||
// if ((double)originalImage.Width / (double)originalImage.Height > (double)towidth / (double)toheight)
|
||||
// {
|
||||
// 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();
|
||||
//}
|
||||
using (var originalImage = Image.Load(originalImagePath))
|
||||
{
|
||||
int towidth = width; //缩略图宽度
|
||||
int toheight = height; //缩略图高度
|
||||
switch (mode)
|
||||
{
|
||||
case "HW": //指定高宽缩放(可能变形)
|
||||
break;
|
||||
case "W": //指定宽,高按比例
|
||||
toheight = originalImage.Height * width / originalImage.Width;
|
||||
break;
|
||||
case "H": //指定高,宽按比例
|
||||
towidth = originalImage.Width * height / originalImage.Height;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
originalImage.Mutate(x => x.Resize(towidth, toheight));
|
||||
originalImage.Save(thumbnailPath);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,7 +1,7 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>netcoreapp5.0</TargetFramework>
|
||||
<TargetFramework>netcoreapp3.1</TargetFramework>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
|
||||
@ -18,6 +18,7 @@
|
||||
<PackageReference Include="NUnit" Version="3.12.0" />
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.5.0" />
|
||||
<PackageReference Include="NUnit3TestAdapter" Version="3.16.0" />
|
||||
<PackageReference Include="SixLabors.ImageSharp" Version="1.0.2" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
@ -1,29 +1,35 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Infrastructure;
|
||||
using Infrastructure.Extensions;
|
||||
using Infrastructure.Helpers;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Microsoft.Extensions.Options;
|
||||
using OpenAuth.App.Interface;
|
||||
using OpenAuth.App.Request;
|
||||
using OpenAuth.App.Response;
|
||||
using OpenAuth.Repository.Domain;
|
||||
using OpenAuth.Repository.Interface;
|
||||
|
||||
namespace OpenAuth.App
|
||||
{
|
||||
/// <summary>
|
||||
/// 文件
|
||||
/// 文件管理
|
||||
/// </summary>
|
||||
public class FileApp : BaseApp<UploadFile>
|
||||
{
|
||||
private ILogger<FileApp> _logger;
|
||||
private string _filePath;
|
||||
private string _dbFilePath; //数据库中的文件路径
|
||||
private string _dbThumbnail; //数据库中的缩略图路径
|
||||
private string _dbFilePath; //数据库中的文件路径
|
||||
private string _dbThumbnail; //数据库中的缩略图路径
|
||||
|
||||
public FileApp( IOptions<AppSetting> setOptions, IUnitWork unitWork, IRepository<UploadFile> repository, ILogger<FileApp> logger, IAuth auth)
|
||||
:base(unitWork, repository, auth)
|
||||
public FileApp(IOptions<AppSetting> setOptions, IUnitWork unitWork, IRepository<UploadFile> repository,
|
||||
ILogger<FileApp> logger, IAuth auth)
|
||||
: base(unitWork, repository, auth)
|
||||
{
|
||||
_logger = logger;
|
||||
_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)
|
||||
{
|
||||
var result = new List<UploadFile>();
|
||||
@ -55,20 +85,22 @@ namespace OpenAuth.App
|
||||
{
|
||||
_logger.LogWarning("收到新文件为空");
|
||||
}
|
||||
|
||||
if (file != null && file.Length > 0 && file.Length < 10485760)
|
||||
{
|
||||
using (var binaryReader = new BinaryReader(file.OpenReadStream()))
|
||||
{
|
||||
var fileName = Path.GetFileName(file.FileName);
|
||||
var data = binaryReader.ReadBytes((int)file.Length);
|
||||
UploadFile(fileName, data);
|
||||
var data = binaryReader.ReadBytes((int) file.Length);
|
||||
SaveFile(fileName, data);
|
||||
|
||||
var filedb = new UploadFile
|
||||
{
|
||||
FilePath = _dbFilePath,
|
||||
Thumbnail = _dbThumbnail,
|
||||
FileName = fileName,
|
||||
FileSize = file.Length,
|
||||
FileSize = file.Length.ToInt(),
|
||||
CreateUserName = _auth.GetUserName(),
|
||||
FileType = Path.GetExtension(fileName),
|
||||
Extension = Path.GetExtension(fileName)
|
||||
};
|
||||
@ -81,8 +113,33 @@ namespace OpenAuth.App
|
||||
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");
|
||||
|
||||
@ -98,7 +155,7 @@ namespace OpenAuth.App
|
||||
throw new Exception("文件不能为空");
|
||||
}
|
||||
|
||||
var uploadPath = Path.Combine(_filePath , folder );
|
||||
var uploadPath = Path.Combine(_filePath, folder);
|
||||
_logger.LogInformation("文件写入:" + uploadPath);
|
||||
if (!Directory.Exists(uploadPath))
|
||||
{
|
||||
@ -108,21 +165,22 @@ namespace OpenAuth.App
|
||||
var ext = Path.GetExtension(fileName).ToLower();
|
||||
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.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;
|
||||
ImgHelper.MakeThumbnail(Path.Combine(uploadPath , newName), Path.Combine(uploadPath , thumbnailName));
|
||||
_dbThumbnail = Path.Combine(folder , thumbnailName);
|
||||
ImgHelper.MakeThumbnail(Path.Combine(uploadPath, newName), Path.Combine(uploadPath, thumbnailName));
|
||||
_dbThumbnail = Path.Combine(folder, thumbnailName);
|
||||
}
|
||||
|
||||
|
||||
_dbFilePath = Path.Combine(folder , newName);
|
||||
_dbFilePath = Path.Combine(folder, newName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -62,6 +62,9 @@ namespace OpenAuth.App
|
||||
return _revelanceApp.Get(Define.ROLEDATAPROPERTY, roleId, moduleCode);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 根据某角色ID获取可访问某模块的菜单项
|
||||
/// </summary>
|
||||
public IEnumerable<ModuleElement> LoadMenusForRole(string moduleId, string 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)
|
||||
{
|
||||
var loginContext = _auth.GetCurrentUser();
|
||||
|
@ -1,7 +1,7 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>netcoreapp5.0</TargetFramework>
|
||||
<TargetFramework>netcoreapp3.1</TargetFramework>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
|
||||
|
7
OpenAuth.App/Request/QueryFileListReq.cs
Normal file
7
OpenAuth.App/Request/QueryFileListReq.cs
Normal file
@ -0,0 +1,7 @@
|
||||
namespace OpenAuth.App.Request
|
||||
{
|
||||
public class QueryFileListReq : PageReq
|
||||
{
|
||||
//todo:添加自己的请求字段
|
||||
}
|
||||
}
|
@ -72,14 +72,16 @@ namespace OpenAuth.App
|
||||
{
|
||||
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)
|
||||
{
|
||||
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)
|
||||
{
|
||||
Repository.Delete(u => u.Key == Define.ROLEDATAPROPERTY
|
||||
UnitWork.Delete<Relevance>(u => u.Key == Define.ROLEDATAPROPERTY
|
||||
&& u.FirstId == request.RoleId
|
||||
&& u.SecondId == request.ModuleCode
|
||||
&& u.ThirdId == property);
|
||||
}
|
||||
UnitWork.Save();
|
||||
}
|
||||
}
|
||||
|
||||
@ -174,18 +177,21 @@ namespace OpenAuth.App
|
||||
/// <param name="request"></param>
|
||||
public void AssignRoleUsers(AssignRoleUsers request)
|
||||
{
|
||||
//删除以前的所有用户
|
||||
UnitWork.Delete<Relevance>(u => u.SecondId == request.RoleId && u.Key == Define.USERROLE);
|
||||
//批量分配用户角色
|
||||
UnitWork.BatchAdd((from firstId in request.UserIds
|
||||
select new Relevance
|
||||
{
|
||||
Key = Define.USERROLE,
|
||||
FirstId = firstId,
|
||||
SecondId = request.RoleId,
|
||||
OperateTime = DateTime.Now
|
||||
}).ToArray());
|
||||
UnitWork.Save();
|
||||
UnitWork.ExecuteWithTransaction(() =>
|
||||
{
|
||||
//删除以前的所有用户
|
||||
UnitWork.Delete<Relevance>(u => u.SecondId == request.RoleId && u.Key == Define.USERROLE);
|
||||
//批量分配用户角色
|
||||
UnitWork.BatchAdd((from firstId in request.UserIds
|
||||
select new Relevance
|
||||
{
|
||||
Key = Define.USERROLE,
|
||||
FirstId = firstId,
|
||||
SecondId = request.RoleId,
|
||||
OperateTime = DateTime.Now
|
||||
}).ToArray());
|
||||
UnitWork.Save();
|
||||
});
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -194,18 +200,21 @@ namespace OpenAuth.App
|
||||
/// <param name="request"></param>
|
||||
public void AssignOrgUsers(AssignOrgUsers request)
|
||||
{
|
||||
//删除以前的所有用户
|
||||
UnitWork.Delete<Relevance>(u => u.SecondId == request.OrgId && u.Key == Define.USERORG);
|
||||
//批量分配用户角色
|
||||
UnitWork.BatchAdd((from firstId in request.UserIds
|
||||
select new Relevance
|
||||
{
|
||||
Key = Define.USERORG,
|
||||
FirstId = firstId,
|
||||
SecondId = request.OrgId,
|
||||
OperateTime = DateTime.Now
|
||||
}).ToArray());
|
||||
UnitWork.Save();
|
||||
UnitWork.ExecuteWithTransaction(() =>
|
||||
{
|
||||
//删除以前的所有用户
|
||||
UnitWork.Delete<Relevance>(u => u.SecondId == request.OrgId && u.Key == Define.USERORG);
|
||||
//批量分配用户角色
|
||||
UnitWork.BatchAdd((from firstId in request.UserIds
|
||||
select new Relevance
|
||||
{
|
||||
Key = Define.USERORG,
|
||||
FirstId = firstId,
|
||||
SecondId = request.OrgId,
|
||||
OperateTime = DateTime.Now
|
||||
}).ToArray());
|
||||
UnitWork.Save();
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
52
OpenAuth.App/Test/TestFileApp.cs
Normal file
52
OpenAuth.App/Test/TestFileApp.cs
Normal 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));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@ -119,47 +119,52 @@ namespace OpenAuth.App
|
||||
throw new Exception("请为用户分配机构");
|
||||
User requser = request;
|
||||
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
|
||||
}
|
||||
|
||||
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)) //密码为空的时候,不做修改
|
||||
else
|
||||
{
|
||||
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();
|
||||
string[] orgIds = request.OrganizationIds.Split(',').ToArray();
|
||||
UnitWork.Save();
|
||||
string[] orgIds = request.OrganizationIds.Split(',').ToArray();
|
||||
|
||||
_revelanceApp.DeleteBy(Define.USERORG, requser.Id);
|
||||
_revelanceApp.Assign(Define.USERORG, orgIds.ToLookup(u => requser.Id));
|
||||
_revelanceApp.DeleteBy(Define.USERORG, requser.Id);
|
||||
_revelanceApp.Assign(Define.USERORG, orgIds.ToLookup(u => requser.Id));
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -168,10 +173,14 @@ namespace OpenAuth.App
|
||||
/// <param name="ids"></param>
|
||||
public override void Delete(string[] ids)
|
||||
{
|
||||
UnitWork.Delete<Relevance>(u =>(u.Key == Define.USERROLE || u.Key == Define.USERORG)
|
||||
&& ids.Contains(u.FirstId));
|
||||
UnitWork.Delete<User>(u => ids.Contains(u.Id));
|
||||
UnitWork.Save();
|
||||
UnitWork.ExecuteWithTransaction(() =>
|
||||
{
|
||||
UnitWork.Delete<Relevance>(u =>(u.Key == Define.USERROLE || u.Key == Define.USERORG)
|
||||
&& ids.Contains(u.FirstId));
|
||||
UnitWork.Delete<User>(u => ids.Contains(u.Id));
|
||||
UnitWork.Save();
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>netcoreapp5.0</TargetFramework>
|
||||
<TargetFramework>netcoreapp3.1</TargetFramework>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
@ -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.Mvc.Controllers
|
||||
/// <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]
|
||||
|
@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using Infrastructure;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using OpenAuth.App;
|
||||
@ -136,9 +137,10 @@ namespace OpenAuth.Mvc.Controllers
|
||||
/// <summary>
|
||||
/// 加载列表
|
||||
/// </summary>
|
||||
public string Load([FromQuery]QueryFlowInstanceListReq request)
|
||||
{
|
||||
return JsonHelper.Instance.Serialize(_app.Load(request));
|
||||
public async Task<string> Load([FromQuery]QueryFlowInstanceListReq request)
|
||||
{
|
||||
var objs = await _app.Load(request);
|
||||
return JsonHelper.Instance.Serialize(objs);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using Infrastructure;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using OpenAuth.App;
|
||||
@ -86,9 +87,10 @@ namespace OpenAuth.Mvc.Controllers
|
||||
/// <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]
|
||||
|
@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using Infrastructure;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using OpenAuth.App;
|
||||
@ -87,9 +88,10 @@ namespace OpenAuth.Mvc.Controllers
|
||||
/// <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]
|
||||
|
@ -1,7 +1,8 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Infrastructure;
|
||||
using System.Threading.Tasks;
|
||||
using Infrastructure;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using OpenAuth.App;
|
||||
@ -106,9 +107,10 @@ namespace OpenAuth.Mvc.Controllers
|
||||
/// <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]
|
||||
|
@ -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;
|
||||
@ -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]
|
||||
|
@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using Infrastructure;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using OpenAuth.App;
|
||||
@ -60,9 +61,10 @@ namespace OpenAuth.Mvc.Controllers
|
||||
/// <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]
|
||||
|
@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using Infrastructure;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using OpenAuth.App;
|
||||
@ -60,9 +61,10 @@ namespace OpenAuth.Mvc.Controllers
|
||||
/// <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]
|
||||
|
@ -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.Mvc.Controllers
|
||||
/// <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]
|
||||
|
@ -1,7 +1,7 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>netcoreapp5.0</TargetFramework>
|
||||
<TargetFramework>netcoreapp3.1</TargetFramework>
|
||||
<UseRazorBuildServer>false</UseRazorBuildServer>
|
||||
</PropertyGroup>
|
||||
|
||||
|
@ -51,7 +51,7 @@ namespace OpenAuth.Repository.Domain
|
||||
/// <summary>
|
||||
/// 文件大小
|
||||
/// </summary>
|
||||
public long FileSize { get; set; }
|
||||
public int? FileSize { get; set; }
|
||||
/// <summary>
|
||||
/// 扩展名称
|
||||
/// </summary>
|
||||
|
@ -1,7 +1,7 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>netcoreapp5.0</TargetFramework>
|
||||
<TargetFramework>netcoreapp3.1</TargetFramework>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
|
||||
|
@ -1,11 +1,14 @@
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using Infrastructure;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using OpenAuth.App;
|
||||
using OpenAuth.App.Request;
|
||||
using OpenAuth.App.Response;
|
||||
using OpenAuth.Repository.Domain;
|
||||
|
||||
namespace OpenAuth.WebApi.Controllers
|
||||
@ -24,9 +27,42 @@ namespace OpenAuth.WebApi.Controllers
|
||||
{
|
||||
_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>
|
||||
/// 批量上传文件接口
|
||||
/// <para>客户端文本框需设置name='files'</para>
|
||||
/// </summary>
|
||||
/// <param name="files"></param>
|
||||
/// <returns>服务器存储的文件信息</returns>
|
||||
|
@ -187,7 +187,10 @@ namespace OpenAuth.WebApi.Controllers
|
||||
|
||||
#endregion 添加编辑模块
|
||||
|
||||
//添加或修改
|
||||
/// <summary>
|
||||
/// 新增菜单
|
||||
/// <para>当前登录用户的所有角色会自动分配菜单</para>
|
||||
/// </summary>
|
||||
[HttpPost]
|
||||
public Response<ModuleElement> AddMenu(ModuleElement obj)
|
||||
{
|
||||
@ -206,7 +209,9 @@ namespace OpenAuth.WebApi.Controllers
|
||||
return result;
|
||||
}
|
||||
|
||||
//添加或修改
|
||||
/// <summary>
|
||||
/// 修改菜单属性
|
||||
/// </summary>
|
||||
[HttpPost]
|
||||
public Response UpdateMenu(ModuleElement obj)
|
||||
{
|
||||
@ -226,6 +231,9 @@ namespace OpenAuth.WebApi.Controllers
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 删除菜单
|
||||
/// </summary>
|
||||
[HttpPost]
|
||||
public Response DeleteMenu([FromBody]string[] ids)
|
||||
{
|
||||
|
@ -1,7 +1,7 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>netcoreapp5.0</TargetFramework>
|
||||
<TargetFramework>netcoreapp3.1</TargetFramework>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
|
||||
|
Loading…
Reference in New Issue
Block a user