using Bootstrap.Admin.Query; using Bootstrap.DataAccess; using Bootstrap.Security; using Longbow.Web.Mvc; using Microsoft.AspNetCore.Mvc; using System.Collections.Generic; namespace Bootstrap.Admin.Controllers.Api { /// /// /// [Route("api/[controller]")] [ApiController] public class MenusController : ControllerBase { /// /// 获得所有菜单列表调用 /// /// /// [HttpGet] public QueryData Get([FromQuery]QueryMenuOption value) { return value.RetrieveData(User.Identity.Name); } /// /// 保存菜单调用 /// /// [HttpPost] public bool Post([FromBody]BootstrapMenu value) { return MenuHelper.Save(value); } /// /// 删除菜单调用 /// /// [HttpDelete] public bool Delete([FromBody]IEnumerable value) { return MenuHelper.Delete(value); } /// /// 角色管理菜单授权按钮调用 /// /// 角色ID /// type=role时,角色管理菜单授权调用;type=user时,菜单管理编辑页面父类菜单按钮调用 /// [HttpPost("{id}")] public IEnumerable Post(string id, [FromQuery]string type) { IEnumerable ret = new List(); switch (type) { case "role": ret = MenuHelper.RetrieveMenusByRoleId(id); break; case "user": ret = MenuHelper.RetrieveMenus(User.Identity.Name); break; } return ret; } /// /// 角色管理菜单授权保存按钮调用 /// /// 角色ID /// 菜单ID集合 /// [HttpPut("{id}")] public bool Put(string id, [FromBody]IEnumerable value) { return MenuHelper.SaveMenusByRoleId(id, value); } } }