Exemplo n.º 1
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IWebHostEnvironment env, OrderManagementDB DBContext)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }
            else
            {
                app.UseExceptionHandler("/Home/Error");
            }
            app.UseStaticFiles();

            app.UseRouting();

            app.UseHQMysqlDBContext(DBContext);

            ////启用授权服务
            app.UseHQAuthorization();


            //设置跨域
            //app.UseCors();
            app.UseCors("CorsPolicy");

            app.UseEndpoints(endpoints =>
            {
                endpoints.MapControllerRoute(
                    name: "default",
                    pattern: "{controller=Authority}/{action=Index}/{upar1?}/{upar2?}/{upar3?}", new { area = "Authority" });
                endpoints.MapControllerRoute(
                    name: "areaDefault",
                    pattern: "{area=Main}/{controller=Authority}/{action=Index}/{upar1?}/{upar2?}/{upar3?}");
            });
        }
Exemplo n.º 2
0
        public List <OrderManagementModel.DBModel.Authority.Authority_PermissionBase> GetPermissionList()
        {
            OrderManagementDB DBcontext = new OrderManagementDB();

            var vl = DBcontext.Authority_PermissionBase.OrderByDescending(o => o.ID);

            return(vl.ToList());
        }
Exemplo n.º 3
0
        public List <OrderManagementModel.DBModel.Authority.Authority_Account> GetAccountList()
        {
            OrderManagementDB DBcontext = new OrderManagementDB();

            var vl = DBcontext.Authority_Account.OrderByDescending(o => o.ID);

            return(vl.ToList());
        }
Exemplo n.º 4
0
        public HQResult <string> AddRole(string RoleName, string Description)
        {
            HQResult <string> result    = new HQResult <string>();
            OrderManagementDB DBcontext = new OrderManagementDB();

            DBcontext.Authority_Role.Add(new  Authority_Role {
                RoleName = RoleName, Description = Description
            });
            DBcontext.SaveChanges();

            return(result.SetResult(1, "ok"));
        }
Exemplo n.º 5
0
        public HQResult <string> AddAccount(string Account, string Name, string Pass)
        {
            HQResult <string> result    = new HQResult <string>();
            OrderManagementDB DBcontext = new OrderManagementDB();

            DBcontext.Authority_Account.Add(new Authority_Account {
                Account = Account, Name = Name, Pass = Pass,
            });
            DBcontext.SaveChanges();

            return(result.SetResult(1, "ok"));
        }
Exemplo n.º 6
0
        public HQResult <string> RelatedPerBase(int RoleId, int BaseId)
        {
            HQResult <string> result    = new HQResult <string>();
            OrderManagementDB DBcontext = new OrderManagementDB();

            DBcontext.Authority_RelatedRoleBasePer.Add(new  OrderManagementModel.DBModel.Authority.Authority_RelatedRoleBasePer()
            {
                BasePerID = BaseId, RoleID = RoleId
            });
            DBcontext.SaveChanges();

            return(result.SetResult(1, "ok"));
        }
Exemplo n.º 7
0
        public HQResult <string> RelatedRole(int AccountId, int RoleId)
        {
            HQResult <string> result    = new HQResult <string>();
            OrderManagementDB DBcontext = new OrderManagementDB();

            DBcontext.Authority_RelatedAccountRole.Add(new OrderManagementModel.DBModel.Authority.Authority_RelatedAccountRole()
            {
                AccountID = AccountId, RoleID = RoleId
            });
            DBcontext.SaveChanges();

            return(result.SetResult(1, "ok"));
        }
Exemplo n.º 8
0
        public PagingResult <Authority_PermissionBase> GetPaging(Authority_PermissionBaseWhere where)
        {
            PagingResult <Authority_PermissionBase> Result = new PagingResult <Authority_PermissionBase>();


            OrderManagementDB DBcontext = new OrderManagementDB();

            IQueryable <Authority_PermissionBase> Queryable;

            Queryable = DBcontext.Authority_PermissionBase
                        .OrderByDescending(o => o.ID);



            if (where.ID > 0)
            {
                Queryable = Queryable.Where(w => w.ID == where.ID);
            }

            if (string.IsNullOrWhiteSpace(where.Action))
            {
                Queryable = Queryable.Where(w => w.Action == where.Action);
            }

            if (string.IsNullOrWhiteSpace(where.Area))
            {
                Queryable = Queryable.Where(w => w.Area == where.Area);
            }

            if (string.IsNullOrWhiteSpace(where.Control))
            {
                Queryable = Queryable.Where(w => w.Control == where.Control);
            }

            if (string.IsNullOrWhiteSpace(where.Description))
            {
                Queryable = Queryable.Where(w => w.Description.Contains(where.Description));
            }

            if (where.PageIndex > 0 && where.PageCount > 0)
            {
                Queryable = DBcontext.Authority_PermissionBase.Skip((where.PageIndex - 1) * where.PageCount).Take(where.PageCount);
            }


            Result.list = Queryable.ToList();

            return(Result);
        }
Exemplo n.º 9
0
        public HQResult <Authority_Account> Sigin(string Account, string Password)
        {
            HQResult <Authority_Account> result = new HQResult <Authority_Account>();

            OrderManagementDB DBcontext = new OrderManagementDB();

            var user = DBcontext.Authority_Account.Where(w => w.Account == Account && w.Pass == Password)
                       .Include(p => p.RelatedRoles)
                       .ThenInclude(p => p.Role)
                       .ThenInclude(p => p.RelatedRoleBases)
                       .ThenInclude(p => p.BasePer).FirstOrDefault();

            if (user == null)
            {
                return(result.SetResult(-1, null));
            }

            return(result.SetResult(1, "ok", user));
        }
Exemplo n.º 10
0
        public List <OrderManagementModel.DBModel.Authority.Authority_Account> GetAccountWhere(AccountWhere where)
        {
            OrderManagementDB DBcontext = new OrderManagementDB();

            //List<int> ids = new List<int>();
            //ids.Add(1);
            //ids.Add(2);
            //ids.Add(3);
            //ids.Add(4);
            //ids.Add(5);

            //int[] idarray =  new int[] { 1, 3, 5, 7, 9 };

            //var test1 = DBcontext.Authority_Account.AsQueryable();
            //var test2 = test1.Where(o => idarray.Contains(o.ID));

            //var v3= test2.ToList();


            var Queryable = DBcontext.Authority_Account.AsQueryable().GetWhere(new PageQueryParam <AccountWhere>(where));


            return(Queryable.ToList());
        }
Exemplo n.º 11
0
        /// <summary>
        /// 启用授权服务
        /// 一定要放在 UseRouting 下面.放在UseEndpoints 上面.否则会影响系统正常运行.
        /// </summary>
        /// <param name="app"></param>
        /// <returns></returns>
        public static IApplicationBuilder UseHQMysqlDBContext(this IApplicationBuilder app, OrderManagementDB context)
        {
            context.Database.Migrate();

            return(app);
        }