You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

81 lines
3.1 KiB

using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Znyc.Cloudcar.Admin.AspNetCore.Controllers;
using Znyc.Cloudcar.Admin.AspNetCore.Entitys;
using Znyc.Cloudcar.Admin.AspNetCore.Mvc;
using Znyc.Cloudcar.Admin.Commons.Cache;
using Znyc.Cloudcar.Admin.Commons.Entitys;
using Znyc.Cloudcar.Admin.Commons.Json;
using Znyc.Cloudcar.Admin.Commons.Log;
using Znyc.Cloudcar.Admin.Security.Dtos;
using Znyc.Cloudcar.Admin.Security.Entitys;
using Znyc.Cloudcar.Admin.Security.IServices;
namespace Znyc.Cloudcar.Admin.WebApi.Controllers
{
/// <summary>
/// 功能模块接口
/// </summary>
[ApiController]
[Produces("application/json")]
[Route("api/[controller]")]
public class FunctionController : AreaApiController<MenuEntity, MenuOutputDto, MenuInputDto, IMenuService, long>
{
/// <summary>
/// </summary>
/// <param name="service"></param>
public FunctionController(IMenuService service) : base(service)
{
_service = service;
}
/// <summary>
/// 根据父级功能编码查询所有子集功能,主要用于页面操作按钮权限
/// </summary>
/// <param name="enCode">菜单功能编码</param>
/// <returns></returns>
[HttpGet("GetListByParentEnCode")]
[FunctionAuthorize("")]
public async Task<IActionResult> GetListByParentEnCode(string enCode)
{
CommonResult result = new CommonResult();
try
{
if (CurrentUser != null)
{
CacheHelper cacheHelper = new CacheHelper();
List<MenuOutputDto> functions = new List<MenuOutputDto>();
functions = cacheHelper.Get("User_Function_" + CurrentUser.UserId).ToJson()
.ToObject<List<MenuOutputDto>>();
MenuOutputDto functionOutputDto = functions.Find(s => s.EnCode == enCode);
List<MenuOutputDto> nowFunList = new List<MenuOutputDto>();
if (functionOutputDto != null)
{
nowFunList = functions
.FindAll(s => s.ParentId == functionOutputDto.Id && s.IsShow && s.MenuType.Equals("F"))
.OrderBy(s => s.SortCode).ToList();
}
result.ErrCode = ErrCode.successCode;
result.ResData = nowFunList;
}
else
{
result.ErrCode = "40008";
result.ErrMsg = ErrCode.err40008;
}
}
catch (Exception ex)
{
Log4NetHelper.Error("根据父级功能编码查询所有子集功能,主要用于页面操作按钮权限,代码生成异常", ex);
result.ErrCode = ErrCode.failCode;
result.ErrMsg = "获取模块功能异常";
}
return ToJsonContent(result);
}
}
}