feat:准备添加excel操作
This commit is contained in:
@@ -2,6 +2,9 @@
|
||||
<Import Project="..\..\common.props" />
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.AspNetCore.Mvc.Abstractions" Version="2.2.0" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Mvc.Core" Version="2.2.5" />
|
||||
<PackageReference Include="MiniExcel" Version="1.31.3" />
|
||||
<PackageReference Include="Volo.Abp.Ddd.Application" Version="8.0.0" />
|
||||
</ItemGroup>
|
||||
|
||||
|
||||
@@ -3,11 +3,14 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using MiniExcelLibs;
|
||||
using Volo.Abp;
|
||||
using Volo.Abp.Application.Dtos;
|
||||
using Volo.Abp.Application.Services;
|
||||
using Volo.Abp.Domain.Entities;
|
||||
using Volo.Abp.Domain.Repositories;
|
||||
using Volo.Abp.Validation;
|
||||
|
||||
namespace Yi.Framework.Ddd.Application
|
||||
{
|
||||
@@ -86,7 +89,7 @@ namespace Yi.Framework.Ddd.Application
|
||||
/// <param name="id"></param>
|
||||
/// <returns></returns>
|
||||
[RemoteService(isEnabled: true)]
|
||||
public async Task DeleteAsync(IEnumerable<TKey> id)
|
||||
public virtual async Task DeleteAsync(IEnumerable<TKey> id)
|
||||
{
|
||||
await Repository.DeleteManyAsync(id);
|
||||
}
|
||||
@@ -95,5 +98,34 @@ namespace Yi.Framework.Ddd.Application
|
||||
{
|
||||
return base.DeleteAsync(id);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public virtual async Task<IActionResult> GetExportExcelAsync(TGetListInput input)
|
||||
{
|
||||
if (input is IPagedResultRequest paged)
|
||||
{
|
||||
paged.SkipCount = 0;
|
||||
paged.MaxResultCount = LimitedResultRequestDto.MaxMaxResultCount;
|
||||
}
|
||||
|
||||
var output = await this.GetListAsync(input);
|
||||
var dirPath = $"/wwwroot/temp";
|
||||
var filePath = $"{dirPath}/{Guid.NewGuid()}.xlsx";
|
||||
if (!Directory.Exists(dirPath))
|
||||
{
|
||||
Directory.CreateDirectory(dirPath);
|
||||
}
|
||||
|
||||
MiniExcel.SaveAs(filePath, output.Items);
|
||||
return new FileStreamResult(File.OpenRead(filePath), "application/vnd.ms-excel");
|
||||
}
|
||||
|
||||
public virtual async Task PostImportExcelAsync()
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
using Volo.Abp.Application;
|
||||
using Volo.Abp;
|
||||
using Volo.Abp.Application;
|
||||
using Volo.Abp.Application.Dtos;
|
||||
using Volo.Abp.Modularity;
|
||||
using Yi.Framework.Ddd.Application.Contracts;
|
||||
|
||||
@@ -8,6 +10,11 @@ namespace Yi.Framework.Ddd.Application
|
||||
typeof(YiFrameworkDddApplicationContractsModule))]
|
||||
public class YiFrameworkDddApplicationModule : AbpModule
|
||||
{
|
||||
|
||||
public override void OnApplicationInitialization(ApplicationInitializationContext context)
|
||||
{
|
||||
//分页限制
|
||||
LimitedResultRequestDto.DefaultMaxResultCount = 10;
|
||||
LimitedResultRequestDto.MaxMaxResultCount = 10000;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user