Exemplo n.º 1
0
        /// <summary>
        /// 处理查询条件
        /// 把数据权限限制条件带入
        /// </summary>
        /// <param name="httpContext"></param>
        /// <param name="request"></param>
        /// <returns>是否允许查看数据</returns>
        public static bool HandleRequest(HttpContext httpContext, IDataLimitRequest request)
        {
            request.LimitShops = request.LimitProvince = request.LimitCity = request.LimitDistrict = string.Empty;
            var ticket = AppTicket.GetAppTicket(httpContext);

            switch (ticket.DataLimitType)
            {
            case (int)DataLimitTypeEnum.All:
                return(true);

            case (int)DataLimitTypeEnum.Area:
                if (string.IsNullOrEmpty(ticket.DataLimitArea))
                {
                    return(false);
                }
                HandleRequestByArea(ticket.DataLimitArea, request);
                return(true);

            case (int)DataLimitTypeEnum.Shop:
                if (string.IsNullOrEmpty(ticket.DataLimitShop))
                {
                    return(false);
                }
                HandleRequestByShop(ticket.DataLimitShop, request);
                return(true);
            }
            return(false);
        }
Exemplo n.º 2
0
 /// <summary>
 /// 区域农药销售统计
 /// </summary>
 /// <param name="httpContext"></param>
 /// <param name="request"></param>
 /// <returns></returns>
 public async Task <ResponseBase> ProcessAction(HttpContext httpContext, GetStatisticsRetailRequest request)
 {
     _appTicket = AppTicket.GetAppTicket(httpContext);
     if (request.AreaId == 0 || _appTicket.DataLimitType == (int)DataLimitTypeEnum.Shop)
     {
         return(await GetStatisticsRetailDefault(request));
     }
     return(await GetStatisticsRetailLevel(request));
 }
Exemplo n.º 3
0
        /// <summary>
        /// 执行方法之前,验证用户角色权限
        /// </summary>
        /// <param name="context"></param>
        public override void OnActionExecuting(ActionExecutingContext context)
        {
            var actionDescriptor = context.ActionDescriptor as ControllerActionDescriptor;

            if (actionDescriptor != null)
            {
                var authorityConfig = MenuLib.MenuConfigs.FirstOrDefault(p => p.Controller == actionDescriptor.ControllerName && p.Action == actionDescriptor.ActionName);
                if (authorityConfig != null)
                {
                    var isCanVisit = new AuthorityCore(AppTicket.GetAppTicket(context.HttpContext).WeightSum).Validation(authorityConfig.Id);
                    if (!isCanVisit)
                    {
                        context.HttpContext.Response.StatusCode = (int)System.Net.HttpStatusCode.Forbidden;
                        context.Result = new JsonResult(new ResponseBase().GetResponseForbidden());
                    }
                }
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// 获取登录者菜单
        /// </summary>
        /// <param name="httpContext"></param>
        /// <returns></returns>
        public ResponseBase ProcessAction(HttpContext httpContext)
        {
            var ticket        = AppTicket.GetAppTicket(httpContext);
            var authorityCore = new AuthorityCore(ticket.WeightSum);

            HandleShowAction(authorityCore);
            InitFatherMenu(authorityCore);
            var menus = MenuLib.MenuConfigs.Where(p => authorityCore.Validation(p.Id)
                                                  )
                        .Select(p => new MenuView()
            {
                Id      = p.Id,
                IsOwner = true,
                Name    = p.Name,
                PerCode = p.PerCode,
                Type    = p.Type
            }).ToList();

            return(ResponseBase.Success(menus));
        }