添加excel模块

This commit is contained in:
橙子
2023-01-16 23:05:01 +08:00
parent 46b176fc59
commit 034abb06ad
159 changed files with 328 additions and 97 deletions

View File

@@ -0,0 +1,18 @@
<?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="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,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 StudentGetListOutputDto : 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;
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,16 @@
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 long Id { get; set; }
public string? Name { get; set; }
public long? Number { 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,21 @@
<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>
<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,22 @@
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;
namespace Yi.Framework.Application.Contracts
{
public class YiFrameworkApplicationContractsModule : IStartupModule
{
public void Configure(IApplicationBuilder app, ConfigureMiddlewareContext context)
{
}
public void ConfigureServices(IServiceCollection services, ConfigureServicesContext context)
{
}
}
}

View File

@@ -0,0 +1,19 @@
<?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.PostShijie">
<summary>
你好世界
</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,43 @@
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 Yi.Framework.Domain.Student.IRepository;
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;
namespace Yi.Framework.Application.Student
{
/// <summary>
/// 服务实现
/// </summary>
public class StudentService : CrudAppService<StudentEntity, StudentGetOutputDto, StudentGetListOutputDto, long, StudentGetListInputVo, StudentCreateInputVo, StudentUpdateInputVo>,
IStudentService, IAutoApiService
{
private readonly IStudentRepository _studentRepository;
private readonly StudentManager _studentManager;
public StudentService(IStudentRepository studentRepository, StudentManager studentManager)
{
_studentRepository = studentRepository;
_studentManager = studentManager;
}
/// <summary>
/// 你好世界
/// </summary>
/// <returns></returns>
public async Task<List<StudentGetListOutputDto>> PostShijie()
{
throw new NotImplementedException();
var entities = await _studentRepository.GetMyListAsync();
return await MapToGetListOutputDtosAsync(entities);
}
}
}

View File

@@ -0,0 +1,16 @@
<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>
<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,26 @@
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.Student;
using Yi.Framework.Application.Student;
namespace Yi.Framework.Application
{
public class YiFrameworkApplicationModule : IStartupModule
{
public void Configure(IApplicationBuilder app, ConfigureMiddlewareContext context)
{
}
public void ConfigureServices(IServiceCollection services, ConfigureServicesContext context)
{
services.AddTransient<IStudentService, StudentService>();
}
}
}

View File

@@ -0,0 +1,16 @@
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,13 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\..\src\framework\Yi.Framework.Ddd\Yi.Framework.Ddd.csproj" />
</ItemGroup>
</Project>

View File

@@ -0,0 +1,22 @@
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;
namespace Yi.Framework.Domain.Shared
{
public class YiFrameworkDomainSharedModule : IStartupModule
{
public void Configure(IApplicationBuilder app, ConfigureMiddlewareContext context)
{
}
public void ConfigureServices(IServiceCollection services, ConfigureServicesContext context)
{
}
}
}

View File

@@ -0,0 +1,33 @@
<?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="T:Yi.Framework.Domain.Student.IRepository.IStudentRepository">
<summary>
仓储抽象
</summary>
</member>
<member name="T:Yi.Framework.Domain.Student.StudentManager">
<summary>
领域服务
</summary>
</member>
</members>
</doc>

View File

@@ -0,0 +1,30 @@
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Yi.Framework.Ddd.Entities;
namespace Yi.Framework.Domain.Student.Entities
{
/// <summary>
/// 学生实体
/// </summary>
[SugarTable("Student")]
public class StudentEntity : IEntity<long>
{
[SugarColumn(IsPrimaryKey = true)]
public long Id { get; set; }
/// <summary>
/// 学生名称
/// </summary>
public string Name { get; set; } = string.Empty;
/// <summary>
/// 学号
/// </summary>
public long Number { 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.IRepository
{
/// <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.IRepository;
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,21 @@
<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>
<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,24 @@
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.Domain.Student;
namespace Yi.Framework.Domain
{
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.IRepository;
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,14 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<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,25 @@
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.Domain.Student.IRepository;
using Yi.Framework.Sqlsugar.Student;
namespace Yi.Framework.Sqlsugar
{
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,54 @@
using Yi.Framework.Application;
using Yi.Framework.Application.Contracts;
using Yi.Framework.Core;
using Yi.Framework.Core.Autofac.Extensions;
using Yi.Framework.Core.Autofac.Modules;
using Yi.Framework.Core.AutoMapper;
using Yi.Framework.Core.Extensions;
using Yi.Framework.Core.Sqlsugar;
using Yi.Framework.Ddd;
using Yi.Framework.Domain;
using Yi.Framework.Domain.Shared;
using Yi.Framework.Sqlsugar;
using Yi.Framework.Web;
TimeTest.Start();
var builder = WebApplication.CreateBuilder(args);
builder.WebHost.UseUrls(builder.Configuration.GetValue<string>("StartUrl"));
//<2F><><EFBFBD><EFBFBD>ģ<EFBFBD><C4A3>
builder.UseYiModules(
typeof(YiFrameworkCoreModule).Assembly,
typeof(YiFrameworkCoreAutoMapperModule).Assembly,
typeof(YiFrameworkDddModule).Assembly,
typeof(YiFrameworkCoreSqlsugarModule).Assembly,
typeof(YiFrameworkSqlsugarModule).Assembly,
typeof(YiFrameworkDomainSharedModule).Assembly,
typeof(YiFrameworkDomainModule).Assembly,
typeof(YiFrameworkApplicationContractsModule).Assembly,
typeof(YiFrameworkApplicationModule).Assembly,
typeof(YiFrameworkWebModule).Assembly
);
//<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>();
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,11 @@
using Yi.Framework.Core.Attributes;
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,9 @@
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毫秒

View File

@@ -0,0 +1,15 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>
<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>
</Project>

View File

@@ -0,0 +1,41 @@
using AspNetCore.Microsoft.AspNetCore.Builder;
using StartupModules;
using Yi.Framework.Application;
namespace Yi.Framework.Web
{
/// <summary>
/// 这里是最后执行的模块
/// </summary>
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,29 @@
{
"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
]
}
}