添加代码生成模块

This commit is contained in:
橙子
2023-01-21 18:09:21 +08:00
parent 9b1b915925
commit 1f702c20ae
69 changed files with 828 additions and 7 deletions

View File

@@ -0,0 +1,23 @@
<?xml version="1.0"?>
<doc>
<assembly>
<name>Yi.Framework.Application.Contracts</name>
</assembly>
<members>
<member name="T:Yi.Framework.Application.Contracts.Student.Dtos.StudentCreateInputVo">
<summary>
Student输入创建对象
</summary>
</member>
<member name="P:Yi.Framework.Application.Contracts.Student.Dtos.StudentGetListOutputDto.IsDeleted">
<summary>
想看一下结果
</summary>
</member>
<member name="T:Yi.Framework.Application.Contracts.Student.IStudentService">
<summary>
服务抽象
</summary>
</member>
</members>
</doc>

View File

@@ -0,0 +1,18 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Yi.Framework.Application.Contracts.Student.Dtos
{
/// <summary>
/// Student输入创建对象
/// </summary>
public class StudentCreateInputVo
{
public string Name { get; set; }
public long Number { get; set; }
}
}

View File

@@ -0,0 +1,16 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Yi.Framework.Ddd.Dtos;
namespace Yi.Framework.Application.Contracts.Student.Dtos
{
public class StudentGetListInputVo : PagedAndSortedResultRequestDto
{
public string? Name { get; set; }
public long? Number { get; set; }
}
}

View File

@@ -0,0 +1,21 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Yi.Framework.Ddd.Dtos;
namespace Yi.Framework.Application.Contracts.Student.Dtos
{
public class StudentGetListOutputDto : IEntityDto<long>
{
public long Id { get; set; }
public string Name { get; set; }
public long Number { get; set; }
/// <summary>
/// 想看一下结果
/// </summary>
public bool IsDeleted { get; set; }
}
}

View File

@@ -0,0 +1,17 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Yi.Framework.Ddd.Dtos;
namespace Yi.Framework.Application.Contracts.Student.Dtos
{
public class StudentGetOutputDto : IEntityDto<long>
{
public long Id { get; set; }
public string Name { get; set; }
public long Number { get; set; }
}
}

View File

@@ -0,0 +1,17 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Yi.Framework.Application.Contracts.Student.Dtos
{
public class StudentUpdateInputVo
{
public string? Name { get; set; }
public long? Number { get; set; }
public bool IsDeleted { get; set; }
}
}

View File

@@ -0,0 +1,18 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Yi.Framework.Application.Contracts.Student.Dtos;
using Yi.Framework.Ddd.Services.Abstract;
namespace Yi.Framework.Application.Contracts.Student
{
/// <summary>
/// 服务抽象
/// </summary>
public interface IStudentService : ICrudAppService<StudentGetOutputDto, StudentGetListOutputDto, long, StudentGetListInputVo, StudentCreateInputVo, StudentUpdateInputVo>
{
}
}

View File

@@ -0,0 +1,23 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<GenerateDocumentationFile>True</GenerateDocumentationFile>
<DocumentationFile>./ApplicationContractsSwaggerDoc.xml</DocumentationFile>
</PropertyGroup>
<ItemGroup>
<Compile Include="..\..\GlobalUsings.cs" Link="Properties\GlobalUsings.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Yi.Framework.Domain.Shared\Yi.Framework.Domain.Shared.csproj" />
</ItemGroup>
<ItemGroup>
<None Update="ApplicationContractsSwaggerDoc.xml">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
</ItemGroup>
</Project>

View File

@@ -0,0 +1,27 @@
using Microsoft.AspNetCore.Builder;
using Microsoft.Extensions.DependencyInjection;
using StartupModules;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Yi.Framework.Core.Attributes;
using Yi.Framework.Domain.Shared;
namespace Yi.Framework.Application.Contracts
{
[DependsOn(
typeof(YiFrameworkDomainSharedModule)
)]
public class YiFrameworkApplicationContractsModule : IStartupModule
{
public void Configure(IApplicationBuilder app, ConfigureMiddlewareContext context)
{
}
public void ConfigureServices(IServiceCollection services, ConfigureServicesContext context)
{
}
}
}

View File

