2018-06-07 00:45:47 +08:00
|
|
|
|
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
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
///
|
|
|
|
|
/// </summary>
|
|
|
|
|
[Route("api/[controller]")]
|
|
|
|
|
public class MenusController : Controller
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
2018-09-13 17:55:24 +08:00
|
|
|
|
/// 获得所有菜单列表调用
|
2018-06-07 00:45:47 +08:00
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="value"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
[HttpGet]
|
2018-10-31 12:08:57 +08:00
|
|
|
|
public QueryData<object> Get(QueryMenuOption value)
|
2018-06-07 00:45:47 +08:00
|
|
|
|
{
|
|
|
|
|
return value.RetrieveData(User.Identity.Name);
|
|
|
|
|
}
|
2018-10-31 16:50:55 +08:00
|
|
|
|
|
2018-06-07 00:45:47 +08:00
|
|
|
|
/// <summary>
|
2018-09-13 17:55:24 +08:00
|
|
|
|
/// 保存菜单调用
|
2018-06-07 00:45:47 +08:00
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="value"></param>
|
|
|
|
|
[HttpPost]
|
2018-06-07 14:39:45 +08:00
|
|
|
|
public bool Post([FromBody]BootstrapMenu value)
|
2018-06-07 00:45:47 +08:00
|
|
|
|
{
|
|
|
|
|
return MenuHelper.SaveMenu(value);
|
|
|
|
|
}
|
2018-10-31 16:50:55 +08:00
|
|
|
|
|
2018-06-07 00:45:47 +08:00
|
|
|
|
/// <summary>
|
2018-09-13 17:55:24 +08:00
|
|
|
|
/// 删除菜单调用
|
2018-06-07 00:45:47 +08:00
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="value"></param>
|
|
|
|
|
[HttpDelete]
|
2018-10-30 13:07:29 +08:00
|
|
|
|
public bool Delete([FromBody]IEnumerable<string> value)
|
2018-06-07 00:45:47 +08:00
|
|
|
|
{
|
|
|
|
|
return MenuHelper.DeleteMenu(value);
|
|
|
|
|
}
|
2018-10-31 16:50:55 +08:00
|
|
|
|
|
2018-06-07 00:45:47 +08:00
|
|
|
|
/// <summary>
|
2018-10-31 16:50:55 +08:00
|
|
|
|
/// 角色管理菜单授权按钮调用
|
2018-06-07 00:45:47 +08:00
|
|
|
|
/// </summary>
|
2018-10-31 16:50:55 +08:00
|
|
|
|
/// <param name="id">角色ID</param>
|
|
|
|
|
/// <param name="type">type=role时,角色管理菜单授权调用;type=user时,菜单管理编辑页面父类菜单按钮调用</param>
|
2018-06-07 00:45:47 +08:00
|
|
|
|
/// <returns></returns>
|
|
|
|
|
[HttpPost("{id}")]
|
2018-10-31 16:50:55 +08:00
|
|
|
|
public IEnumerable<object> Post(string id, [FromQuery]string type)
|
2018-06-07 00:45:47 +08:00
|
|
|
|
{
|
2018-10-31 16:50:55 +08:00
|
|
|
|
IEnumerable<object> ret = new List<object>();
|
2018-09-13 19:21:35 +08:00
|
|
|
|
switch (type)
|
2018-06-07 00:45:47 +08:00
|
|
|
|
{
|
|
|
|
|
case "role":
|
2018-10-31 16:50:55 +08:00
|
|
|
|
ret = MenuHelper.RetrieveMenusByRoleId(id);
|
2018-06-07 00:45:47 +08:00
|
|
|
|
break;
|
|
|
|
|
case "user":
|
2018-10-31 16:50:55 +08:00
|
|
|
|
ret = MenuHelper.RetrieveMenus(User.Identity.Name);
|
2018-06-07 00:45:47 +08:00
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
return ret;
|
|
|
|
|
}
|
2018-10-31 16:50:55 +08:00
|
|
|
|
|
2018-06-07 00:45:47 +08:00
|
|
|
|
/// <summary>
|
2018-10-31 16:50:55 +08:00
|
|
|
|
/// 角色管理菜单授权保存按钮调用
|
2018-06-07 00:45:47 +08:00
|
|
|
|
/// </summary>
|
2018-09-13 17:55:24 +08:00
|
|
|
|
/// <param name="id">角色ID</param>
|
|
|
|
|
/// <param name="value">菜单ID集合</param>
|
2018-06-07 00:45:47 +08:00
|
|
|
|
/// <returns></returns>
|
|
|
|
|
[HttpPut("{id}")]
|
2018-10-30 13:07:29 +08:00
|
|
|
|
public bool Put(string id, [FromBody]IEnumerable<string> value)
|
2018-06-07 00:45:47 +08:00
|
|
|
|
{
|
2018-09-13 17:55:24 +08:00
|
|
|
|
return MenuHelper.SaveMenusByRoleId(id, value);
|
2018-06-07 00:45:47 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
2016-10-25 18:54:20 +08:00
|
|
|
|
}
|