Pārlūkot izejas kodu

菜单权限调整

storemanagement
zhaoy pirms 11 mēnešiem
vecāks
revīzija
e84948d630
18 mainītis faili ar 246 papildinājumiem un 27 dzēšanām
  1. +1
    -1
      BPA.SAAS.Manage.Application/Device/Services/ProductService.cs
  2. +4
    -0
      BPA.SAAS.Manage.Application/Org/Dtos/Company/CompanyDtoInput.cs
  3. +1
    -1
      BPA.SAAS.Manage.Application/Org/Services/CompanyService.cs
  4. +1
    -1
      BPA.SAAS.Manage.Application/System/Dtos/MenuDtoInput.cs
  5. +2
    -0
      BPA.SAAS.Manage.Application/System/Dtos/MenuTreeDtoOutput.cs
  6. +3
    -1
      BPA.SAAS.Manage.Application/System/Interface/IMenuService.cs
  7. +13
    -2
      BPA.SAAS.Manage.Application/System/MenuServices.cs
  8. +161
    -10
      BPA.SAAS.Manage.Application/System/Services/MenuService.cs
  9. +2
    -1
      BPA.SAAS.Manage.Core/DbContext.cs
  10. +4
    -0
      BPA.SAAS.Manage.Core/Org/BPA_Company.cs
  11. +2
    -2
      BPA.SAAS.Manage.Core/Product/BPA_Product.cs
  12. +2
    -2
      BPA.SAAS.Manage.Core/Product/BPA_ProductFunction.cs
  13. +2
    -2
      BPA.SAAS.Manage.Core/Product/BPA_ProductFunctionAction.cs
  14. +2
    -2
      BPA.SAAS.Manage.Core/Product/BPA_ProductTopics.cs
  15. +1
    -1
      BPA.SAAS.Manage.Core/System/BPA_Menu.cs
  16. +1
    -0
      BPA.SAAS.Manage.Web.Core/BPA.SAAS.Manage.Web.Core.csproj
  17. +36
    -1
      BPA.SAAS.Manage.Web.Core/Startup.cs
  18. +8
    -0
      BPA.SAAS.Manage.Web.Entry/appsettings.json

+ 1
- 1
BPA.SAAS.Manage.Application/Device/Services/ProductService.cs Parādīt failu

@@ -48,7 +48,7 @@ namespace BPA.SAAS.Manage.Application.Device.Services
public async Task<List<BPA_Product>> GetProductList()
{
var groupId = App.User?.FindFirst(ClaimConst.GroupId)?.Value;
var data = await _db.Queryable<BPA_Product>().Where(x=>x.Status==0 && x.GroupId== groupId) .ToListAsync();
var data = await _db.Queryable<BPA_Product>().Where(x=>x.Status==0) .ToListAsync();
return data;
}
/// <summary>


+ 4
- 0
BPA.SAAS.Manage.Application/Org/Dtos/Company/CompanyDtoInput.cs Parādīt failu

@@ -40,5 +40,9 @@ namespace BPA.SAAS.Manage.Application.Org.Dtos.Company
/// </summary>
public CommonStatus Status { get; set; } = CommonStatus.ENABLE;
public string SysRoleId { get; set; }
/// <summary>
/// 所属平台 0 团餐 1门店 2 后厨 3公共
/// </summary>
public int Type { get; set; }
}
}

+ 1
- 1
BPA.SAAS.Manage.Application/Org/Services/CompanyService.cs Parādīt failu

