权限修改

master
he 2024-12-06 17:01:44 +08:00
parent 655e3454a3
commit be28ea0432
5 changed files with 141 additions and 115 deletions

View File

@ -204,7 +204,8 @@ namespace IRaCIS.Core.API
// 特殊异常处理 比如 404
app.UseStatusCodePagesWithReExecute("/Error/{0}");
//SwaggerSetup.Configure(app, env);
// SwaggerÏÔÒþ
SwaggerSetup.Configure(app, env);

View File

@ -17,8 +17,13 @@ namespace IRaCIS.Core.API
{
public static class SwaggerSetup
{
public static bool useSwagger = false;
public static void AddSwaggerSetup(this IServiceCollection services)
{
if (useSwagger)
{
services.AddSwaggerExamplesFromAssemblyOf<JsonPatchUserRequestExample>();
services.AddSwaggerGen(options =>
@ -26,7 +31,7 @@ namespace IRaCIS.Core.API
//此处的Name 是控制器上分组的名称 Title是界面的大标题
//分组
options.SwaggerDoc("Reviewer", new OpenApiInfo {Title = "医生模块",Version = "Reviewer", });
options.SwaggerDoc("Reviewer", new OpenApiInfo { Title = "医生模块", Version = "Reviewer", });
options.SwaggerDoc("Trial", new OpenApiInfo { Title = "项目模块", Version = "Trial" });
options.SwaggerDoc("Enroll", new OpenApiInfo { Title = "入组模块", Version = "Enroll" });
options.SwaggerDoc("Workload", new OpenApiInfo { Title = "工作量模块", Version = "Workload" });
@ -89,8 +94,11 @@ namespace IRaCIS.Core.API
//});
});
}
}
public static void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
if (useSwagger)
{
app.UseDeveloperExceptionPage();
app.UseSwagger();
@ -136,7 +144,7 @@ namespace IRaCIS.Core.API
});
}
}
}
}

View File

@ -49,7 +49,9 @@ namespace IRaCIS.Core.API.Middleware
private async Task<bool> IsValidRequest(HttpContext context)
{
var apiPathList =await _userTypeMenuRepository.Where(x => x.Menu.ApiPath != null && x.Menu.ApiPath != string.Empty)
if (!Jurisdiction.IsSearch)
{
var apiPathList = await _userTypeMenuRepository.Where(x => x.Menu.ApiPath != null && x.Menu.ApiPath != string.Empty)
.Select(x => new MenuApi()
{
@ -58,16 +60,19 @@ namespace IRaCIS.Core.API.Middleware
}).ToListAsync();
apiPathList = apiPathList.Select(x => new MenuApi()
Jurisdiction.MenuActionList = apiPathList.Select(x => new MenuApi()
{
UserTypeEnum = x.UserTypeEnum,
ApiPath = x.ApiPath.ToLower(),
}).ToList();
Jurisdiction.IsSearch = true;
}
if (_userInfo.UserTypeEnumInt != 0)
{
var url = _userInfo.RequestUrl.ToLower(); ;
if (apiPathList.Any(x => x.ApiPath.Contains(url)) && !apiPathList.Any(x => x.ApiPath.Contains(url) && x.UserTypeEnum == _userInfo.UserTypeEnumInt))
if (Jurisdiction.MenuActionList.Any(x => x.ApiPath.Contains(url)) && !Jurisdiction.MenuActionList.Any(x => x.ApiPath.Contains(url) && x.UserTypeEnum == _userInfo.UserTypeEnumInt))
{
return false;
}

View File

@ -102,11 +102,6 @@ namespace IRaCIS.Application.Contracts
}
public class MenuApi
{
public int UserTypeEnum { get; set; }
public string ApiPath { get; set; }
}
}

View File

@ -1,9 +1,25 @@
using IRaCIS.Core.Domain.Models;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Configuration.Json;
using System.Collections.Generic;
namespace IRaCIS.Core.Domain.Share
{
public static class Jurisdiction
{
public static List<MenuApi> MenuActionList { get; set; }=new List<MenuApi> ();
public static bool IsSearch { get; set; } = false;
}
public class MenuApi
{
public int UserTypeEnum { get; set; }
public string ApiPath { get; set; }
}
/// <summary>
/// 多环境 配置环境实体
/// </summary>
@ -42,6 +58,7 @@ namespace IRaCIS.Core.Domain.Share
public static string UserCodePrefix { get; set; }
public static string QCChallengeCodePrefix { get; set; }
public static string DicomStudyCodePrefix { get; set; }