@@ -0,0 +1,32 @@
<?xml version="1.0"?>
<doc>
<assembly>
<name>Yi.Framework.Application</name>
</assembly>
<members>
<member name="T:Yi.Framework.Application.Student.StudentService">
<summary>
服务实现
</summary>
</member>
<member name="M:Yi.Framework.Application.Student.StudentService.GetDataFiterTestAsync(Yi.Framework.Application.Contracts.Student.Dtos.StudentGetListInputVo)">
<summary>
数据过滤测试
</summary>
<param name="input"></param>
<returns></returns>
</member>
<member name="M:Yi.Framework.Application.Student.StudentService.GetToken">
<summary>
测试token
</summary>
<returns></returns>
</member>
<member name="M:Yi.Framework.Application.Student.StudentService.PostUow">
<summary>
Uow
</summary>
<returns></returns>
</member>
</members>
</doc>

View File

@@ -0,0 +1,23 @@
using AutoMapper;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Yi.Framework.Application.Contracts.Student.Dtos;
using Yi.Framework.Domain.Student.Entities;
namespace Yi.Framework.Application.Student.MapperConfig
{
public class StudentProfile: Profile
{
public StudentProfile()
{
CreateMap<StudentGetListInputVo, StudentEntity>();
CreateMap<StudentCreateInputVo, StudentEntity>();
CreateMap<StudentUpdateInputVo, StudentEntity>();
CreateMap<StudentEntity, StudentGetListOutputDto>();
CreateMap<StudentEntity, StudentGetOutputDto>();
}
}
}

View File

@@ -0,0 +1,105 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Yi.Framework.Application.Contracts.Student;
using Yi.Framework.Domain.Student;
using Microsoft.AspNetCore.Mvc;
using NET.AutoWebApi.Setting;
using Microsoft.AspNetCore.Http;
using Yi.Framework.Ddd.Services.Abstract;
using Yi.Framework.Application.Contracts.Student.Dtos;
using Yi.Framework.Domain.Student.Entities;
using Yi.Framework.Ddd.Services;
using Yi.Framework.Core.Attributes;
using Yi.Framework.Uow;
using Microsoft.AspNetCore.Authorization;
using Yi.Framework.Auth.JwtBearer.Authentication;
using Yi.Framework.Core.Const;
using Yi.Framework.Core.CurrentUsers;
using Yi.Framework.Auth.JwtBearer.Authorization;
using Yi.Framework.Domain.Shared.Student.ConstClasses;
using Yi.Framework.Domain.Student.Repositories;
using Yi.Framework.Data.Filters;
using Yi.Framework.Data.Entities;
using Yi.Framework.Ddd.Dtos;
namespace Yi.Framework.Application.Student
{
/// <summary>
/// 服务实现
/// </summary>
[AppService]
public class StudentService : CrudAppService<StudentEntity, StudentGetOutputDto, StudentGetListOutputDto, long, StudentGetListInputVo, StudentCreateInputVo, StudentUpdateInputVo>,
IStudentService, IAutoApiService
{
private readonly IStudentRepository _studentRepository;
private readonly StudentManager _studentManager;
private readonly IUnitOfWorkManager _unitOfWorkManager;
private readonly JwtTokenManager _jwtTokenManager;
private readonly ICurrentUser _currentUser;
private readonly IDataFilter _dataFilter;
public StudentService(IStudentRepository studentRepository, StudentManager studentManager, IUnitOfWorkManager unitOfWorkManager, JwtTokenManager jwtTokenManager, ICurrentUser currentUser, IDataFilter dataFilter)
{
_studentRepository = studentRepository;
_studentManager = studentManager;
_unitOfWorkManager = unitOfWorkManager;
_jwtTokenManager = jwtTokenManager;
_currentUser = currentUser;
_dataFilter = dataFilter;
}
/// <summary>
/// 数据过滤测试
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
public async Task<PagedResultDto<StudentGetListOutputDto>> GetDataFiterTestAsync(StudentGetListInputVo input)
{
PagedResultDto<StudentGetListOutputDto> res = new();
using (_dataFilter.Disable<ISoftDelete>())
{
res = await base.GetListAsync(input);
}
var p = await base.GetListAsync(input);
return res;
}
/// <summary>
/// 测试token
/// </summary>
/// <returns></returns>
public string GetToken()
{
var claimDic = new Dictionary<string, object>() { { TokenTypeConst.Id, "123" }, { TokenTypeConst.UserName, "cc" } };
return _jwtTokenManager.CreateToken(claimDic);
}
/// <summary>
/// Uow
/// </summary>
/// <returns></returns>
[Authorize]
[Permission(AuthStudentConst.查询)]
public async Task<StudentGetOutputDto> PostUow()
{
var o = _currentUser;
StudentGetOutputDto res = new();
using (var uow = _unitOfWorkManager.CreateContext())
{
var studentRepository = uow.GetRepository<StudentEntity>();
res = await base.CreateAsync(new StudentCreateInputVo { Name = $"老杰哥{DateTime.Now.ToString("ffff")}", Number = 2023 });
if (new Random().Next(0, 2) == 0) throw new NotImplementedException();
uow.Commit();
}
return res;
}
}
}