@@ -124,7 +124,7 @@ namespace BPA.SAAS.Manage.Application.Org.Services
public async Task<bool> UpdateCompany(CompanyDtoInput input)
{
var company = input.Adapt<BPA_Company>();
company.CreateAt= DateTime.Now;
var check = _db.Queryable<BPA_Company>().Where(x => x.IsDeleted == 0).First(t => t.Id == company.Id);

if (check == null)


+ 1
- 1
BPA.SAAS.Manage.Application/System/Dtos/MenuDtoInput.cs Parādīt failu

@@ -49,7 +49,7 @@ namespace BPA.SAAS.Manage.Application.System.Dtos
/// <summary>
/// 所属平台 0 团餐 1门店 2 后厨
/// </summary>
public int Type { get; set; }
public string Type { get; set; }
/// <summary>
/// 是否超管菜单 0否 1是
/// </summary>


+ 2
- 0
BPA.SAAS.Manage.Application/System/Dtos/MenuTreeDtoOutput.cs Parādīt failu

@@ -47,6 +47,8 @@ namespace BPA.SAAS.Manage.Application.System.Dtos
/// 组件
/// </summary>
public string Component { get; set; }
public string Type { get; set; }
public string TypeName { get; set; }
public int IsAdmin{ get; set; }

private List<MenuTreeDtoOutput> _Children;


+ 3
- 1
BPA.SAAS.Manage.Application/System/Interface/IMenuService.cs Parādīt failu

@@ -13,7 +13,9 @@ namespace BPA.SAAS.Manage.Application.System.Interface
Task<bool> Add(MenuDtoInput input);
Task<bool> Update(MenuDtoInput input);
Task<bool> Delete(List<string> input);
Task<List<MenuTreeOutput>> MenuTree(string getType);
Task<List<MenuTreeOutput>> MenuTree();
Task<List<MenuTreeOutput>> MenuTree(string GetType);
Task<List<MenuTreeOutput>> MenuParmyTree(string GetType, string type);
Task<List<MenuRouteDtoOutput>> DymicMenuTree(int type);
Task<bool> Enable(string Id);
Task<bool> Disable(string Id);


+ 13
- 2
BPA.SAAS.Manage.Application/System/MenuServices.cs Parādīt failu

@@ -2,6 +2,7 @@
using BPA.SAAS.Manage.Application.System.Interface;
using System;
using System.Collections.Generic;
using System.Drawing.Drawing2D;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
@@ -57,9 +58,19 @@ namespace BPA.SAAS.Manage.Application.System
/// <param name="getType"></param>
/// <returns></returns>
[HttpGet("/api/menu/menutrees")]
public async Task<List<MenuTreeOutput>> MenuTree(string getType)
public async Task<List<MenuTreeOutput>> MenuTree(string GetType)
{
return await _menuService.MenuTree(getType);
return await _menuService.MenuTree(GetType);
}
[HttpGet("/api/menu/menutreesall")]
public async Task<List<MenuTreeOutput>> MenuTree()
{
return await _menuService.MenuTree();
}
[HttpGet("/api/menu/menuparmytrees")]
public async Task<List<MenuTreeOutput>> MenuParmyTree(string GetType, string type)
{
return await _menuService.MenuParmyTree(GetType, type);
}
[HttpGet("/api/menu/menutree")]
public async Task<List<MenuRouteDtoOutput>> DymicMenuTree(int type)


+ 161
- 10
BPA.SAAS.Manage.Application/System/Services/MenuService.cs Parādīt failu

@@ -7,9 +7,11 @@ using BPA.SAAS.Manage.Core.System;
using Furion.LinqBuilder;
using Mapster.Utils;
using NPOI.SS.Formula.Functions;
using NPOI.XSSF.UserModel;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Security.Cryptography;
using System.Text;
using System.Threading.Tasks;

@@ -54,6 +56,8 @@ namespace BPA.SAAS.Manage.Application.System.Services
Component = t.Component,
Status = t.Status,
IsAdmin=t.IsAdmin,
Type= t.Type,
TypeName= GetTypeName(t.Type),
Children = AllMenus.Where(x => x.Pid == t.Id).Select(x => new MenuTreeDtoOutput
{
Id = x.Id,
@@ -67,6 +71,8 @@ namespace BPA.SAAS.Manage.Application.System.Services
Component = x.Component,
Status = x.Status,
IsAdmin=x.IsAdmin,
Type = x.Type,
TypeName = GetTypeName(x.Type),
Children = AllMenus.Where(y => y.Pid == x.Id).Select(y => new MenuTreeDtoOutput
{
Id = y.Id.ToString(),
@@ -79,13 +85,44 @@ namespace BPA.SAAS.Manage.Application.System.Services
Sort = y.Sort,
Component = y.Component,
Status = y.Status,
IsAdmin=y.IsAdmin
IsAdmin=y.IsAdmin,
Type = y.Type,
TypeName = GetTypeName(y.Type),
}).ToList()
}).ToList()
}).ToList();

