按钮权限

master
ZR20090193-陈敬勇 7 months ago
parent e932f6d454
commit 00a534fe3b

@ -36,7 +36,7 @@ public class CurrentUserViewModel
public string CompanyName { get; set; } = "";
/// <summary>
/// 用户类型 -1 超管 0-普通用户 1-管理员
/// 用户类型 0-超管 1-管理员 2-普通用户 3- 租户申请
/// </summary>
public int UserType { get; set; } = 0;

@ -68,7 +68,11 @@ public interface ICommonService
/// </summary>
/// <returns></returns>
DataResult<List<RouteItem>> GetClientUserPermissionByToken();
/// <summary>
/// 获取客户端按钮权限
/// </summary>
/// <returns></returns>
public DataResult<string[]> GetClientUserPermissionCode();
/// <summary>
/// 获取角色下拉列表
/// </summary>

@ -18,6 +18,8 @@ using DS.WMS.Core.Code.Entity;
using Mapster;
using Microsoft.IdentityModel.Tokens;
using Newtonsoft.Json;
using System.Data;
using DS.WMS.Core.Info.Dtos;
namespace DS.WMS.Core.System.Method;
@ -661,7 +663,7 @@ public class CommonService : ICommonService
//去重
childs.Distinct();
//排序
childs = childs.OrderBy(x => x.SortCode).ToList();
childs = childs.OrderBy(x => x.SortCode).ToList();
item.Children = childs;
}
}
@ -670,6 +672,28 @@ public class CommonService : ICommonService
return DataResult<List<RouteItem>>.Success("获取数据成功!", list);
}
/// <summary>
/// 获取客户端按钮权限
/// </summary>
/// <returns></returns>
public DataResult<string[]> GetClientUserPermissionCode() {
var userId = long.Parse(user.UserId);
var roleList = db.Queryable<SysRoleUser>()
.Where(x => x.UserId == userId).Select(n => n.RoleId).ToList();
roleList.Distinct();
var list = db.Queryable<SysRolePermission>().Where(a => roleList.Contains(a.RoleId) && a.IsPermission == 1)
.InnerJoin<SysPermission>((a,b)=>a.PermissionId == b.Id)
.Where((a, b) => b.MenuType == 3)
.Select((a, b) => a.PermissionId.ToString()
).ToArray();
return DataResult<string[]>.Success("获取数据成功!", list);
}
#endregion

@ -177,11 +177,11 @@ public class SysRoleService : ISysRoleService
{
foreach (var child in childs)
{
var buttons = db.Queryable<SysPermissionTenant>().Filter(null, true).Where(x => x.MenuType == 3 && x.ParentId == child.Key)
var buttons = db.Queryable<SysPermission>().Filter(null, true).Where(x => x.MenuType == 3 && x.ParentId == child.Key)
.Select(a => new RolePermissionTree
{
Title = a.PermissionName,
Key = a.PermissionId,
Key = a.Id,
})
.ToList();
if (buttons.Count > 0)

@ -97,8 +97,18 @@ public class CommonController : ApiController
{
var res = _invokeService.GetClientUserPermissionByToken();
return res;
}
}
/// <summary>
/// 获取客户端按钮权限
/// </summary>
/// <returns></returns>
[HttpGet]
[Route("GetClientUserPermissionCode")]
public DataResult<string[]> GetClientUserPermissionCode()
{
var res = _invokeService.GetClientUserPermissionCode();
return res;
}
/// <summary>
/// 获取角色下拉选项
/// </summary>

@ -1230,3 +1230,17 @@
2024-04-23 09:01:23.7292 Info Validating config: TargetNames=console, ownFile-web, ConfigItems=54, FilePath=D:\Code\DS\ds8-solution\ds-wms-service\DS.WMS.MainApi\bin\Debug\net8.0\nlog.config
2024-04-23 09:01:23.7292 Warn Unused target detected. Add a rule for this target to the configuration. TargetName: allfile
2024-04-23 09:01:23.7573 Info Configuration initialized.
2024-04-24 14:41:19.9657 Info Registered target NLog.Targets.FileTarget(Name=allfile)
2024-04-24 14:41:20.0017 Info Registered target NLog.Targets.FileTarget(Name=ownFile-web)
2024-04-24 14:41:20.0203 Info Registered target NLog.Targets.ColoredConsoleTarget(Name=console)
2024-04-24 14:41:20.0571 Info NLog, Version=5.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c. File version: 5.2.8.2366. Product version: 5.2.8+f586f1341c46fa38aaaff4c641e7f0fa7e813943. GlobalAssemblyCache: False
2024-04-24 14:41:20.0810 Info Validating config: TargetNames=console, ownFile-web, ConfigItems=54, FilePath=D:\Code\DS\ds8-solution\ds-wms-service\DS.WMS.MainApi\bin\Debug\net8.0\nlog.config
2024-04-24 14:41:20.0931 Warn Unused target detected. Add a rule for this target to the configuration. TargetName: allfile
2024-04-24 14:41:20.1185 Info Configuration initialized.
2024-04-24 15:39:08.7895 Info Registered target NLog.Targets.FileTarget(Name=allfile)
2024-04-24 15:39:08.8189 Info Registered target NLog.Targets.FileTarget(Name=ownFile-web)
2024-04-24 15:39:08.8278 Info Registered target NLog.Targets.ColoredConsoleTarget(Name=console)
2024-04-24 15:39:08.8502 Info NLog, Version=5.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c. File version: 5.2.8.2366. Product version: 5.2.8+f586f1341c46fa38aaaff4c641e7f0fa7e813943. GlobalAssemblyCache: False
2024-04-24 15:39:08.8660 Info Validating config: TargetNames=console, ownFile-web, ConfigItems=54, FilePath=D:\Code\DS\ds8-solution\ds-wms-service\DS.WMS.MainApi\bin\Debug\net8.0\nlog.config
2024-04-24 15:39:08.8743 Warn Unused target detected. Add a rule for this target to the configuration. TargetName: allfile
2024-04-24 15:39:08.8882 Info Configuration initialized.

Loading…
Cancel
Save