using Bootstrap.Admin.Query; using Bootstrap.DataAccess; using Longbow.Web.Mvc; using Microsoft.AspNetCore.Mvc; using Newtonsoft.Json.Linq; using System.Collections.Generic; using System.Linq; namespace Bootstrap.Admin.Controllers.Api { /// /// /// [Route("api/[controller]")] public class RolesController : Controller { /// /// /// /// /// [HttpGet] public QueryData Get(QueryRoleOption value) { return value.RetrieveData(); } /// /// /// /// /// /// [HttpPost("{id}")] public IEnumerable Post(int id, [FromBody]JObject value) { var ret = new List(); dynamic json = value; switch ((string)json.type) { case "user": ret = RoleHelper.RetrieveRolesByUserId(id).ToList(); break; case "group": ret = RoleHelper.RetrieveRolesByGroupId(id).ToList(); break; case "menu": ret = RoleHelper.RetrieveRolesByMenuId(id).ToList(); break; default: break; } return ret; } /// 根据GroupID获取 /// /// /// [HttpPut("{id}")] public bool Put(int id, [FromBody]JObject value) { var ret = false; dynamic json = value; string roleIds = json.roleIds; switch ((string)json.type) { case "user": ret = RoleHelper.SaveRolesByUserId(id, roleIds); break; case "group": ret = RoleHelper.SaveRolesByGroupId(id, roleIds); break; case "menu": ret = RoleHelper.SavaRolesByMenuId(id, roleIds); break; default: break; } return ret; } /// /// /// /// [HttpPost] public bool Post([FromBody]Role value) { return RoleHelper.SaveRole(value); } /// /// /// /// [HttpDelete] public bool Delete([FromBody]IEnumerable value) { return RoleHelper.DeleteRole(value); } } }