return data;
}
public string GetTypeName(string type)
{
var ary = type.Split(',');
var name = "";
for (int i = 0; i < ary.Length; i++)
{
if (ary[i] == "0")
{
name += "团餐";
}
if (ary[i] == "1")
{
name += "门店";
}
if (ary[i] == "2")
{
name += "后厨";
}
if (ary[i] == "3")
{
name += "公共";
}
if(i< ary.Length - 1)
{
name += ",";
}
}
return name;
}
/// <summary>
/// 新增菜单
/// </summary>
@@ -124,6 +161,7 @@ namespace BPA.SAAS.Manage.Application.System.Services
menu.Sort = input.Sort;
menu.Icon = input.Icon;
menu.IsAdmin= input.IsAdmin;
menu.Type = input.Type;
return await _db.Updateable(menu).ExecuteCommandAsync()>0;
}

@@ -164,12 +202,12 @@ namespace BPA.SAAS.Manage.Application.System.Services
{

var userId = App.User.FindFirst(ClaimConst.CLAINM_USERID)?.Value;
var GroupId = App.User.FindFirst(ClaimConst.GroupId)?.Value;
if (string.IsNullOrWhiteSpace(GroupId) || string.IsNullOrWhiteSpace(userId))
// var GroupId = App.User.FindFirst(ClaimConst.GroupId)?.Value;
if ( string.IsNullOrWhiteSpace(userId))
{
return null;
}
List<BPA_Roles> dataRoles =await _db.Queryable<BPA_Roles>().Where(a => a.GroupId == GroupId).ToListAsync();
List<BPA_Roles> dataRoles =await _db.Queryable<BPA_Roles>().ToListAsync();
if (dataRoles.Count() <= 0)
{
return null;
@@ -178,23 +216,23 @@ namespace BPA.SAAS.Manage.Application.System.Services
var menus = _db.Queryable<BPA_RoleMenu>().Where(t => sysRoleId.Contains(t.SysRoleId))
.Select(x => x.SysMenuId).ToArray();

var AllMenus = _db.Queryable<BPA_Menu>().Where(t => t.IsDeleted == 0 && menus.Contains(t.Id)).OrderBy(t => t.Sort).ToList();
var AllMenus = _db.Queryable<BPA_Menu>().Where(t => menus.Contains(t.Id)).OrderBy(t => t.Sort).ToList();

var data = AllMenus.Where(t => t.Pid == null || t.Pid == "").Select(t => new MenuTreeOutput
{
Key = t.Id,
Title = t.Name,
value = t.Name,
value = t.Id,
Children = AllMenus.Where(x => x.Pid == t.Id).Select(x => new MenuTreeOutput
{
Key = x.Id,
Title = x.Name,
value = x.Name,
value = x.Id,
Children = AllMenus.Where(y => y.Pid == x.Id).Select(y => new MenuTreeOutput
{
Key = y.Id,
Title = y.Name,
value = y.Name,
value = y.Id,
}).ToList()
}).ToList()
}).ToList();
@@ -204,7 +242,62 @@ namespace BPA.SAAS.Manage.Application.System.Services
}
else
{
var AllMenus = _db.Queryable<BPA_Menu>().Where(t => t.IsDeleted == 0).OrderBy(t => t.Sort).ToList();
var AllMenus = _db.Queryable<BPA_Menu>().OrderBy(t => t.Sort).ToList();
var data = AllMenus.Where((t => t.Pid == null || t.Pid == "")).Select(t => new MenuTreeOutput
{
Key = t.Id,
Title = t.Name,
value = t.Id,
Children = AllMenus.Where(x => x.Pid == t.Id).Select(x => new MenuTreeOutput
{
Key = x.Id,
Title = x.Name,
value = x.Id,
Children = AllMenus.Where(y => y.Pid == x.Id).Select(y => new MenuTreeOutput
{
Key = y.Id,
Title = y.Name,
value = y.Name,
}).ToList()
}).ToList()
}).ToList();
var da = new List<MenuTreeOutput>();
data.ForEach(x =>
{
if (x.Children.Count() > 0)
{
da.Add(x);
}

});
return da;

}

}
public async Task<List<MenuTreeOutput>> MenuParmyTree(string GetType, string type)
{
if (!string.IsNullOrWhiteSpace(GetType) && GetType.ToLower() == "user")
{

var userId = App.User.FindFirst(ClaimConst.CLAINM_USERID)?.Value;
// var GroupId = App.User.FindFirst(ClaimConst.GroupId)?.Value;
if (string.IsNullOrWhiteSpace(userId))
{
return null;
}
List<BPA_Roles> dataRoles = await _db.Queryable<BPA_Roles>().ToListAsync();
if (dataRoles.Count() <= 0)
{
return null;
}
var sysRoleId = dataRoles.Select(a => a.Id).ToArray();
var menus = _db.Queryable<BPA_RoleMenu>().Where(t => sysRoleId.Contains(t.SysRoleId))
.Select(x => x.SysMenuId).ToArray();

var AllMenus = _db.Queryable<BPA_Menu>().Where(t => menus.Contains(t.Id)).OrderBy(t => t.Sort).ToList();

var data = AllMenus.Where(t => t.Pid == null || t.Pid == "").Select(t => new MenuTreeOutput
{
@@ -220,7 +313,7 @@ namespace BPA.SAAS.Manage.Application.System.Services
{
Key = y.Id,
Title = y.Name,
value = y.Name,
value = y.Id,
}).ToList()
}).ToList()
}).ToList();
@@ -228,7 +321,65 @@ namespace BPA.SAAS.Manage.Application.System.Services
return data;

}
else
{
var AllMenus = _db.Queryable<BPA_Menu>().Where(t => (t.Type.Contains(type) || t.Type.Contains("3")) && t.IsAdmin == 0).OrderBy(t => t.Sort).ToList();
var data = AllMenus.Where((t => t.Pid == null || t.Pid == "")).Select(t => new MenuTreeOutput
{
Key = t.Id,
Title = t.Name,
value = t.Id,
Children = AllMenus.Where(x => x.Pid == t.Id).Select(x => new MenuTreeOutput
{
Key = x.Id,
Title = x.Name,
value = x.Id,
Children = AllMenus.Where(y => y.Pid == x.Id).Select(y => new MenuTreeOutput
{
Key = y.Id,
Title = y.Name,
value = y.Name,
}).ToList()
}).ToList()
}).ToList();
var da = new List<MenuTreeOutput>();
data.ForEach(x =>
{
if (x.Children.Count() > 0)
{
da.Add(x);
}

});


return da;

}

}
public async Task<List<MenuTreeOutput>> MenuTree()
{
var AllMenus = _db.Queryable<BPA_Menu>().OrderBy(t => t.Sort).ToList();
var data = AllMenus.Where(t => t.Pid == null || t.Pid == "").Select(t => new MenuTreeOutput
{
Key = t.Id,
Title = t.Name,
value = t.Id,
Children = AllMenus.Where(x => x.Pid == t.Id).Select(x => new MenuTreeOutput
{
Key = x.Id,
Title = x.Name,
value = x.Id,
Children = AllMenus.Where(y => y.Pid == x.Id).Select(y => new MenuTreeOutput
{
Key = y.Id,
Title = y.Name,
value = y.Id,
}).ToList()
}).ToList()
}).ToList();
return data;
}
/// <summary>
/// 动态菜单(菜单树)