View File

@@ -0,0 +1,20 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<GenerateDocumentationFile>True</GenerateDocumentationFile>
<DocumentationFile>./ApplicationSwaggerDoc.xml</DocumentationFile>
</PropertyGroup>
<ItemGroup>
<Compile Include="..\..\GlobalUsings.cs" Link="Properties\GlobalUsings.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\src\framework\Yi.Framework.Auth.JwtBearer\Yi.Framework.Auth.JwtBearer.csproj" />
<ProjectReference Include="..\..\src\framework\Yi.Framework.Uow\Yi.Framework.Uow.csproj" />
<ProjectReference Include="..\Yi.Framework.Application.Contracts\Yi.Framework.Application.Contracts.csproj" />
<ProjectReference Include="..\Yi.Framework.Domain\Yi.Framework.Domain.csproj" />
</ItemGroup>
</Project>

View File

@@ -0,0 +1,35 @@
using Microsoft.AspNetCore.Builder;
using Microsoft.Extensions.DependencyInjection;
using StartupModules;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Yi.Framework.Application.Contracts;
using Yi.Framework.Application.Contracts.Student;
using Yi.Framework.Application.Student;
using Yi.Framework.Auth.JwtBearer;
using Yi.Framework.Core.Attributes;
using Yi.Framework.Data;
using Yi.Framework.Ddd;
using Yi.Framework.Domain;
namespace Yi.Framework.Application
{
[DependsOn(
typeof(YiFrameworkApplicationContractsModule),
typeof(YiFrameworkDomainModule),
typeof(YiFrameworkAuthJwtBearerModule)
)]
public class YiFrameworkApplicationModule : IStartupModule
{
public void Configure(IApplicationBuilder app, ConfigureMiddlewareContext context)
{
}
public void ConfigureServices(IServiceCollection services, ConfigureServicesContext context)
{
}
}
}

View File

@@ -0,0 +1 @@
global using Yi.Framework.Core.Attributes;

View File

@@ -0,0 +1,14 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Yi.Framework.Domain.Shared.Student.ConstClasses
{
public class AuthStudentConst
{
public const string = "student:student:list";
public const string = "student:student:add";
}
}

View File

@@ -0,0 +1,17 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Yi.Framework.Domain.Shared.Student.ConstClasses
{
/// <summary>
/// 常量定义
/// </summary>
public class StudentConst
{
public const string = "失败!学生已经重复";
}
}

View File

@@ -0,0 +1,15 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<Compile Include="..\..\GlobalUsings.cs" Link="Properties\GlobalUsings.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\src\framework\Yi.Framework.Ddd\Yi.Framework.Ddd.csproj" />
</ItemGroup>
</Project>

View File

@@ -0,0 +1,27 @@
using Microsoft.AspNetCore.Builder;
using Microsoft.Extensions.DependencyInjection;
using StartupModules;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Yi.Framework.Core.Attributes;
using Yi.Framework.Ddd;
namespace Yi.Framework.Domain.Shared
{
[DependsOn(
typeof(YiFrameworkDddModule)
)]
public class YiFrameworkDomainSharedModule : IStartupModule
{
public void Configure(IApplicationBuilder app, ConfigureMiddlewareContext context)
{
}
public void ConfigureServices(IServiceCollection services, ConfigureServicesContext context)
{
}
}
}

View File

