Exemple #1
0
        public JsonResult GetMenuListByRoleId([FromForm]  WXQ.InOutPutEntites.Input.SystemManage.Menu.GetMenuListByRoleIdInput model)
        {
            ResponseResult result = new ResponseResult();

            GetMenuListByRoleIdInputModelValidation validator = new GetMenuListByRoleIdInputModelValidation();
            ValidationResult vr = validator.Validate(model);

            if (!vr.IsValid)
            {
                result.Code   = ResponseResultMessageDefine.ParaError;
                result.Errors = vr.Errors.Select(e => e.ErrorMessage).ToList();
            }
            else
            {
                WXQ.BusinessCore.systemmanage.MenuOp op = new WXQ.BusinessCore.systemmanage.MenuOp();

                SqlSugar.PageModel           pagemodel = TypeAdapter.Adapt <WXQ.InOutPutEntites.Input.PageInput, SqlSugar.PageModel>(model.Page);
                ListResult <WXQ.Enties.Menu> rv        = op.GetMenuListByRoleId(model.RoleId, pagemodel.PageIndex, pagemodel.PageSize);

                if (rv == null)
                {
                    result.Code = ResponseResultMessageDefine.OpLost;
                    result.Errors.Add(ResponseResultMessageDefine.OpLostMessage);
                }
                else
                {
                    result.Data = rv;
                }
            }

            return(Json(result));
        }
Exemple #2
0
        public JsonResult GetMenuTreeForCurrentUserByDeparentId([FromQuery] int departmentId, [FromQuery] int roleId)
        {
            ResponseResult result = new ResponseResult();


            int userId = WebApi.Common.HelpOp.UserOp.GetUserId(this.User);

            if (userId <= 0)
            {
                result.Code = ResponseResultMessageDefine.ParaError;
                result.Errors.Add("用户id错误");
            }
            else
            {
                WXQ.BusinessCore.systemmanage.MenuOp op = new WXQ.BusinessCore.systemmanage.MenuOp();



                var allnodes      = op.GetMenuTreeByUserId(userId, departmentId);
                var selectednodes = op.GetMenuListByRoleId(roleId, 1, 2000).Result.Select(m => m.MenuId).ToList();



                if (allnodes == null)
                {
                    result.Code = ResponseResultMessageDefine.OpLost;
                    result.Errors.Add(ResponseResultMessageDefine.OpLostMessage);
                }
                else
                {
                    dynamic dy = new ExpandoObject();
                    dy.AllNodes      = allnodes;
                    dy.SelectedNodes = selectednodes;
                    result.Data      = dy;
                }
            }

            return(Json(result));
        }