From be42500d2c21da97dfdfe908adebe30c2eb254fa Mon Sep 17 00:00:00 2001
From: hutongqing <hutongqing@hnkhzn.com>
Date: 星期五, 25 十月 2024 16:18:11 +0800
Subject: [PATCH] 更新字典获取
---
/dev/null | 0
WIDESEAWCS_Server/.vs/WIDESEAWCS_Server/FileContentIndex/2e039f01-75fb-4752-a777-4084d6de71ac.vsidx | 0
WIDESEAWCS_Server/WIDESEAWCS_SystemServices/Sys_UserService.cs | 14 ++++
WIDESEAWCS_Server/WIDESEAWCS_SystemServices/Sys_RoleService.cs | 2
WIDESEAWCS_Server/WIDESEAWCS_ISystemServices/ISys_MenuService.cs | 1
WIDESEAWCS_Server/WIDESEAWCS_SystemRepository/Sys_DictionaryRepository.cs | 32 +++++-----
WIDESEAWCS_Server/WIDESEAWCS_Tasks/WIDESEAWCS_Tasks.csproj | 2
WIDESEAWCS_Server/WIDESEAWCS_SystemServices/Sys_DictionaryService.cs | 97 ++++++++++++++++++++++++++------
8 files changed, 111 insertions(+), 37 deletions(-)
diff --git a/WIDESEAWCS_Server/.vs/WIDESEAWCS_Server/FileContentIndex/2e039f01-75fb-4752-a777-4084d6de71ac.vsidx b/WIDESEAWCS_Server/.vs/WIDESEAWCS_Server/FileContentIndex/2e039f01-75fb-4752-a777-4084d6de71ac.vsidx
new file mode 100644
index 0000000..6ea196f
--- /dev/null
+++ b/WIDESEAWCS_Server/.vs/WIDESEAWCS_Server/FileContentIndex/2e039f01-75fb-4752-a777-4084d6de71ac.vsidx
Binary files differ
diff --git a/WIDESEAWCS_Server/.vs/WIDESEAWCS_Server/FileContentIndex/7dc1175d-35b9-490c-9810-66c8a03b0b35.vsidx b/WIDESEAWCS_Server/.vs/WIDESEAWCS_Server/FileContentIndex/7dc1175d-35b9-490c-9810-66c8a03b0b35.vsidx
deleted file mode 100644
index 041f50f..0000000
--- a/WIDESEAWCS_Server/.vs/WIDESEAWCS_Server/FileContentIndex/7dc1175d-35b9-490c-9810-66c8a03b0b35.vsidx
+++ /dev/null
Binary files differ
diff --git a/WIDESEAWCS_Server/WIDESEAWCS_ISystemServices/ISys_MenuService.cs b/WIDESEAWCS_Server/WIDESEAWCS_ISystemServices/ISys_MenuService.cs
index 7325119..1309279 100644
--- a/WIDESEAWCS_Server/WIDESEAWCS_ISystemServices/ISys_MenuService.cs
+++ b/WIDESEAWCS_Server/WIDESEAWCS_ISystemServices/ISys_MenuService.cs
@@ -12,6 +12,7 @@
public interface ISys_MenuService : IService<Sys_Menu>
{
object GetCurrentMenuActionList();
+ object GetMenuActionList(int roleId);
List<Sys_Menu> GetUserMenuList(int roleId);
diff --git a/WIDESEAWCS_Server/WIDESEAWCS_SystemRepository/Sys_DictionaryRepository.cs b/WIDESEAWCS_Server/WIDESEAWCS_SystemRepository/Sys_DictionaryRepository.cs
index f90799d..970ffbc 100644
--- a/WIDESEAWCS_Server/WIDESEAWCS_SystemRepository/Sys_DictionaryRepository.cs
+++ b/WIDESEAWCS_Server/WIDESEAWCS_SystemRepository/Sys_DictionaryRepository.cs
@@ -23,22 +23,22 @@
/// <param name="dicNos"></param>
/// <param name="executeSql">鏄惁鎵ц鑷畾涔塻ql</param>
/// <returns></returns>
- public IEnumerable<Sys_Dictionary> GetDictionaries(IEnumerable<string> dicNos, bool executeSql = true)
+ public IEnumerable<Sys_Dictionary> GetDictionaries(IEnumerable<string> dicNos, bool executeSql = false)
{
- List<Sys_Dictionary> Dictionaries = GetAllDictionary();
+ List<Sys_Dictionary> Dictionaries = GetAllDictionary(dicNos);
- foreach (var item in Dictionaries.Where(x => dicNos.Contains(x.DicNo)))
- {
- if (executeSql)
- {
- // 2020.05.01澧炲姞鏍规嵁鐢ㄦ埛淇℃伅鍔犺浇瀛楀吀鏁版嵁婧恠ql
- string sql = item.DBSql;
- if (!string.IsNullOrEmpty(sql))
- {
- item.DicList = Query(sql);
- }
- }
- }
+ //foreach (var item in Dictionaries.Where(x => dicNos.Contains(x.DicNo)))
+ //{
+ // if (executeSql)
+ // {
+ // // 2020.05.01澧炲姞鏍规嵁鐢ㄦ埛淇℃伅鍔犺浇瀛楀吀鏁版嵁婧恠ql
+ // string sql = item.DBSql;
+ // if (!string.IsNullOrEmpty(sql))
+ // {
+ // item.DicList = Query(sql);
+ // }
+ // }
+ //}
return Dictionaries;
}
@@ -59,10 +59,10 @@
}
}
- private List<Sys_Dictionary> GetAllDictionary()
+ private List<Sys_Dictionary> GetAllDictionary(IEnumerable<string> dicNos)
{
//base.QueryData().ToList();
- List<Sys_Dictionary> _dictionaries = Db.Queryable<Sys_Dictionary>().Includes(x => x.DicList).Where(x => x.Enable == 1).ToList();
+ List<Sys_Dictionary> _dictionaries = Db.Queryable<Sys_Dictionary>().Includes(x => x.DicList).Where(x => x.Enable == 1 && dicNos.Contains(x.DicNo)).ToList();
return _dictionaries;
}
}
diff --git a/WIDESEAWCS_Server/WIDESEAWCS_SystemServices/Sys_DictionaryService.cs b/WIDESEAWCS_Server/WIDESEAWCS_SystemServices/Sys_DictionaryService.cs
index cbf757b..e04fe7a 100644
--- a/WIDESEAWCS_Server/WIDESEAWCS_SystemServices/Sys_DictionaryService.cs
+++ b/WIDESEAWCS_Server/WIDESEAWCS_SystemServices/Sys_DictionaryService.cs
@@ -1,12 +1,18 @@
锘縰sing Newtonsoft.Json;
+using OfficeOpenXml.FormulaParsing.Excel.Functions.DateTime;
using System;
using System.Collections.Generic;
+using System.ComponentModel;
using System.Linq;
+using System.Reflection;
using System.Text;
using System.Threading.Tasks;
+using WIDESEAWCS_Common.TaskEnum;
using WIDESEAWCS_Core.BaseRepository;
using WIDESEAWCS_Core.BaseServices;
+using WIDESEAWCS_Core.Caches;
using WIDESEAWCS_Core.DB;
+using WIDESEAWCS_Core.Enums;
using WIDESEAWCS_Core.Helper;
using WIDESEAWCS_DTO.System;
using WIDESEAWCS_ISystemRepository;
@@ -18,37 +24,92 @@
public class Sys_DictionaryService : ServiceBase<Sys_Dictionary, ISys_DictionaryRepository>, ISys_DictionaryService
{
private readonly IUnitOfWorkManage _unitOfWorkManage;
- public Sys_DictionaryService(ISys_DictionaryRepository BaseDal, IUnitOfWorkManage unitOfWorkManage) : base(BaseDal)
+ private readonly ICacheService _cacheService;
+
+ public Sys_DictionaryService(ISys_DictionaryRepository BaseDal, IUnitOfWorkManage unitOfWorkManage, ICacheService cacheService) : base(BaseDal)
{
_unitOfWorkManage = unitOfWorkManage;
+ _cacheService = cacheService;
}
public List<VueDictionaryDTO> GetVueDictionary(string[] dicNos)
{
if (dicNos == null || dicNos.Count() == 0) return new List<VueDictionaryDTO>();
+ List<VueDictionaryDTO> vueDictionaryDTOs = new List<VueDictionaryDTO>();
- var dicConfig = BaseDal.GetDictionaries(dicNos, false).Select(s => new
+ List<string> cacheDicNos = new List<string>();
+ foreach (string n in dicNos)
{
- dicNo = s.DicNo,
- config = s.Config,
- dbSql = s.DBSql,
- list = s.DicList.OrderByDescending(o => o.OrderNo).Select(list => new { key = list.DicValue, value = list.DicName })
- }).ToList();
-
- object GetSourceData(string dicNo, string dbSql, object data)
- {
- if (string.IsNullOrEmpty(dbSql))
+ string str = _cacheService.Get(n);
+ if (!string.IsNullOrEmpty(str))
{
- return data;
+ VueDictionaryDTO? vueDictionary = JsonConvert.DeserializeObject<VueDictionaryDTO>(str);
+
+ if (vueDictionary != null)
+ {
+ vueDictionaryDTOs.Add(vueDictionary);
+ cacheDicNos.Add(n);
+ }
}
- return BaseDal.QueryObjectDataBySql(dbSql, null);
}
- return dicConfig.Select(item => new VueDictionaryDTO
+ if (dicNos.Where(x => !cacheDicNos.Contains(x)).Count() > 0)
{
- DicNo = item.dicNo,
- Config = item.config,
- Data = GetSourceData(item.dicNo, item.dbSql, item.list)
- }).ToList();
+ List<string> list = dicNos.Where(x => !cacheDicNos.Contains(x)).ToList();
+ List<Sys_Dictionary> dictionaries = BaseDal.GetDictionaries(list).ToList();
+
+ List<VueDictionaryDTO> selectDics = dictionaries.Select(s => new VueDictionaryDTO
+ {
+ DicNo = s.DicNo,
+ Config = s.Config,
+ //dbSql = s.Sql,
+ Data = s.DicList.OrderByDescending(o => o.OrderNo).Select(list => new { key = list.DicValue, value = list.DicName })
+ }).ToList();
+
+ foreach (var v in dictionaries)
+ {
+ if (!string.IsNullOrEmpty(v.DBSql))
+ {
+ VueDictionaryDTO? temp = selectDics.FirstOrDefault(x => x.DicNo == v.DicNo);
+ if (temp != null)
+ selectDics.Remove(temp);
+ selectDics.Add(new VueDictionaryDTO
+ {
+ Config = v.Config,
+ DicNo = v.DicNo,
+ Data = BaseDal.QueryDynamicDataBySql(v.DBSql)
+ });
+ }
+ }
+
+ foreach (var item in selectDics)
+ {
+ if (!_cacheService.Exists(item.DicNo))
+ {
+ _cacheService.Add(item.DicNo, item.Serialize());
+ }
+ }
+ vueDictionaryDTOs.AddRange(selectDics);
+ }
+
+ //object GetSourceData(string dicNo, string dbSql, object data)
+ //{
+ // if (string.IsNullOrEmpty(dbSql))
+ // {
+ // return data;
+ // }
+ // return BaseDal.QueryObjectDataBySql(dbSql, null);
+ //}
+ //List<VueDictionaryDTO> vueDictionaryDTOs = dicConfig.Select(item => new VueDictionaryDTO
+ //{
+ // DicNo = item.dicNo,
+ // Config = item.config,
+ // Data = GetSourceData(item.dicNo, item.dbSql, item.list)
+ //}).ToList();
+
+
+ return vueDictionaryDTOs;
}
+
+
}
}
diff --git a/WIDESEAWCS_Server/WIDESEAWCS_SystemServices/Sys_RoleService.cs b/WIDESEAWCS_Server/WIDESEAWCS_SystemServices/Sys_RoleService.cs
index c75161f..88811c2 100644
--- a/WIDESEAWCS_Server/WIDESEAWCS_SystemServices/Sys_RoleService.cs
+++ b/WIDESEAWCS_Server/WIDESEAWCS_SystemServices/Sys_RoleService.cs
@@ -192,7 +192,7 @@
x.AuthValue = "";
});
//灏嗗彇娑堢殑鏉冮檺璁剧疆涓�""
- _RoleAuthRepository.UpdateData(delAuths);
+ _RoleAuthRepository.DeleteData(delAuths);
int addCount = updateAuths.Where(x => x.AuthId <= 0).Count();
int updateCount = updateAuths.Where(x => x.AuthId > 0).Count();
diff --git a/WIDESEAWCS_Server/WIDESEAWCS_SystemServices/Sys_UserService.cs b/WIDESEAWCS_Server/WIDESEAWCS_SystemServices/Sys_UserService.cs
index 874ff8f..2c740c4 100644
--- a/WIDESEAWCS_Server/WIDESEAWCS_SystemServices/Sys_UserService.cs
+++ b/WIDESEAWCS_Server/WIDESEAWCS_SystemServices/Sys_UserService.cs
@@ -18,10 +18,12 @@
{
private readonly IUnitOfWorkManage _unitOfWorkManage;
private readonly ICacheService _cacheService;
- public Sys_UserService(ISys_UserRepository repository, IUnitOfWorkManage unitOfWorkManage, ICacheService cacheService) : base(repository)
+ private readonly ISys_MenuService _menuService;
+ public Sys_UserService(ISys_UserRepository repository, IUnitOfWorkManage unitOfWorkManage, ICacheService cacheService, ISys_MenuService menuService) : base(repository)
{
_unitOfWorkManage = unitOfWorkManage;
_cacheService = cacheService;
+ _menuService = menuService;
}
public WebResponseContent Login(LoginInfo loginInfo)
@@ -47,6 +49,16 @@
UserInfo user = BaseDal.GetUserInfo(loginInfo.UserName, loginInfo.Password);
if (user != null)
{
+ object obj = _menuService.GetMenuActionList(user.RoleId);
+ if (obj is not IEnumerable<object> list)
+ {
+ return WebResponseContent.Instance.Error("鏃犵櫥褰曟潈闄�");
+ }
+ if (!list.Any())
+ {
+ return WebResponseContent.Instance.Error("鏃犵櫥褰曟潈闄�");
+ }
+
string token = JwtHelper.IssueJwt(new TokenModelJwt()
{
UserId = user.UserId,
diff --git a/WIDESEAWCS_Server/WIDESEAWCS_Tasks/WIDESEAWCS_Tasks.csproj b/WIDESEAWCS_Server/WIDESEAWCS_Tasks/WIDESEAWCS_Tasks.csproj
index fd5b6b6..d7b9760 100644
--- a/WIDESEAWCS_Server/WIDESEAWCS_Tasks/WIDESEAWCS_Tasks.csproj
+++ b/WIDESEAWCS_Server/WIDESEAWCS_Tasks/WIDESEAWCS_Tasks.csproj
@@ -7,7 +7,7 @@
</PropertyGroup>
<ItemGroup>
- <PackageReference Include="WIDESEAWCS_QuartzJob" Version="1.0.0" />
+ <PackageReference Include="WIDESEAWCS_QuartzJob" Version="2.0.3" />
</ItemGroup>
<ItemGroup>
--
Gitblit v1.9.3