@@ -0,0 +1,38 @@
<?xml version="1.0"?>
<doc>
<assembly>
<name>Yi.Framework.Domain</name>
</assembly>
<members>
<member name="T:Yi.Framework.Domain.Student.Entities.StudentEntity">
<summary>
学生实体
</summary>
</member>
<member name="P:Yi.Framework.Domain.Student.Entities.StudentEntity.Name">
<summary>
学生名称
</summary>
</member>
<member name="P:Yi.Framework.Domain.Student.Entities.StudentEntity.Number">
<summary>
学号
</summary>
</member>
<member name="P:Yi.Framework.Domain.Student.Entities.StudentEntity.IsDeleted">
<summary>
软删除
</summary>
</member>
<member name="T:Yi.Framework.Domain.Student.Repositories.IStudentRepository">
<summary>
仓储抽象
</summary>
</member>
<member name="T:Yi.Framework.Domain.Student.StudentManager">
<summary>
领域服务
</summary>
</member>
</members>
</doc>

View File

@@ -0,0 +1,36 @@
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Yi.Framework.Data.Entities;
using Yi.Framework.Ddd.Entities;
namespace Yi.Framework.Domain.Student.Entities
{
/// <summary>
/// 学生实体
/// </summary>
[SugarTable("Student")]
public class StudentEntity : IEntity<long>, ISoftDelete
{
[SugarColumn(IsPrimaryKey = true)]
public long Id { get; set; }
/// <summary>
/// 学生名称
/// </summary>
public string Name { get; set; } = string.Empty;
/// <summary>
/// 学号
/// </summary>
public long Number { get;set ; }
/// <summary>
/// 软删除
/// </summary>
public bool IsDeleted { get; set; }
}
}

View File

@@ -0,0 +1,18 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Yi.Framework.Ddd.Repositories;
using Yi.Framework.Domain.Student.Entities;
namespace Yi.Framework.Domain.Student.Repositories
{
/// <summary>
/// 仓储抽象
/// </summary>
public interface IStudentRepository : IRepository<StudentEntity>
{
Task<List<StudentEntity>> GetMyListAsync();
}
}

View File

@@ -0,0 +1,21 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Yi.Framework.Domain.Student.Repositories;
namespace Yi.Framework.Domain.Student
{
/// <summary>
/// 领域服务
/// </summary>
public class StudentManager
{
private readonly IStudentRepository _studentRepository;
public StudentManager(IStudentRepository studentRepository)
{
_studentRepository=studentRepository;
}
}
}

View File

@@ -0,0 +1,24 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<GenerateDocumentationFile>True</GenerateDocumentationFile>
<DocumentationFile>./DomainSwaggerDoc.xml</DocumentationFile>
</PropertyGroup>
<ItemGroup>
<Compile Include="..\..\GlobalUsings.cs" Link="Properties\GlobalUsings.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\src\framework\Yi.Framework.Data\Yi.Framework.Data.csproj" />
<ProjectReference Include="..\Yi.Framework.Domain.Shared\Yi.Framework.Domain.Shared.csproj" />
</ItemGroup>
<ItemGroup>
<None Update="DomainSwaggerDoc.xml">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
</ItemGroup>
</Project>

View File

@@ -0,0 +1,31 @@
using Microsoft.AspNetCore.Builder;
using Microsoft.Extensions.DependencyInjection;
using StartupModules;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Yi.Framework.Core.Attributes;
using Yi.Framework.Data;
using Yi.Framework.Domain.Shared;
using Yi.Framework.Domain.Student;
namespace Yi.Framework.Domain
{
[DependsOn(
typeof(YiFrameworkDomainSharedModule),
typeof(YiFrameworkDataModule)
)]
public class YiFrameworkDomainModule : IStartupModule
{
public void Configure(IApplicationBuilder app, ConfigureMiddlewareContext context)
{
}
public void ConfigureServices(IServiceCollection services, ConfigureServicesContext context)
{
services.AddTransient<StudentManager>();
}
}
}

View File

@@ -0,0 +1,27 @@
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Yi.Framework.Core.Sqlsugar.Repositories;
using Yi.Framework.Domain.Student.Entities;
using Yi.Framework.Domain.Student.Repositories;
namespace Yi.Framework.Sqlsugar.Student
{
/// <summary>
/// 仓储实现方式
/// </summary>
public class StudentRepository : SqlsugarRepository<StudentEntity>, IStudentRepository
{
public StudentRepository(ISqlSugarClient context) : base(context)
{
}
public async Task<List<StudentEntity>> GetMyListAsync()
{
return await _DbQueryable.ToListAsync();
}
}
}

View File

