Пример #1
0
        public IHttpActionResult Query()
        {
            //SecurityHelper.CurrentPrincipal.RoleId;
            RoleFilter request = new RoleFilter();

            request.RoleId = SecurityHelper.CurrentPrincipal.RoleId;
            var response = _service.GetRoleModule(request).ToList().Distinct();

            //var response = _service.GetMenus(roleId);
            return(Ok(response));
        }
Пример #2
0
        public IHttpActionResult Get(string roleId, string type = "", bool loadTreeByRole = false)
        {
            if (type == "")
            {
                RoleFilter request = new RoleFilter
                {
                    RoleId = string.IsNullOrWhiteSpace(roleId) ? null : roleId
                };
                var response = _service.GetRoleModule(request);
                return(Ok(response));
            }
            else if (type == "tree")
            {
                BaseRequest <RoleFilter> requestByRole = new BaseRequest <RoleFilter>
                {
                    Data =
                    {
                        RoleId = string.IsNullOrWhiteSpace(roleId) ? null : roleId,
                        OrgId  = SecurityHelper.CurrentPrincipal.OrgId
                    }
                };

                BaseRequest <RoleFilter> requestByTree = new BaseRequest <RoleFilter>();
                if (loadTreeByRole)
                {
                    requestByTree.Data.OrgId    = SecurityHelper.CurrentPrincipal.OrgId;
                    requestByTree.Data.RoleId   = SecurityHelper.CurrentPrincipal.RoleId;
                    requestByTree.Data.RoleType = SecurityHelper.CurrentPrincipal.RoleType;
                }
                var response = _service.GetModuleByRole(requestByRole, requestByTree);
                return(Ok(response));
            }
            else
            {
                return(Ok("type參數不正確"));
            }
        }