/// <summary> /// 菜单授权-菜单功能 /// role=角色 /// funguid=按钮的编号 /// status=取消还是授权 /// </summary> /// <returns></returns> public ApiResult<string> RoleMenuToFunAsync(SysPermissionsParm parm) { var res = new ApiResult<string>() { statusCode = (int)ApiEnum.Error }; try { //根据角色和菜单查询内容 var model = Db.Queryable<SysPermissions>().Single(m => m.RoleGuid == parm.role && m.MenuGuid == parm.menu && m.Types == 1); if (model == null) { res.message = "您还没有授权当前菜单功能模块"; return res; } if (!string.IsNullOrEmpty(model.BtnFunJson)) { //判断授权还是取消 var list = JsonConvert.DeserializeObject<List<string>>(model.BtnFunJson); if (parm.status == 0) { if (list.Contains(parm.btnfun)) { list.Remove(parm.btnfun); } } else { //授权 if (!list.Contains(parm.btnfun)) { list.Add(parm.btnfun); } } model.BtnFunJson = JsonConvert.SerializeObject(list); } else { //肯定是增加 model.BtnFunJson = JsonConvert.SerializeObject(new List<string>() { parm.btnfun }); } Db.Updateable<SysPermissions>() .SetColumns(m => new SysPermissions() { BtnFunJson = model.BtnFunJson }) .Where(m => m.RoleGuid == parm.role && m.MenuGuid == parm.menu && m.Types == 1).ExecuteCommand(); res.statusCode = (int)ApiEnum.Status; } catch (Exception ex) { res.message = ex.Message; Logger.Default.ProcessError((int)ApiEnum.Error, ex.Message); } return res; }
public ApiResult <string> RoleMenuToFun([FromBody] SysPermissionsParm parm) { return(_roleMenu.RoleMenuToFunAsync(parm)); }
public IActionResult RoleMenuToFun([FromBody] SysPermissionsParm parm) { return(Ok(_roleMenu.RoleMenuToFunAsync(parm))); }
public async Task <ApiResult <string> > RoleMenuToFun(SysPermissionsParm parm) { return(await _roleMenu.RoleMenuToFunAsync(parm)); }