Browse Source

菜单修改

storemanagement
zhaoy 11 months ago
parent
commit
96ae6639de
9 changed files with 111 additions and 51 deletions
  1. +1
    -1
      BPA.SAAS.Manage.Application/Device/Services/DeviceService.cs
  2. +0
    -1
      BPA.SAAS.Manage.Application/Device/Services/ProductFunctionService.cs
  3. +2
    -1
      BPA.SAAS.Manage.Application/Device/Services/ProductService.cs
  4. +8
    -0
      BPA.SAAS.Manage.Application/System/Dtos/MenuDtoInput.cs
  5. +2
    -0
      BPA.SAAS.Manage.Application/System/Dtos/MenuTreeDtoOutput.cs
  6. +1
    -1
      BPA.SAAS.Manage.Application/System/Interface/IMenuService.cs
  7. +2
    -2
      BPA.SAAS.Manage.Application/System/MenuServices.cs
  8. +87
    -45
      BPA.SAAS.Manage.Application/System/Services/MenuService.cs
  9. +8
    -0
      BPA.SAAS.Manage.Core/System/BPA_Menu.cs

+ 1
- 1
BPA.SAAS.Manage.Application/Device/Services/DeviceService.cs View File

@@ -33,7 +33,7 @@ namespace BPA.SAAS.Manage.Application.Device.Services
public async Task<PageUtil> GetDeviceInfoPage(DeviceQueryInputDto inputDto)
{
RefAsync<int> total =0;
var data = await _db.Queryable<BPA_DeviceInfo, BPA_Product>((a, b) => new JoinQueryInfos(JoinType.Left, b.Id == a.ProductId))
var data = await _db.Queryable<BPA_DeviceInfo, BPA_Product>((a, b) => new JoinQueryInfos(JoinType.Left, a.ProductId == b.Id))

.WhereIF(!string.IsNullOrWhiteSpace(inputDto.StoreId), (a, b) => a.OrgId == inputDto.StoreId)
.WhereIF(!string.IsNullOrWhiteSpace(inputDto.DeviceName), (a, b) => a.DeviceName.Contains(inputDto.DeviceName))


+ 0
- 1
BPA.SAAS.Manage.Application/Device/Services/ProductFunctionService.cs View File

@@ -44,7 +44,6 @@ namespace BPA.SAAS.Manage.Application.Device.Services
Name = x.Name,
Status = x.Status,
x.Id,
x.GroupId,
x.ForeignKeyRe,
x.DeviceVersionKey,
DeviceTypeKey = b.ProductId,


+ 2
- 1
BPA.SAAS.Manage.Application/Device/Services/ProductService.cs View File

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


+ 8
- 0
BPA.SAAS.Manage.Application/System/Dtos/MenuDtoInput.cs View File

@@ -46,6 +46,14 @@ namespace BPA.SAAS.Manage.Application.System.Dtos
/// 备注
/// </summary>
public string Remark { get; set; }
/// <summary>
/// 所属平台 0 团餐 1门店 2 后厨
/// </summary>
public int Type { get; set; }
/// <summary>
/// 是否超管菜单 0否 1是
/// </summary>
public int IsAdmin { get; set; }
public CommonStatus Status { get; set; } = CommonStatus.ENABLE;
}
}

+ 2
- 0
BPA.SAAS.Manage.Application/System/Dtos/MenuTreeDtoOutput.cs View File

@@ -1,4 +1,5 @@
using BPA.SAAS.Manage.Comm.Enum;
using NPOI.SS.Formula.Functions;
using System;
using System.Collections.Generic;
using System.Linq;
@@ -46,6 +47,7 @@ namespace BPA.SAAS.Manage.Application.System.Dtos
/// 组件
/// </summary>
public string Component { get; set; }
public int IsAdmin{ get; set; }

private List<MenuTreeDtoOutput> _Children;
public List<MenuTreeDtoOutput> Children


