forked from ddrilling/AsbCloudServer
CS2-58 FileController Add filter by filename
This commit is contained in:
parent
e8bfe3b443
commit
b3b1230c0a
@ -14,7 +14,7 @@ namespace AsbCloudApp.Services
|
|||||||
Task<FileInfoDto> SaveAsync(int idWell, int idUser, int idCategory, string fileFullName, Stream fileStream, CancellationToken token = default);
|
Task<FileInfoDto> SaveAsync(int idWell, int idUser, int idCategory, string fileFullName, Stream fileStream, CancellationToken token = default);
|
||||||
|
|
||||||
Task<PaginationContainer<FileInfoDto>> GetInfosAsync(int idWell,
|
Task<PaginationContainer<FileInfoDto>> GetInfosAsync(int idWell,
|
||||||
int idCategory, IEnumerable<int> companies, DateTime begin, DateTime end,
|
int idCategory, IEnumerable<int> companies, string fileName, DateTime begin, DateTime end,
|
||||||
int skip, int take, CancellationToken token = default);
|
int skip, int take, CancellationToken token = default);
|
||||||
|
|
||||||
Task<FileInfoDto> GetInfoAsync(int fileId,
|
Task<FileInfoDto> GetInfoAsync(int fileId,
|
||||||
|
@ -73,7 +73,7 @@ namespace AsbCloudInfrastructure.Services
|
|||||||
}
|
}
|
||||||
|
|
||||||
public async Task<PaginationContainer<FileInfoDto>> GetInfosAsync(int idWell,
|
public async Task<PaginationContainer<FileInfoDto>> GetInfosAsync(int idWell,
|
||||||
int idCategory, IEnumerable<int> companies = default, DateTime begin = default,
|
int idCategory, IEnumerable<int> companies = default, string fileName = default, DateTime begin = default,
|
||||||
DateTime end = default, int skip = 0, int take = 32, CancellationToken token = default)
|
DateTime end = default, int skip = 0, int take = 32, CancellationToken token = default)
|
||||||
{
|
{
|
||||||
var query = db.Files
|
var query = db.Files
|
||||||
@ -87,6 +87,9 @@ namespace AsbCloudInfrastructure.Services
|
|||||||
query.Include(file => file.Author).ThenInclude(a => a.Company)
|
query.Include(file => file.Author).ThenInclude(a => a.Company)
|
||||||
.Where(e => companies.Contains(e.Author.Company.Id));
|
.Where(e => companies.Contains(e.Author.Company.Id));
|
||||||
|
|
||||||
|
if (!string.IsNullOrEmpty(fileName))
|
||||||
|
query = query.Where(e => e.Name.Contains(fileName, StringComparison.OrdinalIgnoreCase));
|
||||||
|
|
||||||
if (begin != default)
|
if (begin != default)
|
||||||
query = query.Where(e => e.UploadDate >= begin);
|
query = query.Where(e => e.UploadDate >= begin);
|
||||||
|
|
||||||
|
@ -104,10 +104,16 @@ namespace AsbCloudWebApi.Controllers
|
|||||||
/// <returns>Список информации о файлах в этой категории</returns>
|
/// <returns>Список информации о файлах в этой категории</returns>
|
||||||
[HttpGet]
|
[HttpGet]
|
||||||
[ProducesResponseType(typeof(PaginationContainer<FileInfoDto>), (int)System.Net.HttpStatusCode.OK)]
|
[ProducesResponseType(typeof(PaginationContainer<FileInfoDto>), (int)System.Net.HttpStatusCode.OK)]
|
||||||
public async Task<IActionResult> GetFilesInfoAsync([FromRoute] int idWell,
|
public async Task<IActionResult> GetFilesInfoAsync(
|
||||||
int skip = 0, int take = 32, int idCategory = default,
|
[FromRoute] int idWell,
|
||||||
DateTime begin = default, DateTime end = default,
|
int idCategory = default,
|
||||||
CancellationToken token = default, [FromQuery] IEnumerable<int> companies = default)
|
[FromQuery] IEnumerable<int> companies = default,
|
||||||
|
string fileName = default,
|
||||||
|
DateTime begin = default,
|
||||||
|
DateTime end = default,
|
||||||
|
int skip = 0,
|
||||||
|
int take = 32,
|
||||||
|
CancellationToken token = default)
|
||||||
{
|
{
|
||||||
int? idCompany = User.GetCompanyId();
|
int? idCompany = User.GetCompanyId();
|
||||||
|
|
||||||
@ -116,7 +122,7 @@ namespace AsbCloudWebApi.Controllers
|
|||||||
return Forbid();
|
return Forbid();
|
||||||
|
|
||||||
var filesInfo = await fileService.GetInfosAsync(idWell, idCategory,
|
var filesInfo = await fileService.GetInfosAsync(idWell, idCategory,
|
||||||
companies, begin, end, skip, take, token).ConfigureAwait(false);
|
companies, fileName, begin, end, skip, take, token).ConfigureAwait(false);
|
||||||
|
|
||||||
if (filesInfo is null || !filesInfo.Items.Any())
|
if (filesInfo is null || !filesInfo.Items.Any())
|
||||||
return NoContent();
|
return NoContent();
|
||||||
|
Loading…
Reference in New Issue
Block a user