From 8c6fd742db249ad4cc819cf041eb98d880a3ef73 Mon Sep 17 00:00:00 2001
From: hutongqing <hutongqing@hnkhzn.com>
Date: 星期四, 02 一月 2025 15:09:07 +0800
Subject: [PATCH] 1

---
 WIDESEAWCS_Server/WIDESEAWCS_SystemRepository/Sys_MenuRepository.cs |   22 ++++++++++++++--------
 1 files changed, 14 insertions(+), 8 deletions(-)

diff --git a/WIDESEAWCS_Server/WIDESEAWCS_SystemRepository/Sys_MenuRepository.cs b/WIDESEAWCS_Server/WIDESEAWCS_SystemRepository/Sys_MenuRepository.cs
index e58f5a0..12b9dc6 100644
--- a/WIDESEAWCS_Server/WIDESEAWCS_SystemRepository/Sys_MenuRepository.cs
+++ b/WIDESEAWCS_Server/WIDESEAWCS_SystemRepository/Sys_MenuRepository.cs
@@ -1,9 +1,13 @@
-锘縰sing System;
+锘縰sing AutoMapper;
+using SqlSugar;
+using System;
 using System.Collections.Concurrent;
 using System.Collections.Generic;
+using System.Drawing;
 using System.Linq;
 using System.Text;
 using System.Threading.Tasks;
+using WIDESEA_DTO.System;
 using WIDESEAWCS_Core;
 using WIDESEAWCS_Core.BaseRepository;
 using WIDESEAWCS_Core.Helper;
@@ -15,14 +19,16 @@
 {
     public class Sys_MenuRepository : RepositoryBase<Sys_Menu>, ISys_MenuRepository
     {
-        public Sys_MenuRepository(IUnitOfWorkManage unitOfWorkManage) : base(unitOfWorkManage)
+        private readonly IMapper _mapper;
+        public Sys_MenuRepository(IUnitOfWorkManage unitOfWorkManage, IMapper mapper) : base(unitOfWorkManage)
         {
+            _mapper = mapper;
         }
 
-        public List<Sys_Menu> GetAllMenu()
+        public List<MenuDTO> GetAllMenu()
         {
-            List<Sys_Menu> _menus = base.QueryData(x => x.Enable == 1 || x.Enable == 2).OrderByDescending(a => a.OrderNo).ThenByDescending(q => q.ParentId).ToList();
-
+            List<Sys_Menu> menus = base.QueryData(x => x.Enable == 1 || x.Enable == 2).OrderByDescending(a => a.OrderNo).ThenByDescending(q => q.ParentId).ToList();
+            List<MenuDTO> _menus = _mapper.Map<List<MenuDTO>>(menus);
             _menus.ForEach(x =>
             {
                 x.MenuType ??= 0;
@@ -30,11 +36,11 @@
                 {
                     try
                     {
-                        x.Actions = x.Auth.DeserializeObject<List<Sys_Actions>>();
+                        x.Actions = x.Auth.DeserializeObject<List<ActionDTO>>();
                     }
                     catch { }
                 }
-                x.Actions ??= new List<Sys_Actions>();
+                x.Actions ??= new List<ActionDTO>();
             });
             string test = _menus.Serialize();
             return _menus;
@@ -105,7 +111,7 @@
             {
                 //娌℃湁redis/memory缂撳瓨瑙掕壊鐨勭増鏈彿鎴栦笌褰撳墠鏈嶅姟鍣ㄧ殑瑙掕壊鐗堟湰鍙蜂笉鍚屾椂锛屽埛鏂扮紦瀛�
 
-                List<Permissions> _permissions = QueryTabs<Sys_Menu, Sys_RoleAuth, Permissions>((a, b) => new object[] { a.MenuId, b.MenuId }, (a, b) => new Permissions { MenuId = a.MenuId, ParentId = a.ParentId, TableName = (a.TableName ?? "").ToLower(), MenuAuth = a.Auth, UserAuth = b.AuthValue ?? "", MenuType = a.MenuType ?? 0 }, x => true);
+                List<Permissions> _permissions = QueryTabs<Sys_Menu, Sys_RoleAuth, Permissions>((a, b) => new object[] { JoinType.Inner, a.MenuId == b.MenuId }, (a, b) => new Permissions { MenuId = a.MenuId, ParentId = a.ParentId, TableName = (a.TableName ?? "").ToLower(), MenuAuth = a.Auth, UserAuth = b.AuthValue ?? "", MenuType = a.MenuType ?? 0 }, (a, b) => b.RoleId == roleId, x => true);
 
                 ActionToArray(_permissions);
 

--
Gitblit v1.9.3