コード例 #1
0
        public ActionResult UpdateMenuExecutive(ReqNavMenuView navMenu)
        {
            var menuId = navMenu.MenuId;
            var opera  = (int)Operation.Update;

            if (!navMenu.GetIsValid())
            {
                string errorMsg = navMenu.GetErrorMessageList().First().ErrorMessage;
                return(Json(ResMessage.CreatMessage(ResultTypeEnum.Exception, errorMsg)));
            }
            var isBtn = _buttonBll.BtnJurisdiction(menuId, opera);

            if (!isBtn)
            {
                return(Json(ResMessage.CreatMessage(ResultTypeEnum.ValidateError, "您没有修改按钮权限")));
            }
            var nav = _menuShareBll.FirstOrDefault <Sys_NavMenu>(x => x.MenuId.Equals(menuId));

            if (nav == null)
            {
                return(Json(ResMessage.CreatMessage(ResultTypeEnum.Error, "菜单不存在")));
            }
            nav.MenuId      = navMenu.MenuId;
            nav.MenuName    = navMenu.MenuName;
            nav.ParentMenId = navMenu.ParentMenId;
            nav.Level       = navMenu.Level;
            nav.Url         = navMenu.Url;
            var result = _menuShareBll.UpdateEntity(nav);

            return(Json(ResMessage.CreatMessage(result ? ResultTypeEnum.Success : ResultTypeEnum.Exception)));
        }
コード例 #2
0
        /// <summary>
        /// 权限验证
        /// </summary>
        /// <param name="filterContext"></param>
        public override void OnAuthorization(AuthorizationContext filterContext)
        {
            //过滤验证
            if (filterContext.ActionDescriptor.IsDefined(typeof(NoTokenCheckAttribute), true) ||
                filterContext.ActionDescriptor.ControllerDescriptor.IsDefined(typeof(NoTokenCheckAttribute), true))
            {
                return;
            }
            var token = filterContext.HttpContext.Request.Headers["token"];

            if (!string.IsNullOrWhiteSpace(token))
            {
                var userId = int.Parse(token.Decrypt());
                if (CheckToken(userId))
                {
                    SessionManager.Add(ConstString.UserLoginId, userId);
                    return;
                }
            }
            filterContext.HttpContext.Response.ContentType = "application/json";
            var result = ResMessage.CreatMessage(ResultMessageEnum.Error, "无Token用户权限,请登录获取token");

            filterContext.Result = new JsonResult()
            {
                Data = result,
                JsonRequestBehavior = JsonRequestBehavior.AllowGet
            };
            //string json = JsonConvert.SerializeObject(result);
            //filterContext.HttpContext.Response.Write(json);
            filterContext.HttpContext.Response.End();
            filterContext.HttpContext.Response.Close();
        }
コード例 #3
0
        /// <summary>
        /// 权限验证
        /// </summary>
        /// <param name="filterContext"></param>
        public override void OnAuthorization(AuthorizationContext filterContext)
        {
            //过滤验证
            if (filterContext.ActionDescriptor.IsDefined(typeof(AllowAnonymousAttribute), true) ||
                filterContext.ActionDescriptor.ControllerDescriptor.IsDefined(typeof(AllowAnonymousAttribute), true))
            {
                return;
            }
            var token = filterContext.HttpContext.Request.Headers["token"];

            if (!string.IsNullOrWhiteSpace(token))
            {
                string userId = token.Decrypt();
                if (CheckToken(userId))
                {
                    SessionManager.Add(ConstString.SysUserLoginId, userId);
                    return;
                }
            }
            filterContext.HttpContext.Response.ContentType = "application/json";
            var    result = ResMessage.CreatMessage(ResultTypeEnum.Error, "无Token用户权限,请登录获取token");
            string json   = JsonConvert.SerializeObject(result);

            filterContext.HttpContext.Response.Write(json);
            filterContext.HttpContext.Response.End();
        }