@@ -0,0 +1,17 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<Compile Include="..\..\GlobalUsings.cs" Link="Properties\GlobalUsings.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\src\framework\Yi.Framework.Core.Sqlsugar\Yi.Framework.Core.Sqlsugar.csproj" />
<ProjectReference Include="..\Yi.Framework.Domain\Yi.Framework.Domain.csproj" />
</ItemGroup>
</Project>

View File

@@ -0,0 +1,30 @@
using Microsoft.AspNetCore.Builder;
using Microsoft.Extensions.DependencyInjection;
using StartupModules;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Yi.Framework.Core.Attributes;
using Yi.Framework.Core.Sqlsugar;
using Yi.Framework.Domain;
using Yi.Framework.Domain.Student.Repositories;
using Yi.Framework.Sqlsugar.Student;
namespace Yi.Framework.Sqlsugar
{
[DependsOn(typeof(YiFrameworkCoreSqlsugarModule),
typeof(YiFrameworkDomainModule))]
public class YiFrameworkSqlsugarModule : IStartupModule
{
public void Configure(IApplicationBuilder app, ConfigureMiddlewareContext context)
{
}
public void ConfigureServices(IServiceCollection services, ConfigureServicesContext context)
{
services.AddTransient<IStudentRepository, StudentRepository>();
}
}
}

View File

@@ -0,0 +1,34 @@
using AspNetCore.Microsoft.AspNetCore.Hosting;
using Yi.Framework.Core.Autofac.Extensions;
using Yi.Framework.Core.Autofac.Modules;
using Yi.Framework.Core.Extensions;
using Yi.Framework.Web;
TimeTest.Start();
var builder = WebApplication.CreateBuilder(args);
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>url
builder.WebHost.UseStartUrlsServer(builder.Configuration);
//<2F><><EFBFBD><EFBFBD>ģ<EFBFBD><C4A3>
builder.UseYiModules(typeof(YiFrameworkWebModule));
//<2F><><EFBFBD><EFBFBD>autofacģ<63><C4A3>,<2C><>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD>ģ<EFBFBD><C4A3>
builder.Host.ConfigureAutoFacContainer(container =>
{
container.RegisterYiModule(AutoFacModuleEnum.PropertiesAutowiredModule, typeof(YiFrameworkWebModule).Assembly);
});
var app = builder.Build();
var t = app.Services.GetService<Test2Entity>();
//ȫ<>ִ<EFBFBD><D6B4><EFBFBD><EFBFBD>м<EFBFBD><D0BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
app.UseErrorHandlingServer();
app.UseAuthentication();
app.UseAuthorization();
app.MapControllers();
app.Run();

View File

@@ -0,0 +1,15 @@
{
"$schema": "https://json.schemastore.org/launchsettings.json",
"profiles": {
"Yi.Framework.Web": {
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": true,
"launchUrl": "swagger",
"applicationUrl": "http://localhost:19002",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
}
}
}

View File

@@ -0,0 +1,10 @@
using Yi.Framework.Core.DependencyInjection;
namespace Yi.Framework.Web
{
public class Test2Entity: ITransientDependency
{
[Autowired]
public TestEntity testEntity { get; set; }
}
}

View File

@@ -0,0 +1,9 @@
using Yi.Framework.Core.DependencyInjection;
namespace Yi.Framework.Web
{
public class TestEntity: ITransientDependency
{
}
}

View File

@@ -0,0 +1,26 @@
using System.Diagnostics;
namespace Yi.Framework.Web
{
public class TimeTest
{
public static Stopwatch Stopwatch { get; set; }
public static void Start()
{
Stopwatch=new Stopwatch();
Stopwatch.Start();
}
public static void Result()
{
Stopwatch.Stop();
string time = Stopwatch.ElapsedMilliseconds.ToString();
Stopwatch.Restart();
string res = $"{DateTime.Now.ToString("yyyy:MM:dd-HH:mm:ss")}本次运行启动时间为:{time}毫秒\r\n";
Console.WriteLine(res);
File.AppendAllText("./TimeTest.txt", res);
}
}
}

View File

