Merge commit 'refs/pull/11/head' of https://gitee.com/izory/ZrAdminNetCore

This commit is contained in:
不做码农
2022-07-01 22:18:32 +08:00
16 changed files with 90 additions and 129 deletions

View File

@@ -1,10 +1,6 @@
using Infrastructure;
using Microsoft.Extensions.Configuration;
using SqlSugar;
using SqlSugar.IOC;
using System;
using System.Collections.Generic;
using System.Linq;
using ZR.Admin.WebApi.Framework;
using ZR.Model.System;
@@ -24,6 +20,9 @@ namespace ZR.Admin.WebApi.Extensions
//仅本人数据权限
public static string DATA_SCOPE_SELF = "5";
public static void AddDb(IConfiguration Configuration)
{
string connStr = Configuration.GetConnectionString("conn_db");
@@ -83,6 +82,18 @@ namespace ZR.Admin.WebApi.Extensions
};
#endregion
});
}
public static void InitDb(this IServiceProvider service)
{
var db = DbScoped.SugarScope;
db.DbMaintenance.CreateDatabase();
//db.CodeFirst.
var baseType = typeof(SysBase);
var entityes = AssemblyUtils.GetAllTypes().Where(p => !p.IsAbstract && p != baseType && /*p.IsAssignableTo(baseType) && */p.GetCustomAttribute<SugarTable>()!=null).ToArray();
db.CodeFirst.SetStringDefaultLength(512).InitTables(entityes);
}
/// <summary>

View File

@@ -39,7 +39,7 @@ namespace ZR.Admin.WebApi.Extensions
public static void AddSwaggerConfig(this IServiceCollection services)
{
if (services == null) throw new ArgumentNullException(nameof(services));
IWebHostEnvironment hostEnvironment = App.GetRequiredService<IWebHostEnvironment>();
//IWebHostEnvironment hostEnvironment = App.GetRequiredService<IWebHostEnvironment>();
services.AddSwaggerGen(c =>
{
@@ -52,7 +52,7 @@ namespace ZR.Admin.WebApi.Extensions
try
{
//添加文档注释
c.IncludeXmlComments(Path.Combine(hostEnvironment.ContentRootPath, "ZRAdmin.xml"), true);
c.IncludeXmlComments("ZRAdmin.xml", true);
}
catch (Exception ex)
{

View File

@@ -35,7 +35,7 @@ namespace ZR.Admin.WebApi.Extensions
{
//var _tasksQzService = (ISysTasksQzService)App.GetRequiredService(typeof(ISysTasksQzService));
ITaskSchedulerServer _schedulerServer = App.GetRequiredService<ITaskSchedulerServer>();
ITaskSchedulerServer _schedulerServer = app.ApplicationServices.GetRequiredService<ITaskSchedulerServer>();
//var tasks = _tasksQzService.GetList(m => m.IsStart);
var tasks = SqlSugar.IOC.DbScoped.SugarScope.Queryable<Model.System.SysTasksQz>().Where(m => m.IsStart).ToList();