using SqlSugar;
using Yi.Framework.Infrastructure.Ddd.Dtos;
using Yi.Framework.Infrastructure.Ddd.Services;
using Yi.Furion.Application.Rbac.Services;
using Yi.Furion.Core.Rbac.Dtos.Menu;
using Yi.Furion.Core.Rbac.Entities;
namespace Yi.Furion.Application.Rbac.Services.Impl
{
///
/// Menu服务实现
///
[ApiDescriptionSettings("RBAC")]
public class MenuService : CrudAppService,
IMenuService, ITransient, IDynamicApiController
{
public override async Task> GetListAsync(MenuGetListInputVo input)
{
var entity = await MapToEntityAsync(input);
RefAsync total = 0;
var entities = await _DbQueryable.WhereIF(!string.IsNullOrEmpty(input.MenuName), x => x.MenuName.Contains(input.MenuName!))
.WhereIF(input.State is not null, x => x.State == input.State)
.OrderByDescending(x => x.OrderNum)
.ToPageListAsync(input.PageNum, input.PageSize, total);
return new PagedResultDto(total, await MapToGetListOutputDtosAsync(entities));
}
///
/// 查询当前角色的菜单
///
///
///
public async Task> GetListRoleIdAsync(long roleId)
{
var entities = await _DbQueryable.Where(m => SqlFunc.Subqueryable().Where(rm => rm.RoleId == roleId && rm.MenuId == m.Id).Any()).ToListAsync();
return await MapToGetListOutputDtosAsync(entities);
}
}
}