+ 1
- 1
BPA.SAAS.Manage.Application/System/Interface/IMenuService.cs View File

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


+ 2
- 2
BPA.SAAS.Manage.Application/System/MenuServices.cs View File

@@ -62,9 +62,9 @@ namespace BPA.SAAS.Manage.Application.System
return await _menuService.MenuTree(getType);
}
[HttpGet("/api/menu/menutree")]
public async Task<List<MenuRouteDtoOutput>> DymicMenuTree()
public async Task<List<MenuRouteDtoOutput>> DymicMenuTree(int type)
{
return await _menuService.DymicMenuTree();
return await _menuService.DymicMenuTree(type);
}
[HttpGet("/api/menu/enable")]
public async Task<bool> Enable(string Id)


+ 87
- 45
BPA.SAAS.Manage.Application/System/Services/MenuService.cs View File

@@ -6,6 +6,7 @@ using BPA.SAAS.Manage.Core.Org;
using BPA.SAAS.Manage.Core.System;
using Furion.LinqBuilder;
using Mapster.Utils;
using StackExchange.Profiling.Internal;
using System;
using System.Collections.Generic;
using System.Linq;
@@ -31,7 +32,7 @@ namespace BPA.SAAS.Manage.Application.System.Services
if (App.User.FindFirst(ClaimConst.CLAINM_USERID)?.Value == null)
return null;

var AllMenus =await _db.Queryable<BPA_Menu>().Where(t => t.IsDeleted == 0).OrderBy(t => t.Sort).ToListAsync();
var AllMenus = await _db.Queryable<BPA_Menu>().OrderBy(t => t.Sort).ToListAsync();

var query = AllMenus.Where(t => t.Pid == "" || t.Pid == null);

@@ -52,6 +53,7 @@ namespace BPA.SAAS.Manage.Application.System.Services
Sort = t.Sort,
Component = t.Component,
Status = t.Status,
IsAdmin = t.IsAdmin,
Children = AllMenus.Where(x => x.Pid == t.Id).Select(x => new MenuTreeDtoOutput
{
Id = x.Id,
@@ -64,6 +66,7 @@ namespace BPA.SAAS.Manage.Application.System.Services
Sort = x.Sort,
Component = x.Component,
Status = x.Status,
IsAdmin = x.IsAdmin,
Children = AllMenus.Where(y => y.Pid == x.Id).Select(y => new MenuTreeDtoOutput
{
Id = y.Id.ToString(),
@@ -76,6 +79,7 @@ namespace BPA.SAAS.Manage.Application.System.Services
Sort = y.Sort,
Component = y.Component,
Status = y.Status,
IsAdmin = y.IsAdmin,
}).ToList()
}).ToList()
}).ToList();
@@ -89,17 +93,17 @@ namespace BPA.SAAS.Manage.Application.System.Services
/// <returns></returns>
public async Task<bool> Add(MenuDtoInput input)
{
var dicttypes = _db.Queryable<BPA_Menu>().Where(a => a.Code == input.Code && a.IsDeleted == 0).ToList();
if (dicttypes.Count() > 0)
{
throw Oops.Oh("编码已存在");
}
var dicttypes = _db.Queryable<BPA_Menu>().Where(a => a.Code == input.Code).ToList();
//if (dicttypes.Count() > 0)
//{
// throw Oops.Oh("编码已存在");
//}
if (input.Name.Length > 20)
{
throw Oops.Oh("菜单名称过长");
}
var menu = input.Adapt<BPA_Menu>();
return await _db.Insertable(menu).CallEntityMethod(t => t.Create()).ExecuteCommandAsync()> 0;
return await _db.Insertable(menu).CallEntityMethod(t => t.Create()).ExecuteCommandAsync() > 0;
}