コード例 #4
0
        public ActionResult MenuButtonsByMenuId(string menuId)
        {
            Func <List <Sys_button>, List <ResButton> > func = (x) =>
                                                               x.Select(t =>
                                                                        ResButton.CreatesInstance(t.ButtonId, t.ButtonName, t.ButtonSeq ?? 0, t.ButtonIcon)).ToList();
            var allbtns  = _buttonShareBll.LoadEntities();
            var menubtns = _buttonBll.GetMenuButtonsByMenuId(menuId);
            var result   = ResdSingleToMultiple <ResButton> .CreateObject(func(allbtns), func(menubtns), menuId);

            return(Json(ResMessage.CreatMessage(ResultTypeEnum.Success, "执行成功", result)));
        }
コード例 #5
0
        public ActionResult DelMenuExecutive(string menuId, string delMenuId)
        {
            var isBtn = _buttonBll.BtnJurisdiction(menuId, (int)Operation.Delete);

            if (!isBtn)
            {
                return(Json(ResMessage.CreatMessage(ResultTypeEnum.ValidateError, "您没有删除按钮权限")));
            }
            var delMenuIds = delMenuId.Split(',');

            if (delMenuIds == null || delMenuIds.Any())
            {
                return(Json(ResMessage.CreatMessage(ResultTypeEnum.ValidateError, "传入delMenuId值不存在元素")));
            }
            var result = _menuShareBll.BulkDelete(x => delMenuIds.Contains(x.MenuId));

            return(Json(ResMessage.CreatMessage(ResultTypeEnum.Success)));
        }
コード例 #6
0
        public void ResultMessageTest()
        {
            var obj = new { Id = 1, Name = "二狗子" };

            var viewModel = ResMessage.CreatMessage(ResultMessageEnum.Success);
            var json      = JsonHelper.Serialize(viewModel);


            viewModel = ResMessage.CreatMessage(ResultMessageEnum.Success, "业务处理成功");
            json      = JsonHelper.Serialize(viewModel);


            viewModel = ResMessage.CreatMessage(ResultMessageEnum.Success, obj);
            json      = JsonHelper.Serialize(viewModel);


            viewModel = ResMessage.CreatMessage(ResultMessageEnum.Success, "业务处理成功", obj);
            json      = JsonHelper.Serialize(viewModel);
        }
コード例 #7
0
        /// <summary>
        /// 充值
        /// </summary>
        /// <param name="req"></param>
        /// <returns></returns>
        public ActionResult Recharge(ReqConsumptiondetails req)
        {
            object Lock = new object();

            lock (Lock)
            {
                if (!ModelState.IsValid)
                {
                    var errorMsg = ModelState.FristModelStateErrors().FirstOrDefault();
                    return(Json(ResMessage.CreatMessage(ResultMessageEnum.ValidateError, errorMsg)));
                }
                if (req != null)
                {
                    var userId         = Convert.ToInt32(SessionManager.Get(ConstString.UserLoginId).ToString());
                    var userinfo       = new BaseBLL <UserInfo>().FirstOrDefault(x => x.Id.Equals(userId));
                    var personalWallet = new BaseBLL <PersonalWallet>().FirstOrDefault(x => x.UserName.Equals(userId.ToString()));
                    if (userinfo == null)
                    {
                        return(Json(ResMessage.CreatMessage(ResultMessageEnum.Error, "该用户不存在")));
                    }
                    var bll = new CapitalBLL();
                    if (req.Amount <= 0)
                    {
                        return(Json(ResMessage.CreatMessage(ResultMessageEnum.Error, "充值金额不能小于等于0")));
                    }
                    if (personalWallet == null)
                    {
                        return(Json(ResMessage.CreatMessage(ResultMessageEnum.Error, "用户钱包不存在")));
                    }
                    bool bl = bll.Recharge(req, userId.ToString());
                    if (bl)
                    {
                        bool blz = bll.AddBalance(userId.ToString(), req.Amount);
                        if (blz)
                        {
                            return(Json(ResMessage.CreatMessage(ResultMessageEnum.Success, "充值成功")));
                        }
                    }
                }
                return(Json(ResMessage.CreatMessage(ResultMessageEnum.Error, "充值失败")));
            }
        }
