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