예제 #1
0
        public IActionResult GetList(Authority model)
        {
            using var bll = new AuthorityBll();
            var rst = bll.GetList("");

            return(Json(rst));
        }
예제 #2
0
        public IActionResult Delete(Authority model)
        {
            using var bll = new AuthorityBll();
            var rst = bll.Delete(model);

            return(Json(rst));
        }
예제 #3
0
        public IActionResult GetOne(Authority model)
        {
            if (model.id == 0)
            {
                var defalut = new ReturnResult <Authority>()
                {
                    Result = true,
                    Data   = new Authority()
                };
                return(Json(defalut));
            }
            using var bll = new AuthorityBll();
            var rst = bll.GetOne(model);

            return(Json(rst));
        }
예제 #4
0
        public IActionResult Add(Authority model)
        {
            var rst = new ReturnResult <bool>();

            using var bll = new AuthorityBll();
            if (model.id == 0)
            {
                rst = bll.Add(model);
            }
            else
            {
                rst = bll.Update(model);
            }

            return(Json(rst));
        }
예제 #5
0
 public CAuthorityModel Post(CAuthorityModel value)
 {
     using (var dal = DalBuilder.CreateDal(ConfigurationManager.ConnectionStrings["DefaultConnection"].ConnectionString, 0))
     {
         bool ok;
         try
         {
             dal.Open();
         }
         catch
         {
             throw new HttpResponseException(new SystemExceptionMessage());
         }
         var httpCookie = HttpContext.Current.Request.Cookies["Token"];
         if (value.Remain && httpCookie != null && string.IsNullOrEmpty(value.UserCode) && string.IsNullOrEmpty(value.UPwd))
         {
             //Token不为空 用户名和密码为空,则使用token登录
             ok = AuthorityBll.Signin(dal, httpCookie.Value, value);
         }
         else
         {
             //使用用户名密码登录
             ok = AuthorityBll.Signin(dal, value);
         }
         if (!ok)
         {
             throw new HttpResponseException(new DataNotFoundMessage());
         }
         HttpContext.Current.Session["SignUser"] = value;
         //生成Token
         var token = Guid.NewGuid().ToString();
         AuthorityBll.UpdateToken(dal, token, value.UserCode);
         HttpContext.Current.Response.Cookies["Token"].Value   = token;
         HttpContext.Current.Response.Cookies["Token"].Expires = DateTime.Now.AddDays(30);
         if (value.Remain)
         {
             return(value);
         }
         HttpContext.Current.Response.Cookies["Token"].Expires = DateTime.Now.AddDays(-1);
         AuthorityBll.DropToken(dal, value.UserCode);
         return(value);
     }
 }
예제 #6
0
 /// <summary>
 /// 构造
 /// </summary>
 /// <param name="bll"></param>
 public AuthorityController(AuthorityBll bll, AuthorityRoleBll authRoleBll,
                            IOptions <SysConfig> config) : base(bll, config)
 {
     _bll         = bll;
     _authRoleBll = authRoleBll;
 }