forked from ddrilling/AsbCloudServer
Merge branch 'dev' into feature/import_and_export_process_map
This commit is contained in:
commit
a08b7e5a81
@ -1,4 +1,5 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace AsbCloudApp.Data
|
||||
{
|
||||
@ -13,16 +14,7 @@ namespace AsbCloudApp.Data
|
||||
/// </summary>
|
||||
public PaginationContainer()
|
||||
{
|
||||
Items = new List<T>(4);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// конструктор
|
||||
/// </summary>
|
||||
/// <param name="capacity"></param>
|
||||
public PaginationContainer(int capacity)
|
||||
{
|
||||
Items = new List<T>(capacity);
|
||||
Items = Enumerable.Empty<T>();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -43,6 +35,6 @@ namespace AsbCloudApp.Data
|
||||
/// <summary>
|
||||
/// Данные
|
||||
/// </summary>
|
||||
public List<T> Items { get; set; }
|
||||
public IEnumerable<T> Items { get; set; }
|
||||
}
|
||||
}
|
||||
|
@ -13,11 +13,22 @@ public interface IHelpPageRepository : ICrudRepository<HelpPageDto>
|
||||
/// <summary>
|
||||
/// Получение справки по url страницы и id категории
|
||||
/// </summary>
|
||||
/// <param name="urlPage"></param>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="idCategory"></param>
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns></returns>
|
||||
Task<HelpPageDto?> GetOrDefaultByUrlPageAndIdCategoryAsync(string urlPage,
|
||||
Task<HelpPageDto?> GetOrDefaultByUrlPageAndIdCategoryAsync(string key,
|
||||
int idCategory,
|
||||
CancellationToken cancellationToken);
|
||||
|
||||
/// <summary>
|
||||
/// Проверяет наличие справки для страницы
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="idCategory"></param>
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns></returns>
|
||||
Task<bool> IsExistingAsync(string key,
|
||||
int idCategory,
|
||||
CancellationToken cancellationToken);
|
||||
}
|
||||
|
@ -111,7 +111,7 @@ namespace AsbCloudInfrastructure.Repository
|
||||
.ToListAsync(token)
|
||||
.ConfigureAwait(false);
|
||||
|
||||
result.Items = entities.Select(e => Convert(e)).ToList();
|
||||
result.Items = entities.Select(e => Convert(e));
|
||||
|
||||
return result;
|
||||
}
|
||||
|
@ -16,13 +16,13 @@ public class HelpPageRepository : CrudRepositoryBase<HelpPageDto, HelpPage>,
|
||||
{
|
||||
}
|
||||
|
||||
public async Task<HelpPageDto?> GetOrDefaultByUrlPageAndIdCategoryAsync(string urlPage,
|
||||
public async Task<HelpPageDto?> GetOrDefaultByUrlPageAndIdCategoryAsync(string key,
|
||||
int idCategory,
|
||||
CancellationToken cancellationToken)
|
||||
{
|
||||
var helpPage = await dbSet.AsNoTracking()
|
||||
.SingleOrDefaultAsync(x =>
|
||||
x.UrlPage == urlPage &&
|
||||
x.UrlPage == key &&
|
||||
x.IdCategory == idCategory,
|
||||
cancellationToken);
|
||||
|
||||
@ -31,4 +31,9 @@ public class HelpPageRepository : CrudRepositoryBase<HelpPageDto, HelpPage>,
|
||||
|
||||
return helpPage.Adapt<HelpPageDto>();
|
||||
}
|
||||
|
||||
public Task<bool> IsExistingAsync(string key, int idCategory, CancellationToken cancellationToken) =>
|
||||
dbContext.HelpPages.AnyAsync(h => h.UrlPage == key &&
|
||||
h.IdCategory == idCategory,
|
||||
cancellationToken);
|
||||
}
|
||||
|
@ -70,14 +70,14 @@ public class NotificationRepository : CrudCacheRepositoryBase<NotificationDto, N
|
||||
|
||||
if (result.Count < skip)
|
||||
return result;
|
||||
|
||||
|
||||
result.Items = await query
|
||||
.SortBy(request.SortFields)
|
||||
.Skip(skip)
|
||||
.Take(take)
|
||||
.AsNoTracking()
|
||||
.Select(x => x.Adapt<NotificationDto>())
|
||||
.ToListAsync(cancellationToken);
|
||||
.ToArrayAsync(cancellationToken);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
@ -165,7 +165,7 @@ namespace AsbCloudInfrastructure.Repository
|
||||
.Skip(result.Skip)
|
||||
.Take(result.Take);
|
||||
|
||||
result.Items = await query.ToListAsync(token);
|
||||
result.Items = await query.ToArrayAsync(token);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -101,6 +101,8 @@ namespace AsbCloudInfrastructure.Services.SAUB
|
||||
var eventsDict = events.ToDictionary(x=>x.IdEvent, x => x);
|
||||
var usersDict = users.ToDictionary(x => x.IdUser, x => x);
|
||||
|
||||
var messagesDtoList = new List<MessageDto>();
|
||||
|
||||
foreach (var message in messagesList)
|
||||
{
|
||||
var messageDto = new MessageDto
|
||||
@ -126,10 +128,11 @@ namespace AsbCloudInfrastructure.Services.SAUB
|
||||
messageDto.CategoryId = e.IdCategory;
|
||||
messageDto.Message = e.MakeMessageText(message);
|
||||
}
|
||||
|
||||
result.Items.Add(messageDto);
|
||||
messagesDtoList.Add(messageDto);
|
||||
}
|
||||
|
||||
result.Items = result.Items.Concat(messagesDtoList);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -21,18 +21,21 @@ public class HelpPageController : ControllerBase
|
||||
{
|
||||
private readonly IHelpPageService helpPageService;
|
||||
private readonly IUserRepository userRepository;
|
||||
private readonly IHelpPageRepository helpPageRepository;
|
||||
|
||||
public HelpPageController(IHelpPageService helpPageService,
|
||||
IUserRepository userRepository)
|
||||
IUserRepository userRepository,
|
||||
IHelpPageRepository helpPageRepository)
|
||||
{
|
||||
this.helpPageService = helpPageService;
|
||||
this.userRepository = userRepository;
|
||||
this.helpPageRepository = helpPageRepository;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Загрузка файла справки
|
||||
/// </summary>
|
||||
/// <param name="urlPage">Url страницы</param>
|
||||
/// <param name="key">Ключ страницы</param>
|
||||
/// <param name="idCategory">Id категории файла. Допустимое значение параметра: 20000</param>
|
||||
/// <param name="file">Файл справки</param>
|
||||
/// <param name="cancellationToken">Токен для отмены задачи</param>
|
||||
@ -41,7 +44,7 @@ public class HelpPageController : ControllerBase
|
||||
[Permission]
|
||||
[ProducesResponseType(typeof(int), (int)HttpStatusCode.OK)]
|
||||
public async Task<IActionResult> UploadAsync(
|
||||
string urlPage,
|
||||
[Required] string key,
|
||||
[Range(minimum: 20000, maximum: 20000, ErrorMessage = "Категория файла недопустима. Допустимые: 20000")]
|
||||
int idCategory,
|
||||
[Required] IFormFile file,
|
||||
@ -57,7 +60,7 @@ public class HelpPageController : ControllerBase
|
||||
|
||||
using var fileStream = file.OpenReadStream();
|
||||
|
||||
int helpPageId = await helpPageService.AddOrUpdateAsync(urlPage,
|
||||
int helpPageId = await helpPageService.AddOrUpdateAsync(key,
|
||||
idCategory,
|
||||
file.FileName,
|
||||
fileStream,
|
||||
@ -69,19 +72,20 @@ public class HelpPageController : ControllerBase
|
||||
/// <summary>
|
||||
/// Получение файла справки
|
||||
/// </summary>
|
||||
/// <param name="urlPage">Url страницы</param>
|
||||
/// <param name="key">Ключ страницы</param>
|
||||
/// <param name="idCategory">Id категории файла. Допустимое значение параметра: 20000</param>
|
||||
/// <param name="cancellationToken">Токен для отмены задачи</param>
|
||||
/// <returns></returns>
|
||||
[HttpGet]
|
||||
[Route("{urlPage}/{idCategory}")]
|
||||
[ProducesResponseType(typeof(PhysicalFileResult), (int)HttpStatusCode.OK)]
|
||||
[ProducesResponseType(StatusCodes.Status204NoContent)]
|
||||
public async Task<IActionResult> GetFileAsync(string urlPage,
|
||||
int idCategory,
|
||||
public async Task<IActionResult> GetFileAsync(
|
||||
[Required] string key,
|
||||
[Range(minimum: 20000, maximum: 20000, ErrorMessage = "Категория файла недопустима. Допустимые: 20000")]
|
||||
int idCategory,
|
||||
CancellationToken cancellationToken)
|
||||
{
|
||||
var file = await helpPageService.GetFileStreamAsync(urlPage,
|
||||
var file = await helpPageService.GetFileStreamAsync(key,
|
||||
idCategory,
|
||||
cancellationToken);
|
||||
|
||||
@ -94,4 +98,27 @@ public class HelpPageController : ControllerBase
|
||||
|
||||
return File(memoryStream, "application/pdf", file.fileName);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Проверяет наличие справки для страницы
|
||||
/// </summary>
|
||||
/// <param name="key">Ключ страницы</param>
|
||||
/// <param name="idCategory">Id категории файла. Допустимое значение параметра: 20000</param>
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet]
|
||||
[Route("isExisting")]
|
||||
[ProducesResponseType(typeof(bool), (int)HttpStatusCode.OK)]
|
||||
public async Task<IActionResult> IsExistingAsync(
|
||||
[Required] string key,
|
||||
[Range(minimum: 20000, maximum: 20000, ErrorMessage = "Категория файла недопустима. Допустимые: 20000")]
|
||||
int idCategory,
|
||||
CancellationToken cancellationToken)
|
||||
{
|
||||
var helpPage = await helpPageRepository.GetOrDefaultByUrlPageAndIdCategoryAsync(key,
|
||||
idCategory,
|
||||
cancellationToken);
|
||||
|
||||
return Ok(helpPage != null);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user