@@ -0,0 +1,77 @@
2023:01:16-22:36:40本次运行启动时间为2089毫秒
2023:01:16-22:36:49本次运行启动时间为2021毫秒
2023:01:16-22:37:01本次运行启动时间为2072毫秒
2023:01:16-22:39:23本次运行启动时间为2075毫秒
2023:01:16-22:40:48本次运行启动时间为2172毫秒
2023:01:16-22:41:12本次运行启动时间为2142毫秒
2023:01:16-22:42:05本次运行启动时间为2008毫秒
2023:01:16-22:43:22本次运行启动时间为1910毫秒
2023:01:16-22:44:33本次运行启动时间为2017毫秒
2023:01:17-17:30:46本次运行启动时间为23171毫秒
2023:01:17-17:45:11本次运行启动时间为4771毫秒
2023:01:17-17:45:54本次运行启动时间为1917毫秒
2023:01:17-17:48:04本次运行启动时间为2138毫秒
2023:01:17-17:57:41本次运行启动时间为1907毫秒
2023:01:17-17:58:29本次运行启动时间为1895毫秒
2023:01:17-17:58:43本次运行启动时间为1937毫秒
2023:01:17-17:59:38本次运行启动时间为1856毫秒
2023:01:17-21:06:57本次运行启动时间为2285毫秒
2023:01:17-21:09:32本次运行启动时间为2007毫秒
2023:01:17-21:10:16本次运行启动时间为1862毫秒
2023:01:17-21:12:25本次运行启动时间为2055毫秒
2023:01:17-21:13:46本次运行启动时间为5606毫秒
2023:01:17-21:14:35本次运行启动时间为4824毫秒
2023:01:17-21:18:17本次运行启动时间为8985毫秒
2023:01:17-21:19:48本次运行启动时间为1859毫秒
2023:01:17-21:21:32本次运行启动时间为1786毫秒
2023:01:17-22:41:17本次运行启动时间为1901毫秒
2023:01:17-22:42:21本次运行启动时间为1946毫秒
2023:01:17-22:42:55本次运行启动时间为1970毫秒
2023:01:17-22:43:56本次运行启动时间为2023毫秒
2023:01:17-22:45:25本次运行启动时间为1803毫秒
2023:01:17-22:45:52本次运行启动时间为1877毫秒
2023:01:17-23:24:07本次运行启动时间为1836毫秒
2023:01:17-23:29:20本次运行启动时间为1958毫秒
2023:01:17-23:45:25本次运行启动时间为2016毫秒
2023:01:18-19:34:47本次运行启动时间为2631毫秒
2023:01:18-19:36:58本次运行启动时间为2551毫秒
2023:01:18-19:40:12本次运行启动时间为1978毫秒
2023:01:19-13:52:51本次运行启动时间为2600毫秒
2023:01:19-13:54:09本次运行启动时间为2180毫秒
2023:01:19-13:54:43本次运行启动时间为2122毫秒
2023:01:19-13:55:58本次运行启动时间为2355毫秒
2023:01:19-14:03:10本次运行启动时间为2144毫秒
2023:01:19-14:08:44本次运行启动时间为2279毫秒
2023:01:19-14:13:40本次运行启动时间为2188毫秒
2023:01:19-14:28:11本次运行启动时间为2207毫秒
2023:01:19-14:31:37本次运行启动时间为2216毫秒
2023:01:19-14:35:15本次运行启动时间为2428毫秒
2023:01:19-14:38:41本次运行启动时间为2141毫秒
2023:01:19-14:40:57本次运行启动时间为2220毫秒
2023:01:19-14:47:12本次运行启动时间为2234毫秒
2023:01:19-14:49:25本次运行启动时间为2202毫秒
2023:01:19-14:51:18本次运行启动时间为2175毫秒
2023:01:19-14:53:52本次运行启动时间为2250毫秒
2023:01:19-14:54:38本次运行启动时间为2145毫秒
2023:01:19-14:55:21本次运行启动时间为2123毫秒
2023:01:19-15:20:38本次运行启动时间为2486毫秒
2023:01:19-15:22:37本次运行启动时间为2251毫秒
2023:01:19-15:26:31本次运行启动时间为2182毫秒
2023:01:19-15:28:47本次运行启动时间为2187毫秒
2023:01:19-15:29:07本次运行启动时间为2163毫秒
2023:01:19-15:29:57本次运行启动时间为2307毫秒
2023:01:19-15:35:21本次运行启动时间为3172毫秒
2023:01:19-17:47:34本次运行启动时间为2598毫秒
2023:01:19-17:52:49本次运行启动时间为1940毫秒
2023:01:19-17:54:41本次运行启动时间为1861毫秒
2023:01:19-17:57:37本次运行启动时间为1945毫秒
2023:01:20-18:25:59本次运行启动时间为43382毫秒
2023:01:20-18:29:09本次运行启动时间为2173毫秒
2023:01:20-18:32:14本次运行启动时间为2397毫秒
2023:01:20-18:34:14本次运行启动时间为2126毫秒
2023:01:20-18:38:36本次运行启动时间为2152毫秒
2023:01:20-18:45:15本次运行启动时间为7203毫秒
2023:01:20-18:50:46本次运行启动时间为6513毫秒
2023:01:20-18:53:16本次运行启动时间为5186毫秒
2023:01:20-19:01:36本次运行启动时间为5194毫秒
2023:01:21-15:04:00本次运行启动时间为7763毫秒