/// <summary>
@@ -109,17 +113,18 @@ namespace BPA.SAAS.Manage.Application.System.Services
/// <returns></returns>
public async Task<bool> Update(MenuDtoInput input)
{
var menu = await _db.Queryable< BPA_Menu >().Where(x=>x.Id== input.Id).FirstAsync();
var menu = await _db.Queryable<BPA_Menu>().Where(x => x.Id == input.Id).FirstAsync();
//menu = input.Adapt<BPA_Menu>();
menu.Code = input.Code;
menu.Component = input.Component;
menu.Name= input.Name;
menu.Pid= input.Pid;
menu.Name = input.Name;
menu.Pid = input.Pid;
menu.Router = input.Router;
menu.Remark= input.Remark;
menu.Remark = input.Remark;
menu.Sort = input.Sort;
menu.Icon = input.Icon;
return await _db.Updateable(menu).ExecuteCommandAsync()>0;
menu.IsAdmin = input.IsAdmin;
return await _db.Updateable(menu).ExecuteCommandAsync() > 0;
}

/// <summary>
@@ -138,9 +143,9 @@ namespace BPA.SAAS.Manage.Application.System.Services
{
x.IsDeleted = 1;
});
var res =await _db.Updateable(resEntitites).ExecuteCommandAsync();
var res = await _db.Updateable(resEntitites).ExecuteCommandAsync();
_db.Ado.CommitTran();
return res>0;
return res > 0;
}
catch (Exception)
{
@@ -148,11 +153,11 @@ namespace BPA.SAAS.Manage.Application.System.Services
return false;
}
}
/// <summary>
/// 查询菜单树
/// </summary>
/// <param name="GetType"></param>
/// <returns></returns>
/// <summary>
/// 查询菜单树
/// </summary>
/// <param name="GetType"></param>
/// <returns></returns>
public async Task<List<MenuTreeOutput>> MenuTree(string GetType)
{
if (!string.IsNullOrWhiteSpace(GetType) && GetType.ToLower() == "user")
@@ -164,7 +169,7 @@ namespace BPA.SAAS.Manage.Application.System.Services
{
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>().Where(a => a.GroupId == GroupId).ToListAsync();
if (dataRoles.Count() <= 0)
{
return null;
@@ -229,7 +234,7 @@ namespace BPA.SAAS.Manage.Application.System.Services
/// 动态菜单(菜单树)
/// </summary>
/// <returns></returns>
public async Task<List<MenuRouteDtoOutput>> DymicMenuTree()
public async Task<List<MenuRouteDtoOutput>> DymicMenuTree(int type)
{
var UserId = App.User.FindFirst(ClaimConst.CLAINM_USERID)?.Value;
var IsAdmin = App.User.FindFirst(ClaimConst.CLAINM_SUPERADMIN)?.Value;
@@ -237,37 +242,74 @@ namespace BPA.SAAS.Manage.Application.System.Services

if (UserId == null)
return null;
List<BPA_Menu> AllMenus = new List<BPA_Menu>();
List<BPA_Menu> AllMenus = await _db.Queryable<BPA_Menu>().OrderBy(t => t.Sort).ToListAsync();
List<BPA_Menu> ParnMenus = new();
if (IsAdmin == "1" && account == "admin")
AllMenus =await _db.Queryable<BPA_Menu>().Where(t => t.IsDeleted == 0 && t.Status == 0).OrderBy(t => t.Sort).ToListAsync();
else
AllMenus =await _db.Queryable<BPA_Menu>().LeftJoin<BPA_RoleMenu>((t, x) => t.Id == x.SysMenuId).LeftJoin<BPA_UserRole>((t, x, y) => x.SysRoleId == y.SysRoleId)
.Where((t, x, y) => y.SysUserId == UserId && t.Status == 0).Select(t => t).ToListAsync();
//菜单去重
AllMenus = AllMenus.Where((x, i) => AllMenus.FindIndex(z => z.Id == x.Id) == i).ToList();
var data = AllMenus.Where(t => t.Pid == null || t.Pid == "").OrderBy(t => t.Sort).Select(t => new MenuRouteDtoOutput
{
Id = t.Id,
Component = t.Component,
Icon = t.Icon,
Name = t.Name,
Path = t.Router,
Routes = AllMenus.Where(x => x.Pid == t.Id).Select(x => new MenuRouteChildDtoOutput
//ParnMenus = await _db.Queryable<BPA_Menu>().Where(t => t.IsAdmin == 1).OrderBy(t => t.Sort).ToListAsync();
var childMenus = await _db.Queryable<BPA_Menu>().Where(t => t.IsAdmin == 1 && t.Type == 3).OrderBy(t => t.Sort).ToListAsync();
var parnids= childMenus.Select(t => t.Pid).ToList();
var parnlist = _db.Queryable<BPA_Menu>().Where(x => parnids.Contains(x.Id)).Select(t => new MenuRouteDtoOutput
{
Id = t.Id,
Component = x.Component,
Name = x.Name,
Path = x.Router,
Routes = AllMenus.Where(y => y.Pid == x.Id).Select(y => new MenuRouteChildDtoOutput
Component = t.Component,
Icon = t.Icon,
Name = t.Name,
Path = t.Router,
Routes= AllMenus.Where(p=>p.Id==t.Pid).Select(t => new MenuRouteChildDtoOutput
{
Id = t.Id,
Component = y.Component,
Name = y.Name,
Path = y.Router
Component = t.Component,
Name = t.Name,
Path = t.Router,
}).ToList()
}).ToList()
}).ToList();
return data;
}).ToList();
var list=parnlist.Select(t => new MenuRouteDtoOutput
{
Id = t.Id,
Component = t.Component,
Icon = t.Icon,
Name = t.Name,
Path = t.Path,
Routes = childMenus.Where(x => x.Pid == t.Id).Select(x => new MenuRouteChildDtoOutput
{
Id = t.Id,
Component = x.Component,
Name = x.Name,
Path = x.Router,
Routes = childMenus.Where(x => x.Pid == t.Id).Select(x => new MenuRouteChildDtoOutput
{
Id = t.Id,
Component = x.Component,
Name = x.Name,
Path = x.Router,
}).ToList()
}).ToList()
}).ToList();
return list;
}
else{
var childMenus = await _db.Queryable<BPA_Menu>().Where(t => t.IsAdmin == 0 && (t.Type == 3 || t.Type == type)).OrderBy(t => t.Sort).ToListAsync();
var parnids = childMenus.Select(t => t.Pid).ToList();
var parnlist = _db.Queryable<BPA_Menu>().Where(x => parnids.Contains(x.Id)).ToList();
var list = parnlist.OrderBy(t => t.Sort).Select(t => new MenuRouteDtoOutput
{
Id = t.Id,
Component = t.Component,
Icon = t.Icon,
Name = t.Name,
Path = t.Router,
Routes = childMenus.Where(x => x.Pid == t.Id).Select(x => new MenuRouteChildDtoOutput
{
Id = t.Id,
Component = x.Component,
Name = x.Name,
Path = x.Router,
}).ToList()
}).ToList();
return list;
}
}
/// <summary>
/// 启用


+ 8
- 0
BPA.SAAS.Manage.Core/System/BPA_Menu.cs View File

@@ -49,6 +49,14 @@ namespace BPA.SAAS.Manage.Core.System
/// </summary>
public string Remark { get; set; }
/// <summary>
/// 所属平台 0 团餐 1门店 2 后厨 3公共
/// </summary>
public int Type { get; set; }
/// <summary>
/// 是否超管菜单 0否 1是
/// </summary>
public int IsAdmin { get; set; }
/// <summary>
/// 状态 【正常 停用】默认 正常
/// </summary>
[SugarColumn(ColumnDataType = "int", ColumnDescription = "状态", IsNullable = false)]


Loading…
Cancel
Save