using Entity.DbModel; using Entity.DbModel.System; using HybirdFrameworkCore.Entity; using Microsoft.AspNetCore.Mvc; using Service.System; using Entity.Dto.Req; using Entity.Dto.Resp; using Microsoft.Extensions.Localization; namespace WebStarter.Controllers.System { [Produces("application/json")] [ApiController] public class SysMenuController { private SysMenuService _sysMenuServices; private readonly IStringLocalizer _localizer; public SysMenuController(IStringLocalizer localizer,ILogger logger, SysMenuService sysMenuServices) { _localizer = localizer; _sysMenuServices = sysMenuServices; } /// /// 获取登录菜单树 /// /// [HttpGet] [Route("/api/sysMenu/loginMenuTree")] public async Task> GetLoginMenuTree() { List respList = await _sysMenuServices.GetLoginMenuTree(); foreach (var resp in respList) { resp.Meta.Title = _localizer[resp.Meta.Title]; foreach (var child in resp.Children) { child.Meta.Title = _localizer[child.Meta.Title]; } } return respList; } /// /// 获取菜单列表 /// /// /// [HttpGet] [Route("api/sysMenu/list")] public async Task> GetList([FromQuery] MenuReq input) { return await _sysMenuServices.GetList(input); } //[HttpGet] //[Route("api/sysMenu/ownBtnPermList")] //public async BusinessTask> GetOwnBtnPermList() //{ // return await _sysMenuServices.GetOwnBtnPermList(); //} /// /// 增加菜单 /// /// /// [HttpPost] [Route("/api/sysMenu/add")] public async Task> AddMenu([FromBody] AddMenuReq input) { int result = 0; var data = await _sysMenuServices.AddMenu(input); if (data == "增加菜单成功") { result = 200; return Result.Success(result); } else { return Result.Fail(result); } } /// /// 更新菜单 /// /// /// [HttpPost] [Route("/api/sysMenu/update")] public async Task> UpdateMenu([FromBody] UpdateMenuReq input) { var data = await _sysMenuServices.UpdateMenu(input); if (data == 200) return Result.Success(data); else { return Result.Fail(data); } } /// /// 删除菜单 /// /// /// [HttpPost] [Route("/api/sysMenu/delete")] public async Task DeleteMenu([FromBody] DeleteMenuReq input) { await _sysMenuServices.DeleteMenu(input); } } }