2016-11-06 00:48:08 +08:00
|
|
|
|
using Bootstrap.Admin.Models;
|
|
|
|
|
using Bootstrap.DataAccess;
|
2016-12-06 11:04:49 +08:00
|
|
|
|
using Longbow.Web.Mvc;
|
2016-11-07 21:41:17 +08:00
|
|
|
|
using Newtonsoft.Json.Linq;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
2016-11-06 00:48:08 +08:00
|
|
|
|
using System.Web.Http;
|
|
|
|
|
|
|
|
|
|
namespace Bootstrap.Admin.Controllers
|
|
|
|
|
{
|
|
|
|
|
public class MenusController : ApiController
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
///
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="value"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
[HttpGet]
|
|
|
|
|
public QueryData<Menu> Get([FromUri]QueryMenuOption value)
|
|
|
|
|
{
|
2016-11-08 20:37:14 +08:00
|
|
|
|
return value.RetrieveData(User.Identity.Name);
|
2016-11-06 00:48:08 +08:00
|
|
|
|
}
|
|
|
|
|
/// <summary>
|
|
|
|
|
///
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="value"></param>
|
|
|
|
|
[HttpPost]
|
|
|
|
|
public bool Post([FromBody]Menu value)
|
|
|
|
|
{
|
|
|
|
|
return MenuHelper.SaveMenu(value);
|
|
|
|
|
}
|
|
|
|
|
/// <summary>
|
|
|
|
|
///
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="id"></param>
|
|
|
|
|
[HttpDelete]
|
|
|
|
|
public bool Delete([FromBody]string value)
|
|
|
|
|
{
|
|
|
|
|
return MenuHelper.DeleteMenu(value);
|
|
|
|
|
}
|
2016-11-07 21:41:17 +08:00
|
|
|
|
[HttpPost]
|
|
|
|
|
public IEnumerable<Menu> Post(int id, [FromBody]JObject value)
|
|
|
|
|
{
|
|
|
|
|
var ret = new List<Menu>();
|
|
|
|
|
dynamic json = value;
|
|
|
|
|
switch ((string)json.type)
|
|
|
|
|
{
|
|
|
|
|
case "role":
|
|
|
|
|
ret = MenuHelper.RetrieveMenusByRoleId(id).ToList();
|
|
|
|
|
break;
|
2016-11-15 14:31:53 +08:00
|
|
|
|
case "user":
|
|
|
|
|
ret = MenuHelper.RetrieveAllMenusByUserName(User.Identity.Name).ToList();
|
|
|
|
|
break;
|
2016-11-07 21:41:17 +08:00
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
|
[HttpPut]
|
|
|
|
|
public bool Put(int id, [FromBody]JObject value)
|
|
|
|
|
{
|
|
|
|
|
var ret = false;
|
|
|
|
|
dynamic json = value;
|
|
|
|
|
string menuIds = json.menuIds.ToString();
|
|
|
|
|
switch ((string)json.type)
|
|
|
|
|
{
|
|
|
|
|
case "role":
|
|
|
|
|
ret = MenuHelper.SaveMenusByRoleId(id, menuIds);
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
return ret;
|
|
|
|
|
}
|
2016-11-06 00:48:08 +08:00
|
|
|
|
}
|
2016-10-25 18:54:20 +08:00
|
|
|
|
}
|