feat 设备连接注册,sap人事范围,部门
This commit is contained in:
27
Src/Dlhis.Sys/Dlhis.Sys.csproj
Normal file
27
Src/Dlhis.Sys/Dlhis.Sys.csproj
Normal file
@@ -0,0 +1,27 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<Nullable>disable</Nullable>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
|
||||
<DockerfileContext>..\..</DockerfileContext>
|
||||
<GenerateDocumentationFile>True</GenerateDocumentationFile>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Compile Remove="log\**" />
|
||||
<Content Remove="log\**" />
|
||||
<EmbeddedResource Remove="log\**" />
|
||||
<None Remove="log\**" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Kurisu.AspNetCore" Version="0.4.7" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Dlhis.Entity\Dlhis.Entity.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
22
Src/Dlhis.Sys/Dockerfile
Normal file
22
Src/Dlhis.Sys/Dockerfile
Normal file
@@ -0,0 +1,22 @@
|
||||
#See https://aka.ms/customizecontainer to learn how to customize your debug container and how Visual Studio uses this Dockerfile to build your images for faster debugging.
|
||||
|
||||
FROM mcr.microsoft.com/dotnet/aspnet:6.0 AS base
|
||||
WORKDIR /app
|
||||
EXPOSE 80
|
||||
|
||||
FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build
|
||||
WORKDIR /src
|
||||
COPY ["Src/Dlhis.Permission/Dlhis.Permission.csproj", "Src/Dlhis.Permission/"]
|
||||
COPY ["Src/Dlhis.Entity/Dlhis.Entity.csproj", "Src/Dlhis.Entity/"]
|
||||
RUN dotnet restore "Src/Dlhis.Permission/Dlhis.Permission.csproj"
|
||||
COPY . .
|
||||
WORKDIR "/src/Src/Dlhis.Permission"
|
||||
RUN dotnet build "Dlhis.Permission.csproj" -c Release -o /app/build
|
||||
|
||||
FROM build AS publish
|
||||
RUN dotnet publish "Dlhis.Permission.csproj" -c Release -o /app/publish /p:UseAppHost=false
|
||||
|
||||
FROM base AS final
|
||||
WORKDIR /app
|
||||
COPY --from=publish /app/publish .
|
||||
ENTRYPOINT ["dotnet", "Dlhis.Permission.dll"]
|
||||
101
Src/Dlhis.Sys/Menu/Controllers/MenusController.cs
Normal file
101
Src/Dlhis.Sys/Menu/Controllers/MenusController.cs
Normal file
@@ -0,0 +1,101 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Dlhis.Sys.Menu.Services;
|
||||
using Dlhis.Sys.Menu.Response;
|
||||
using Dlhis.Sys.Menu.Request;
|
||||
using Dlhis.Entity.Sys.Enums;
|
||||
|
||||
namespace Dlhis.Sys.Menu.Controllers;
|
||||
|
||||
[Authorize]
|
||||
[Route("api/[controller]")]
|
||||
[ApiController]
|
||||
public class MenusController : ControllerBase
|
||||
{
|
||||
private readonly IMenuService _menuService;
|
||||
|
||||
public MenusController(IMenuService menuService)
|
||||
{
|
||||
_menuService = menuService;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 菜单列表
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpGet("list")]
|
||||
public async Task<List<MenuResponse>> GetListAsync([EnumDataType(typeof(PlatformEnumType))] PlatformEnumType? platform)
|
||||
{
|
||||
if (!platform.HasValue)
|
||||
{
|
||||
platform = PlatformEnumType.UserMobile;
|
||||
}
|
||||
return await _menuService.GetListAsync(platform.Value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 保存菜单
|
||||
/// </summary>
|
||||
/// <param name="request"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
public async Task Save(SaveMenuRequest request)
|
||||
{
|
||||
await _menuService.SaveMenuAsync(request);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 分配权限
|
||||
/// </summary>
|
||||
/// <param name="request"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost("assign")]
|
||||
public async Task AssignmentAsync(MenuPermissionAssignmentRequest request)
|
||||
{
|
||||
await _menuService.AssignmentAsync(request);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 当前类型的权限分配
|
||||
/// </summary>
|
||||
/// <param name="permissionType">权限类型</param>
|
||||
/// <param name="uniqueValue">类型对应的唯一值</param>
|
||||
/// <returns></returns>
|
||||
[HttpGet("assignments")]
|
||||
public async Task<List<string>> GetAssignmentsAsync([EnumDataType(typeof(MenuPermissionTypeEnumType))] MenuPermissionTypeEnumType permissionType, [Required] string uniqueValue)
|
||||
{
|
||||
return await _menuService.GetAssignmentCodesAsync(permissionType, uniqueValue);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取所有权限分配
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpGet("assignments/all")]
|
||||
public async Task<List<string>> GetAllAssignmentsAsync()
|
||||
{
|
||||
return await _menuService.GetAllAssignmentPermissionsAsync();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 我的菜单
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpGet("my")]
|
||||
public async Task<List<MenuResponse>> GetCurrentMenusAsync()
|
||||
{
|
||||
return await _menuService.GetCurrentMenusAsync();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 重置
|
||||
/// </summary>
|
||||
/// <param name="request"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost("reset")]
|
||||
public async Task ResetAsync(List<SaveMenuRequest> request)
|
||||
{
|
||||
await _menuService.ResetAsync(request);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using Dlhis.Entity.Sys.Enums;
|
||||
|
||||
namespace Dlhis.Sys.Menu.Request;
|
||||
|
||||
public class MenuPermissionAssignmentRequest
|
||||
{
|
||||
/// <summary>
|
||||
/// 权限类型
|
||||
/// </summary>
|
||||
[EnumDataType(typeof(MenuPermissionTypeEnumType))]
|
||||
public MenuPermissionTypeEnumType UniqueType { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 唯一值
|
||||
/// </summary>
|
||||
[Required]
|
||||
public string UniqueValue { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 权限code
|
||||
/// </summary>
|
||||
public List<string> Codes { get; set; } = new List<string>();
|
||||
}
|
||||
102
Src/Dlhis.Sys/Menu/Request/SaveMenuRequest.cs
Normal file
102
Src/Dlhis.Sys/Menu/Request/SaveMenuRequest.cs
Normal file
@@ -0,0 +1,102 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using Dlhis.Entity.Sys.Enums;
|
||||
|
||||
namespace Dlhis.Sys.Menu.Request;
|
||||
|
||||
public class SaveMenuRequest : IValidatableObject
|
||||
{
|
||||
public int? Id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// code
|
||||
/// </summary>
|
||||
public string Code { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 上级
|
||||
/// </summary>
|
||||
public string PCode { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Name
|
||||
/// </summary>
|
||||
[Required(ErrorMessage = "Name不能为空")]
|
||||
public string Name { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 标题
|
||||
/// </summary>
|
||||
[Required(ErrorMessage = "标题不能为空")]
|
||||
public string Title { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 图标
|
||||
/// </summary>
|
||||
public string Icon { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 路由地址
|
||||
/// </summary>
|
||||
public string Route { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 权限标识
|
||||
/// </summary>
|
||||
public string Permission { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 是否可见
|
||||
/// </summary>
|
||||
public bool? Visible { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 是否为外链
|
||||
/// </summary>
|
||||
public bool IsLink { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 序号
|
||||
/// </summary>
|
||||
public int Sequence { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 菜单类型
|
||||
/// </summary>
|
||||
[EnumDataType(typeof(MenuEnumType))]
|
||||
public MenuEnumType MenuType { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 平台
|
||||
/// </summary>
|
||||
[EnumDataType(typeof(PlatformEnumType))]
|
||||
public PlatformEnumType Platform { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 兼容reset处理
|
||||
/// </summary>
|
||||
public List<SaveMenuRequest> Items { get; set; }
|
||||
|
||||
public IEnumerable<ValidationResult> Validate(ValidationContext validationContext)
|
||||
{
|
||||
if ((MenuType == MenuEnumType.Menu || MenuType == MenuEnumType.Button) && string.IsNullOrEmpty(Permission))
|
||||
{
|
||||
yield return new ValidationResult("当类型为菜单或者按钮时,权限标识不能为空", new[] { nameof(Permission) });
|
||||
}
|
||||
|
||||
if (MenuType == MenuEnumType.Folder && !string.IsNullOrEmpty(PCode))
|
||||
{
|
||||
yield return new ValidationResult("目录类型无需传入上级code", new[] { nameof(PCode) });
|
||||
}
|
||||
|
||||
//自动生成code
|
||||
if (string.IsNullOrEmpty(Code))
|
||||
{
|
||||
Code = Guid.NewGuid().ToString();
|
||||
}
|
||||
|
||||
if (!Visible.HasValue)
|
||||
{
|
||||
Visible = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
81
Src/Dlhis.Sys/Menu/Response/MenuResponse.cs
Normal file
81
Src/Dlhis.Sys/Menu/Response/MenuResponse.cs
Normal file
@@ -0,0 +1,81 @@
|
||||
using Dlhis.Entity.Sys.Enums;
|
||||
|
||||
namespace Dlhis.Sys.Menu.Response;
|
||||
|
||||
public class MenuResponse
|
||||
{
|
||||
public int Id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// code
|
||||
/// </summary>
|
||||
public string Code { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 上级
|
||||
/// </summary>
|
||||
public string PCode { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 标题
|
||||
/// </summary>
|
||||
public string Title { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Name
|
||||
/// </summary>
|
||||
public string Name { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 图标
|
||||
/// </summary>
|
||||
public string Icon { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 路由地址
|
||||
/// </summary>
|
||||
public string Route { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 序号
|
||||
/// </summary>
|
||||
public int Sequence { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 菜单类型
|
||||
/// </summary>
|
||||
public MenuEnumType MenuType { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 是否外链
|
||||
/// </summary>
|
||||
public bool IsLink { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 权限标识
|
||||
/// </summary>
|
||||
public string Permission { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 是否可见
|
||||
/// </summary>
|
||||
public bool Visible { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 平台
|
||||
/// </summary>
|
||||
public PlatformEnumType Platform { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 手机端才会有
|
||||
/// </summary>
|
||||
public List<string> HotelIds { get; set; } = new List<string>();
|
||||
|
||||
/// <summary>
|
||||
/// 子菜单
|
||||
/// </summary>
|
||||
public List<MenuResponse> Items { get; set; }
|
||||
}
|
||||
25
Src/Dlhis.Sys/Menu/Services/IMenuService.cs
Normal file
25
Src/Dlhis.Sys/Menu/Services/IMenuService.cs
Normal file
@@ -0,0 +1,25 @@
|
||||
|
||||
using Dlhis.Entity.Sys.Enums;
|
||||
using Dlhis.Sys.Menu.Request;
|
||||
using Dlhis.Sys.Menu.Response;
|
||||
|
||||
namespace Dlhis.Sys.Menu.Services;
|
||||
|
||||
public interface IMenuService
|
||||
{
|
||||
Task<List<MenuResponse>> GetListAsync(PlatformEnumType platform);
|
||||
|
||||
Task SaveMenuAsync(SaveMenuRequest request);
|
||||
|
||||
Task AssignmentAsync(MenuPermissionAssignmentRequest request);
|
||||
|
||||
Task<List<string>> GetAssignmentCodesAsync(MenuPermissionTypeEnumType permissionType, string uniqueData);
|
||||
|
||||
Task<List<string>> GetAllAssignmentPermissionsAsync();
|
||||
|
||||
Task<List<MenuResponse>> GetCurrentMenusAsync();
|
||||
|
||||
Task<bool> IsPass(IEnumerable<string> p);
|
||||
|
||||
Task ResetAsync(List<SaveMenuRequest> request);
|
||||
}
|
||||
257
Src/Dlhis.Sys/Menu/Services/Implements/MenuService.cs
Normal file
257
Src/Dlhis.Sys/Menu/Services/Implements/MenuService.cs
Normal file
@@ -0,0 +1,257 @@
|
||||
using Dlhis.Entity.Sys.Entities;
|
||||
using Dlhis.Entity.Sys.Enums;
|
||||
using Dlhis.Sys.Menu.Request;
|
||||
using Dlhis.Sys.Menu.Response;
|
||||
using Kurisu.AspNetCore.Utils.Extensions;
|
||||
using Kurisu.Core.User.Abstractions;
|
||||
using Kurisu.SqlSugar.Services;
|
||||
using Mapster;
|
||||
|
||||
namespace Dlhis.Sys.Menu.Services.Implements;
|
||||
|
||||
public class MenuService : IMenuService
|
||||
{
|
||||
private readonly IDbContext _dbContext;
|
||||
private readonly ICurrentUser _currentUser;
|
||||
|
||||
public MenuService(IDbContext dbContext, ICurrentUser currentUser)
|
||||
{
|
||||
_dbContext = dbContext;
|
||||
_currentUser = currentUser;
|
||||
}
|
||||
|
||||
public async Task<List<MenuResponse>> GetListAsync(PlatformEnumType platform)
|
||||
{
|
||||
var result = await _dbContext.Queryable<MenuEntity>()
|
||||
.Where(x => x.Platform == platform)
|
||||
.OrderBy(x => x.Sequence)
|
||||
.Select<MenuResponse>()
|
||||
.ToListAsync();
|
||||
|
||||
var top = result.Where(x => x.PCode.IsEmpty()).ToList();
|
||||
foreach (var menu in top)
|
||||
{
|
||||
RecursionGetNext(menu, result);
|
||||
}
|
||||
|
||||
return top;
|
||||
}
|
||||
|
||||
public async Task SaveMenuAsync(SaveMenuRequest request)
|
||||
{
|
||||
await CheckAsync(request);
|
||||
|
||||
if (!request.Id.HasValue)
|
||||
{
|
||||
var entity = request.Adapt<MenuEntity>();
|
||||
await _dbContext.InsertAsync(entity);
|
||||
}
|
||||
else
|
||||
{
|
||||
var entity = await _dbContext.Queryable<MenuEntity>().Where(x => x.Id == request.Id).FirstAsync();
|
||||
await ChangeIfCodeEditAsync(entity.Code, request.Code);
|
||||
|
||||
request.Adapt(entity);
|
||||
|
||||
await _dbContext.UpdateAsync(entity);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private async Task ChangeIfCodeEditAsync(string beforeCode, string pcode)
|
||||
{
|
||||
if (beforeCode != pcode)
|
||||
{
|
||||
//修改下级的PCode为当前的code
|
||||
var menus = await _dbContext.Queryable<MenuEntity>().Where(x => x.PCode == beforeCode).ToListAsync();
|
||||
menus.ForEach(x => { x.PCode = pcode; });
|
||||
|
||||
//修改权限code为当前的code,避免权限丢失
|
||||
var permissions = await _dbContext.Queryable<MenuPermissionEntity>().Where(x => x.Code == beforeCode).ToListAsync();
|
||||
permissions.ForEach(x => { x.Code = pcode; });
|
||||
|
||||
await _dbContext.UpdateAsync(menus);
|
||||
await _dbContext.UpdateAsync(permissions);
|
||||
}
|
||||
}
|
||||
|
||||
public async Task AssignmentAsync(MenuPermissionAssignmentRequest request)
|
||||
{
|
||||
(request.UniqueType == MenuPermissionTypeEnumType.Role).ThrowIfTrue("暂不支持角色分配");
|
||||
|
||||
//清空覆盖
|
||||
var permissionsToDelete = await _dbContext.Queryable<MenuPermissionEntity>()
|
||||
.Where(x => x.UniqueType == request.UniqueType)
|
||||
.Where(x => x.UniqueValue == request.UniqueValue)
|
||||
.ToListAsync();
|
||||
//触发日志记录
|
||||
await _dbContext.DeleteAsync(permissionsToDelete);
|
||||
|
||||
var permissions = request.Codes.Select(x => new MenuPermissionEntity
|
||||
{
|
||||
Code = x,
|
||||
UniqueType = request.UniqueType,
|
||||
UniqueValue = request.UniqueValue
|
||||
}).ToList();
|
||||
|
||||
|
||||
await _dbContext.InsertAsync(permissions);
|
||||
}
|
||||
|
||||
public Task<List<string>> GetAssignmentCodesAsync(MenuPermissionTypeEnumType permissionType, string uniqueData)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public async Task<List<string>> GetAllAssignmentPermissionsAsync()
|
||||
{
|
||||
var all = await GetAllAssignmentCodesAsync();
|
||||
|
||||
return await _dbContext.Queryable<MenuEntity>().Where(x => all.Contains(x.Code)).Select(x => x.Permission).ToListAsync();
|
||||
}
|
||||
|
||||
public async Task<List<MenuResponse>> GetCurrentMenusAsync()
|
||||
{
|
||||
//我能看到的权限code,非permissions
|
||||
var allCodes = await GetAllAssignmentCodesAsync();
|
||||
if (!allCodes.Any())
|
||||
{
|
||||
return await GetListAsync(PlatformEnumType.PCAdmin);
|
||||
}
|
||||
|
||||
var allMenus = await _dbContext.Queryable<MenuEntity>()
|
||||
.Where(x => x.Platform == PlatformEnumType.PCAdmin)
|
||||
.Where(x => x.Visible)
|
||||
.Where(x => allCodes.Contains(x.Code))
|
||||
.Select<MenuResponse>()
|
||||
.ToListAsync();
|
||||
|
||||
//获取顶级数据
|
||||
var menus = await _dbContext.Queryable<MenuEntity>()
|
||||
.Where(x => x.Platform == PlatformEnumType.PCAdmin)
|
||||
.Where(x => x.Visible)
|
||||
.Where(x => string.IsNullOrEmpty(x.PCode))
|
||||
.Select<MenuResponse>()
|
||||
.ToListAsync();
|
||||
|
||||
foreach (var menu in menus)
|
||||
{
|
||||
RecursionGetNext(menu, allMenus);
|
||||
}
|
||||
|
||||
menus.RemoveAll(x => !x.Items.Any());
|
||||
return menus;
|
||||
}
|
||||
|
||||
public async Task<bool> IsPass(IEnumerable<string> p)
|
||||
{
|
||||
var permissions = await GetAllAssignmentPermissionsAsync();
|
||||
return permissions.Count == 0 || permissions.All(x => p.Contains(x));
|
||||
}
|
||||
|
||||
public async Task ResetAsync(List<SaveMenuRequest> request)
|
||||
{
|
||||
var menus = await _dbContext.Queryable<MenuEntity>().Where(x => x.Platform == PlatformEnumType.PCAdmin).ToListAsync();
|
||||
await _dbContext.Client.Deleteable(menus).ExecuteCommandAsync();
|
||||
|
||||
foreach (var item in request)
|
||||
{
|
||||
await SaveMenuAsync(item);
|
||||
if (item.Items?.Any() == true)
|
||||
{
|
||||
await RecursionSaveNextAsync(item.Items);
|
||||
}
|
||||
}
|
||||
|
||||
//递归处理下一级
|
||||
async Task RecursionSaveNextAsync(List<SaveMenuRequest> menus)
|
||||
{
|
||||
foreach (var item in menus)
|
||||
{
|
||||
await SaveMenuAsync(item);
|
||||
if (item.Items?.Any() == true)
|
||||
{
|
||||
await RecursionSaveNextAsync(item.Items);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void RecursionGetNext(MenuResponse current, List<MenuResponse> menus)
|
||||
{
|
||||
var nextMenus = menus.Where(x => x.PCode == current.Code).ToList();
|
||||
current.Items = nextMenus;
|
||||
foreach (var menu in nextMenus)
|
||||
{
|
||||
RecursionGetNext(menu, menus);
|
||||
}
|
||||
}
|
||||
|
||||
private async Task CheckAsync(SaveMenuRequest request)
|
||||
{
|
||||
//检查重复code
|
||||
var exists = await _dbContext.Queryable<MenuEntity>()
|
||||
.Where(x => x.Code == request.Code)
|
||||
.WhereIF(request.Id.HasValue, x => x.Id != request.Id).AnyAsync();
|
||||
exists.ThrowIfTrue($"{request.Title}存在重复code");
|
||||
|
||||
//检查name
|
||||
exists = await _dbContext.Queryable<MenuEntity>()
|
||||
.Where(x => x.Name == request.Name)
|
||||
.WhereIF(request.Id.HasValue, x => x.Id != request.Id).AnyAsync();
|
||||
exists.ThrowIfTrue($"{request.Title}存在重复name");
|
||||
|
||||
//判断权限重复
|
||||
if (request.Permission.IsPresent())
|
||||
{
|
||||
exists = await _dbContext.Queryable<MenuEntity>()
|
||||
.Where(x => x.Permission == request.Permission && (request.MenuType == MenuEnumType.Menu || request.MenuType == MenuEnumType.Button))
|
||||
.WhereIF(request.Id.HasValue, x => x.Id != request.Id).AnyAsync();
|
||||
exists.ThrowIfTrue($"{request.Title}存在重复权限标识");
|
||||
}
|
||||
|
||||
//request.PCode
|
||||
var menu = await _dbContext.Queryable<MenuEntity>().Where(x => x.Code == request.PCode).FirstAsync();
|
||||
(menu == null && request.MenuType != MenuEnumType.Folder).ThrowIfTrue($"{request.Title}上级不存在");
|
||||
|
||||
if (request.MenuType == MenuEnumType.Folder)
|
||||
{
|
||||
request.PCode = null;
|
||||
}
|
||||
else if (request.MenuType == MenuEnumType.Menu)
|
||||
{
|
||||
if (menu.MenuType != MenuEnumType.Folder)
|
||||
{
|
||||
throw new Exception($"{request.Title}菜单上级需要为目录");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//button
|
||||
if (menu.MenuType != MenuEnumType.Menu)
|
||||
{
|
||||
throw new Exception($"{request.Title}按钮上级需要为菜单");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private async Task<List<string>> GetAllAssignmentCodesAsync()
|
||||
{
|
||||
var user = await _dbContext.Queryable<UserEntity>().Where(x => x.Id == _currentUser.GetIntSubjectId()).FirstAsync();
|
||||
if (user == null)
|
||||
{
|
||||
return new List<string>();
|
||||
}
|
||||
|
||||
// var gP = await GetAssignmentCodesAsync(MenuPermissionTypeEnumType.Group, manager.usergrp);
|
||||
//
|
||||
// //user
|
||||
// var uP = await GetAssignmentCodesAsync(MenuPermissionTypeEnumType.User, manager.account);
|
||||
// var all = gP.Concat(uP).Distinct().ToList();
|
||||
|
||||
//return all;
|
||||
|
||||
return new List<string>();
|
||||
}
|
||||
}
|
||||
21
Src/Dlhis.Sys/Program.cs
Normal file
21
Src/Dlhis.Sys/Program.cs
Normal file
@@ -0,0 +1,21 @@
|
||||
using Kurisu.AspNetCore.Startup;
|
||||
using Kurisu.Startup;
|
||||
|
||||
namespace Dlhis.Sys
|
||||
{
|
||||
class Program
|
||||
{
|
||||
static void Main(string[] args)
|
||||
{
|
||||
KurisuHost.Run<Startup>(true, args);
|
||||
}
|
||||
}
|
||||
|
||||
public class Startup : DefaultStartup
|
||||
{
|
||||
public Startup(IConfiguration configuration) : base(configuration)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
20
Src/Dlhis.Sys/Properties/launchSettings.json
Normal file
20
Src/Dlhis.Sys/Properties/launchSettings.json
Normal file
@@ -0,0 +1,20 @@
|
||||
{
|
||||
"profiles": {
|
||||
"Dlhis.Permission": {
|
||||
"commandName": "Project",
|
||||
"environmentVariables": {
|
||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||
},
|
||||
"dotnetRunMessages": true,
|
||||
"applicationUrl": "http://localhost:5003"
|
||||
},
|
||||
"Docker": {
|
||||
"commandName": "Docker",
|
||||
"launchUrl": "{Scheme}://{ServiceHost}:{ServicePort}",
|
||||
"environmentVariables": {
|
||||
"ASPNETCORE_URLS": "http://+:80"
|
||||
},
|
||||
"publishAllPorts": true
|
||||
}
|
||||
}
|
||||
}
|
||||
8
Src/Dlhis.Sys/appsettings.Development.json
Normal file
8
Src/Dlhis.Sys/appsettings.Development.json
Normal file
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"Logging": {
|
||||
"LogLevel": {
|
||||
"Default": "Information",
|
||||
"Microsoft.AspNetCore": "Warning"
|
||||
}
|
||||
}
|
||||
}
|
||||
62
Src/Dlhis.Sys/appsettings.json
Normal file
62
Src/Dlhis.Sys/appsettings.json
Normal file
@@ -0,0 +1,62 @@
|
||||
{
|
||||
"Logging": {
|
||||
"LogLevel": {
|
||||
"Default": "Information",
|
||||
"Microsoft.AspNetCore": "Warning"
|
||||
}
|
||||
},
|
||||
"AllowedHosts": "*",
|
||||
"SwaggerOptions": {
|
||||
"Enable": true,
|
||||
"Authority": "https://yikatong.isawesome.cn/oauth2",
|
||||
"ClientId": "4fb184324eac4180",
|
||||
"ClientSecret": "8ac8f235152f1524",
|
||||
"Scopes": {
|
||||
"openid": "openid"
|
||||
}
|
||||
},
|
||||
"IdentityServerOptions": {
|
||||
"Authority": "https://yikatong.isawesome.cn/oauth2",
|
||||
"RequireHttpsMetadata": true,
|
||||
"Issuer": "identity.isawesome.cn",
|
||||
"Audience": "",
|
||||
"Pat": {
|
||||
"Enable": false,
|
||||
"Scheme": "token",
|
||||
"ClientId": "reference",
|
||||
"ClientSecret": "123456"
|
||||
}
|
||||
},
|
||||
"Serilog": {
|
||||
"MinimumLevel": {
|
||||
"Default": "Information",
|
||||
"Override": {
|
||||
"System": "Warning",
|
||||
"Microsoft": "Warning",
|
||||
"Microsoft.Hosting.Lifetime": "Information"
|
||||
}
|
||||
},
|
||||
"WriteTo": [
|
||||
{
|
||||
"Name": "Async",
|
||||
"Args": {
|
||||
"configure": [
|
||||
{
|
||||
"Name": "Console",
|
||||
"Args": {
|
||||
"outputTemplate": "[{Timestamp:HH:mm:ss} {Level:u3}] [{SourceContext}] {Message:lj}{NewLine}{Exception}"
|
||||
}
|
||||
},
|
||||
{
|
||||
"Name": "File",
|
||||
"Args": {
|
||||
"path": "log/log.txt",
|
||||
"rollingInterval": "Hour"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user