From 57e66259a2276e638ab030638b1d3a8c7565c9b7 Mon Sep 17 00:00:00 2001 From: wanghaomei Date: Mon, 21 Nov 2022 11:09:45 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AD=97=E5=85=B8=E5=89=8D=E7=AB=AF=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Myshipping.Core/Entity/SysDictType.cs | 5 +++++ Myshipping.Core/Myshipping.Core.xml | 16 ++++++++++++++++ .../Service/Dict/Dto/DictDataDto.cs | 2 ++ .../Service/Dict/Dto/DictTypeInput.cs | 5 +++++ .../Service/Dict/SysDictDataService.cs | 19 ++++++++++++++++++- Myshipping.Web.Core/Handlers/JwtHandler.cs | 4 ++++ 6 files changed, 50 insertions(+), 1 deletion(-) diff --git a/Myshipping.Core/Entity/SysDictType.cs b/Myshipping.Core/Entity/SysDictType.cs index 97080299..feb5848b 100644 --- a/Myshipping.Core/Entity/SysDictType.cs +++ b/Myshipping.Core/Entity/SysDictType.cs @@ -42,4 +42,9 @@ public class SysDictType : DEntityBase /// public CommonStatus Status { get; set; } = CommonStatus.ENABLE; + /// + /// 是否前端使用 + /// + public bool IsFront { get; set; } + } diff --git a/Myshipping.Core/Myshipping.Core.xml b/Myshipping.Core/Myshipping.Core.xml index 912f606b..64d470b6 100644 --- a/Myshipping.Core/Myshipping.Core.xml +++ b/Myshipping.Core/Myshipping.Core.xml @@ -2570,6 +2570,11 @@ 状态(字典 0正常 1停用 2删除) + + + 是否前端使用 + + 员工表 @@ -8176,6 +8181,11 @@ 排序 + + + 前端 + + 备注 @@ -8229,6 +8239,12 @@ + + + 获取某个字典类型下字典值列表(前端专用) + + + 增加字典值 diff --git a/Myshipping.Core/Service/Dict/Dto/DictDataDto.cs b/Myshipping.Core/Service/Dict/Dto/DictDataDto.cs index 4d801f2e..f4cfa668 100644 --- a/Myshipping.Core/Service/Dict/Dto/DictDataDto.cs +++ b/Myshipping.Core/Service/Dict/Dto/DictDataDto.cs @@ -20,5 +20,7 @@ namespace Myshipping.Core.Service.Dict.Dto public int Sort { get; set; } public string Remark { get; set; } + + public bool IsFront { get; set; } } } diff --git a/Myshipping.Core/Service/Dict/Dto/DictTypeInput.cs b/Myshipping.Core/Service/Dict/Dto/DictTypeInput.cs index a908c042..09896654 100644 --- a/Myshipping.Core/Service/Dict/Dto/DictTypeInput.cs +++ b/Myshipping.Core/Service/Dict/Dto/DictTypeInput.cs @@ -23,6 +23,11 @@ public class DictTypeInput : PageInputBase /// public virtual int Sort { get; set; } + /// + /// 前端 + /// + public virtual bool IsFront { get; set; } + /// /// 备注 /// diff --git a/Myshipping.Core/Service/Dict/SysDictDataService.cs b/Myshipping.Core/Service/Dict/SysDictDataService.cs index d59ed835..8051e7c5 100644 --- a/Myshipping.Core/Service/Dict/SysDictDataService.cs +++ b/Myshipping.Core/Service/Dict/SysDictDataService.cs @@ -64,6 +64,22 @@ public class SysDictDataService : ISysDictDataService, IDynamicApiController, IT .Where(u => u.Status != CommonStatus.DELETED).OrderBy(u => u.Sort).ToListAsync(); } + + + /// + /// 获取某个字典类型下字典值列表(前端专用) + /// + /// + [HttpGet("/sysDictData/frontList")] + public async Task GetDictDataFrontList(string typeCode) + { + return (await _cache.GetAllDictData()) + .Where(u => u.TypeCode == typeCode) + .Where(u => u.IsFront) + .OrderBy(u => u.Sort) + .ToList(); + } + /// /// 增加字典值 /// @@ -211,7 +227,8 @@ public class SysDictDataService : ISysDictDataService, IDynamicApiController, IT Value = d.Value, Code = d.Code, Sort = d.Sort, - Remark = d.Remark + Remark = d.Remark, + IsFront = t.IsFront }).ToListAsync(); await _cache.SetAllDictData(list); } diff --git a/Myshipping.Web.Core/Handlers/JwtHandler.cs b/Myshipping.Web.Core/Handlers/JwtHandler.cs index 85a11f8c..10f25b2d 100644 --- a/Myshipping.Web.Core/Handlers/JwtHandler.cs +++ b/Myshipping.Web.Core/Handlers/JwtHandler.cs @@ -6,6 +6,7 @@ using Myshipping.Core.Service; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Http; using System.Threading.Tasks; +using Furion.Logging; namespace Myshipping.Web.Core; @@ -51,6 +52,9 @@ public class JwtHandler : AppAuthorizeHandler // 路由名称 var routeName = httpContext.Request.Path.Value.Substring(1).Replace("/", ":"); + //字典数据前端需要,允许获取 + if (routeName == "sysDictData:frontList") return true; + var allPermission = await App.GetService().GetAllPermission(); if (!allPermission.Contains(routeName))