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.

121 lines
3.4 KiB

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