+ 2
- 1
BPA.SAAS.Manage.Core/DbContext.cs Parādīt failu

@@ -37,7 +37,7 @@ namespace BPA.SAAS.Manage.Core
{
db.QueryFilter.AddTableFilter<IDeleted>(it => it.IsDeleted == 0);
//db.QueryFilter.AddTableFilter<IStatus>(it => it.Status == 0);
if (!IsSuperAdmin())
if (!IsSuperAdmin() && App.User.FindFirst(ClaimConst.CLAINM_SUPERADMIN)?.Value != null)
{
//非管理员账户过滤加盟商数据
var groupId = App.User?.FindFirst(ClaimConst.GroupId)?.Value;
@@ -83,6 +83,7 @@ namespace BPA.SAAS.Manage.Core
private static bool IsSuperAdmin()
{
if (App.User == null) return false;
var sd = App.User.FindFirst(ClaimConst.CLAINM_SUPERADMIN)?.Value;
return App.User.FindFirst(ClaimConst.CLAINM_SUPERADMIN)?.Value == "1";
}
}

+ 4
- 0
BPA.SAAS.Manage.Core/Org/BPA_Company.cs Parādīt failu

@@ -43,5 +43,9 @@ namespace BPA.SAAS.Manage.Core.Org
/// 状态 【正常 停用】默认 正常
/// </summary>
public CommonStatus Status { get; set; } = CommonStatus.ENABLE;
/// <summary>
/// 所属平台 0 团餐 1门店 2 后厨 3公共
/// </summary>
public int Type { get; set; }
}
}

