From cbf06cbb2e7988fdee53507dede034756ebfbf59 Mon Sep 17 00:00:00 2001
From: hutongqing <hutongqing@hnkhzn.com>
Date: 星期二, 14 一月 2025 15:47:40 +0800
Subject: [PATCH] 1
---
代码管理/WMS/WIDESEA_WMSServer/WIDESEA_SystemService/Sys_RoleService.cs | 102 +++++++++++++++++++++++++++++++++++++++++++++++++--
1 files changed, 98 insertions(+), 4 deletions(-)
diff --git "a/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_SystemService/Sys_RoleService.cs" "b/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_SystemService/Sys_RoleService.cs"
index 030a5ea..db45659 100644
--- "a/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_SystemService/Sys_RoleService.cs"
+++ "b/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_SystemService/Sys_RoleService.cs"
@@ -15,6 +15,8 @@
using WIDESEA_Model.Models;
using WIDESEA_Model.Models.System;
using WIDESEA_SystemRepository;
+using WIDESEA_Core.Helper;
+using WIDESEA_Core.HostedService;
namespace WIDESEA_SystemService
{
@@ -35,6 +37,98 @@
_RoleAuthRepository = roleAuthRepository;
}
+ public override WebResponseContent AddData(SaveModel saveModel)
+ {
+ string authorityScope = saveModel.MainData["authorityScope"].ToString() ?? "";
+ Sys_Role role = saveModel.MainData.DicToModel<Sys_Role>();
+ if (BaseDal.QueryFirst(x => x.RoleName == role.RoleName) != null)
+ {
+ return WebResponseContent.Instance.Error($"瑙掕壊鍚嶉噸澶�");
+ }
+ List<Dt_Warehouse> warehouses = BaseDal.Db.Queryable<Dt_Warehouse>().Where(x => true).ToList();
+ List<Sys_RoleDataPermission> roleDataPermissions = new List<Sys_RoleDataPermission>();
+ if (!string.IsNullOrEmpty(authorityScope))
+ {
+ string[] scopes = authorityScope.Split(',');
+ foreach (string scope in scopes)
+ {
+ Dt_Warehouse? warehouse = warehouses.FirstOrDefault(x => x.WarehouseId == Convert.ToInt32(scope));
+ if (warehouse != null)
+ {
+ roleDataPermissions.Add(new Sys_RoleDataPermission
+ {
+ WarehouseId = warehouse.WarehouseId,
+ WarehouseName = warehouse.WarehouseName,
+ RoleName = role.RoleName
+ });
+ }
+ }
+ }
+
+ int roleId = BaseDal.AddData(role);
+ if (roleDataPermissions.Count > 0)
+ {
+ roleDataPermissions.ForEach(x => { x.RoleId = roleId; });
+ BaseDal.Db.Insertable(roleDataPermissions).ExecuteCommand();
+ }
+
+ PermissionDataHostService.UserRoles = PermissionDataHostService.GetUserRoles(Db);
+
+ return WebResponseContent.Instance.OK();
+ }
+
+ public override WebResponseContent UpdateData(SaveModel saveModel)
+ {
+ string authorityScope = saveModel.MainData["authorityScope"].ToString() ?? "";
+ Sys_Role role = saveModel.MainData.DicToModel<Sys_Role>();
+ if (BaseDal.QueryFirst(x => x.RoleId == role.RoleId) == null)
+ {
+ return WebResponseContent.Instance.Error($"鏈壘鍒拌鏁版嵁");
+ }
+ List<Dt_Warehouse> warehouses = BaseDal.Db.Queryable<Dt_Warehouse>().Where(x => true).ToList();
+
+ List<Sys_RoleDataPermission> oldDatas = BaseDal.Db.Queryable<Sys_RoleDataPermission>().Where(x => x.RoleId == role.RoleId).ToList();
+ List<Sys_RoleDataPermission> roleDataPermissions = new List<Sys_RoleDataPermission>();
+ if (!string.IsNullOrEmpty(authorityScope))
+ {
+ string[] scopes = authorityScope.Split(',');
+ foreach (string scope in scopes)
+ {
+ Sys_RoleDataPermission? oldData = oldDatas.FirstOrDefault(x => x.WarehouseId == Convert.ToInt32(scope));
+ if (oldData == null)
+ {
+ Dt_Warehouse? warehouse = warehouses.FirstOrDefault(x => x.WarehouseId == Convert.ToInt32(scope));
+ if (warehouse != null)
+ {
+ roleDataPermissions.Add(new Sys_RoleDataPermission
+ {
+ WarehouseId = warehouse.WarehouseId,
+ WarehouseName = warehouse.WarehouseName,
+ RoleName = role.RoleName
+ });
+ }
+ }
+ else
+ {
+ oldDatas.Remove(oldData);
+ }
+ }
+ }
+
+ roleDataPermissions.ForEach(x => { x.RoleId = role.RoleId; });
+ BaseDal.Db.Insertable(roleDataPermissions).ExecuteCommand();
+ BaseDal.Db.Deleteable(oldDatas).ExecuteCommand();
+
+ PermissionDataHostService.UserRoles = PermissionDataHostService.GetUserRoles(Db);
+
+ return WebResponseContent.Instance.OK();
+ }
+
+ public List<int> GetAllChildrenRoleId(int roleId)
+ {
+ return GetAllChildren(roleId).Select(x => x.Id).ToList();
+ }
+
public List<RoleNodes> GetAllChildren(int roleId)
{
if (roleId <= 0) return new List<RoleNodes>() { };
@@ -45,7 +139,7 @@
return list;
}
- public List<RoleNodes> GetAllRoleId()
+ public List<RoleNodes> GetAllRoleId()
{
List<RoleNodes> roles = BaseDal.QueryData().Select(s => new RoleNodes() { Id = s.RoleId, ParentId = s.ParentId, RoleName = s.RoleName }).ToList();
@@ -110,7 +204,7 @@
//鑾峰彇鐢ㄦ埛鏉冮檺
List<Permissions> permissions = _MenuRepository.GetPermissions(roleId);
//鏉冮檺鐢ㄦ埛鏉冮檺鏌ヨ鎵�鏈夌殑鑿滃崟淇℃伅
- List<MenuDTO> menus = _MenuService.GetUserMenuList(roleId);
+ List<MenuDTO> menus = _MenuService.GetUserMenuList(roleId);
//鑾峰彇褰撳墠鐢ㄦ埛鏉冮檺濡�:(Add,Search)瀵瑰簲鐨勬樉绀烘枃鏈俊鎭:Add锛氭坊鍔狅紝Search:鏌ヨ
var data = menus.Select(x => new
{
@@ -156,7 +250,7 @@
List<MenuDTO> menus = _MenuService.GetUserMenuListPDA(roleId);
//鑾峰彇褰撳墠鐢ㄦ埛鏉冮檺濡�:(Add,Search)瀵瑰簲鐨勬樉绀烘枃鏈俊鎭:Add锛氭坊鍔狅紝Search:鏌ヨ
- var data = menus.Where(x => x.MenuType==1).Select(x => new
+ var data = menus.Where(x => x.MenuType == 1).Select(x => new
{
Id = x.MenuId,
Pid = x.ParentId,
@@ -243,7 +337,7 @@
int addCount = updateAuths.Where(x => x.AuthId <= 0).Count();
int updateCount = updateAuths.Where(x => x.AuthId > 0).Count();
-
+
string _version = DateTime.Now.ToString("yyyyMMddHHMMssfff");
--
Gitblit v1.9.3