View File

@@ -0,0 +1,28 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>
<ItemGroup>
<Compile Include="..\..\GlobalUsings.cs" Link="Properties\GlobalUsings.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\src\framework\Yi.Framework.Core.Autofac\Yi.Framework.Core.Autofac.csproj" />
<ProjectReference Include="..\Yi.Framework.Application\Yi.Framework.Application.csproj" />
<ProjectReference Include="..\Yi.Framework.Sqlsugar\Yi.Framework.Sqlsugar.csproj" />
</ItemGroup>
<ItemGroup>
<None Update="key.pem">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="public.pem">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
</ItemGroup>
</Project>

View File

@@ -0,0 +1,46 @@
using AspNetCore.Microsoft.AspNetCore.Builder;
using StartupModules;
using Yi.Framework.Application;
using Yi.Framework.Auth.JwtBearer;
using Yi.Framework.Core;
using Yi.Framework.Core.Attributes;
using Yi.Framework.Sqlsugar;
namespace Yi.Framework.Web
{
[DependsOn(
typeof(YiFrameworkSqlsugarModule),
typeof(YiFrameworkApplicationModule)
)]
public class YiFrameworkWebModule : IStartupModule
{
public void ConfigureServices(IServiceCollection services, ConfigureServicesContext context)
{
//添加控制器与动态api
services.AddControllers();
services.AddAutoApiService(opt =>
{
//NETServiceTest所在程序集添加进动态api配置
opt.CreateConventional(typeof(YiFrameworkApplicationModule).Assembly, option => option.RootPath = string.Empty);
});
//添加swagger
services.AddSwaggerServer<YiFrameworkApplicationModule>();
}
public void Configure(IApplicationBuilder app, ConfigureMiddlewareContext context)
{
//if (app.Environment.IsDevelopment())
{
app.UseSwaggerServer();
}
app.UseHttpsRedirection();
app.UseAuthorization();
app.UseRouting();
TimeTest.Result();
}
}
}

View File

@@ -0,0 +1,38 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
},
"AllowedHosts": "*",
//程序启动地址,*代表全部网口
"StartUrl": "http://*:19002",
//数据库类型列表
"DbList": [ "Sqlite", "Mysql", "Sqlserver", "Oracle" ],
"DbConnOptions": {
"Url": "DataSource=yi-sqlsugar-dev.db",
"DbType": "Sqlite",
"EnabledDbSeed": false,
"EnabledReadWrite": false,
"EnabledCodeFirst": false,
"EntityAssembly": null,
"ReadUrl": [
"DataSource=[xxxx]", //sqlite
"server=[xxxx];port=3306;database=[xxxx];user id=[xxxx];password=[xxxx]", //mysql
"Data Source=[xxxx];Initial Catalog=[xxxx];User ID=[xxxx];password=[xxxx]" //sqlserver
]
},
"JwtTokenOptions": {
"Audience": "yi",
"Issuer": "localhost:19002",
"Subject": "yiframwork",
"ExpSecond": 3600
}
}

View File

@@ -0,0 +1,28 @@
-----BEGIN PRIVATE KEY-----
MIIEvwIBADANBgkqhkiG9w0BAQEFAASCBKkwggSlAgEAAoIBAQC7VJTUt9Us8cKj
MzEfYyjiWA4R4/M2bS1GB4t7NXp98C3SC6dVMvDuictGeurT8jNbvJZHtCSuYEvu
NMoSfm76oqFvAp8Gy0iz5sxjZmSnXyCdPEovGhLa0VzMaQ8s+CLOyS56YyCFGeJZ
qgtzJ6GR3eqoYSW9b9UMvkBpZODSctWSNGj3P7jRFDO5VoTwCQA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