コード例 #8
0
ファイル: LoginAction.cs プロジェクト: alivy/MyBackStage
        /// <summary>
        /// API用户登录功能
        /// </summary>
        /// <param name="viewUser"></param>
        /// <returns></returns>
        public ActionResult APIAction(ViewUserLogin viewUser)
        {
            if (!ModelState.IsValid)
            {
                var errorMsg = ModelState.FristModelStateErrors().FirstOrDefault();;
                return(RequestAction(ResMessage.CreatMessage(ResultTypeEnum.ValidateError, errorMsg)));
            }
            var check = APICheckLogin(viewUser);

            if (!check.Item1)
            {
                return(RequestAction(ResMessage.CreatMessage(ResultTypeEnum.Error, "用户名或密码错误")));
            }
            var userId = check.Item2;

            LoginHistory(userId, viewUser.City);
            var token = userId.Encrypt();

            return(RequestAction(ResMessage.CreatMessage(ResultTypeEnum.Success, "登陆成功", ResLoginAPI.GetInstance(token))));
        }
コード例 #9
0
        /// <summary>
        /// 购买足彩
        /// </summary>
        /// <returns></returns>
        public ActionResult BuyFullLottery(ReqBuyFullLottery req)
        {
            if (req.Content.Count() == 0 || !req.Content.Any())
            {
                return(Json(ResMessage.CreatMessage(ResultMessageEnum.Success, "投注内容信息不能为空")));
            }
            var userId  = SessionManager.Get(ConstString.UserLoginId).ObjToInt();
            var orderNo = pulseBLL.GetOrderNoByName("ZQC8", userId);

            userOrderBaseBLL.AddEntity(new UserOrder
            {
                OrderNo        = orderNo,
                UserId         = userId,
                CopePayMoney   = 1,
                ActualPayMoney = 1,
                State          = 1,
                CreateTime     = DateTime.Now
            });
            var order = new UserOrder();

            return(View());
        }
コード例 #10
0
        public ActionResult AddMenuExecutive(ReqNavMenuView navMenu)
        {
            bool result = false;

            if (!navMenu.GetIsValid())
            {
                string errorMsg = navMenu.GetErrorMessageList().First().ErrorMessage;
                return(Json(ResMessage.CreatMessage(ResultTypeEnum.Exception, errorMsg)));
            }
            string newMenuId = string.Empty;

            if (navMenu.ParentMenId != null || navMenu.Level > 1)
            {
                var nav = _menuShareBll.FirstOrDefault <Sys_NavMenu>(x => x.MenuId.Equals(navMenu.ParentMenId));
                if (nav == null)
                {
                    return(Json(ResMessage.CreatMessage(ResultTypeEnum.Error, "父级菜单不存在")));
                }
                newMenuId     = _navMenuBll.maxSubMenuId(navMenu.ParentMenId);
                navMenu.Level = 2;
            }
            else
            {
                newMenuId           = _navMenuBll.maxParentMenuId();
                navMenu.Level       = 2;
                navMenu.ParentMenId = "$";
            }
            result = _menuShareBll.AddEntity(new Sys_NavMenu
            {
                MenuId      = newMenuId,
                MenuName    = navMenu.MenuName,
                ParentMenId = navMenu.ParentMenId,
                Level       = navMenu.Level,
                Url         = navMenu.Url,
                Seq         = navMenu.Seq,
                IsVisible   = navMenu.IsVisible
            });
            return(Json(ResMessage.CreatMessage(result ? ResultTypeEnum.Success : ResultTypeEnum.Exception)));
        }