+ 2
- 2
BPA.SAAS.Manage.Core/Product/BPA_Product.cs Parādīt failu

@@ -10,7 +10,7 @@ using System.Threading.Tasks;
namespace BPA.SAAS.Manage.Core.Product
{
[SugarTable("bpa_product")]
public class BPA_Product : IBaseEntity, IGroupId
public class BPA_Product : IBaseEntity
{
public string Name { get; set; }
public string Key { get; set; }
@@ -18,7 +18,7 @@ namespace BPA.SAAS.Manage.Core.Product
/// 状态 0启用 1禁用
/// </summary>
public CommonStatus Status { get; set; } = CommonStatus.ENABLE;
public string GroupId { get; set; }
//public string GroupId { get; set; }
public string Code { get; set; }
/// <summary>
/// 备注


+ 2
- 2
BPA.SAAS.Manage.Core/Product/BPA_ProductFunction.cs Parādīt failu

@@ -13,7 +13,7 @@ namespace BPA.SAAS.Manage.Core.Product
///产品功能
/// </summary>
[SugarTable("bpa_productfunction")]
public class BPA_ProductFunction : IBaseEntity, IGroupId
public class BPA_ProductFunction : IBaseEntity
{
/// <summary>
/// 功能名称
@@ -26,7 +26,7 @@ namespace BPA.SAAS.Manage.Core.Product
/// <summary>
/// 加盟商id
/// </summary>
public string GroupId { get; set; }
// public string GroupId { get; set; }
/// <summary>
/// 外键
/// </summary>


+ 2
- 2
BPA.SAAS.Manage.Core/Product/BPA_ProductFunctionAction.cs Parādīt failu

@@ -7,7 +7,7 @@ using System.Threading.Tasks;

namespace BPA.SAAS.Manage.Core.Product
{
public class BPA_ProductFunctionAction : IBaseEntity, IGroupId
public class BPA_ProductFunctionAction : IBaseEntity
{
/// <summary>
/// 功能id
@@ -37,6 +37,6 @@ namespace BPA.SAAS.Manage.Core.Product
/// 排序
/// </summary>
public int Sort { get; set; }
public string GroupId { get; set; }
// public string GroupId { get; set; }
}
}

+ 2
- 2
BPA.SAAS.Manage.Core/Product/BPA_ProductTopics.cs Parādīt failu

@@ -9,7 +9,7 @@ using System.Threading.Tasks;
namespace BPA.SAAS.Manage.Core.Product
{
[SugarTable("bpa_producttopics")]
public class BPA_ProductTopics : IBaseEntity, IGroupId
public class BPA_ProductTopics : IBaseEntity
{
/// <summary>
/// Topics类
@@ -24,6 +24,6 @@ namespace BPA.SAAS.Manage.Core.Product
/// </summary>
public string Description { get; set; }
public string ProductId { get; set; }
public string GroupId { get; set; }
//public string GroupId { get; set; }
}
}

+ 1
- 1
BPA.SAAS.Manage.Core/System/BPA_Menu.cs Parādīt failu

@@ -51,7 +51,7 @@ namespace BPA.SAAS.Manage.Core.System
/// <summary>
/// 所属平台 0 团餐 1门店 2 后厨 3公共
/// </summary>
public int Type { get; set; }
public string Type { get; set; }
/// <summary>
/// 是否超管菜单 0否 1是
/// </summary>


+ 1
- 0
BPA.SAAS.Manage.Web.Core/BPA.SAAS.Manage.Web.Core.csproj Parādīt failu

@@ -16,6 +16,7 @@


<ItemGroup>
<PackageReference Include="BPA.MQTTClient" Version="1.0.11" />
<PackageReference Include="FluentValidation.AspNetCore" Version="11.3.0" />
</ItemGroup>



+ 36
- 1
BPA.SAAS.Manage.Web.Core/Startup.cs Parādīt failu

@@ -1,4 +1,5 @@
using BPA.SAAS.Manage.Application.System.Dtos;
using BPA.MQTTClient;
using BPA.SAAS.Manage.Application.System.Dtos;
using BPA.SAAS.Manage.Core;
using FluentValidation.AspNetCore;
using Furion;
@@ -6,7 +7,11 @@ using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using MQTTnet.Client.Connecting;
using MQTTnet.Client.Disconnecting;
using Newtonsoft.Json;
using System;
using System.Threading.Tasks;

namespace BPA.SAAS.Manage.Web.Core
{
@@ -29,6 +34,36 @@ namespace BPA.SAAS.Manage.Web.Core
options.SerializerSettings.ReferenceLoopHandling = ReferenceLoopHandling.Ignore;
options.SerializerSettings.DateFormatString = "yyyy-MM-dd HH:mm:ss";
});
services.AddMqttClientHostedService(op =>
{
op.Port = int.Parse(App.Configuration["dev1_brokerHostSettings:Port"]);
op.Server = App.Configuration["dev1_brokerHostSettings:Host"];
op.UserName = App.Configuration["MqttClientSettings:UserName"];
op.Password = App.Configuration["MqttClientSettings:Password"];
op.mqttClientConnectedHandlerDelegate = new MqttClientConnectedHandlerDelegate(async e =>
{
Console.WriteLine("MQTT连接成功");
});
op.mqttClientDisconnectedHandlerDelegate = new MqttClientDisconnectedHandlerDelegate(async e =>
{
Console.WriteLine("MQTT断开连接");
await Task.Delay(TimeSpan.FromSeconds(5));
try
{
//var options = op.Server.GetService<IMqttClientOptions>();
//await op.Server.GetService<IMqttClient>().ConnectAsync(options);
}
catch (global::System.Exception)
{


}
});
op.MqttApplicationMessageReceivedHandler = new MQTTnet.Client.Receiving.MqttApplicationMessageReceivedHandlerDelegate(async e =>
{

});
});
services.AddCorsAccessor();
services.AddSqlsugarSetup(App.Configuration);
services.AddControllers()


+ 8
- 0
BPA.SAAS.Manage.Web.Entry/appsettings.json Parādīt failu

@@ -22,6 +22,14 @@
"SecretId": "AKIDa4KQIvKUP6bw4ye6JI3a8lCPN7cswnV3",
"SecretKey": "ObaLtCH9nCNPFrFQO7ex2sTqyxlLgnfJ"
},
"dev1_brokerHostSettings": {
"Port": 8083,
"Host": "10.2.1.21"
},
"MqttClientSettings": {
"UserName": "emqx_u_block",
"Password": "emqx_p_admin8765490789"
},
"order_url": "http://order",
"wechat_url": "http://wechat"
}

Notiek ielāde…
Atcelt
Saglabāt