2021-04-23 10:21:25 +05:00
|
|
|
|
using AsbCloudApp.Data;
|
|
|
|
|
using AsbCloudApp.Services;
|
|
|
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
|
|
|
|
namespace AsbCloudWebApi.Controllers
|
|
|
|
|
{
|
|
|
|
|
[Route("api/well")]
|
|
|
|
|
[ApiController]
|
|
|
|
|
public class MessageController : ControllerBase
|
|
|
|
|
{
|
|
|
|
|
private readonly IMessageService messageService;
|
|
|
|
|
|
|
|
|
|
public MessageController(IMessageService messageService)
|
|
|
|
|
{
|
|
|
|
|
this.messageService = messageService;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Выдает список сообщений по скважине
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="wellId">id скважины</param>
|
|
|
|
|
/// <param name="categoryids">список категорий</param>
|
|
|
|
|
/// <param name="begin">дата начала</param>
|
|
|
|
|
/// <param name="end">окончание</param>
|
|
|
|
|
/// <param name="skip">для пагинации кол-во записей пропустить</param>
|
|
|
|
|
/// <param name="take">для пагинации кол-во записей </param>
|
|
|
|
|
/// <returns>список сообщений по скважине</returns>
|
|
|
|
|
[HttpGet]
|
|
|
|
|
[Route("{wellId}/message")]
|
|
|
|
|
[ProducesResponseType(typeof(PaginationContainer<MessageDto>), (int)System.Net.HttpStatusCode.OK)]
|
2021-04-30 17:35:35 +05:00
|
|
|
|
public IActionResult GetMessage(int wellId, int skip = 0, int take = 32, [FromQuery] IEnumerable<int> categoryids = default, DateTime begin = default, DateTime end = default)
|
2021-04-23 10:21:25 +05:00
|
|
|
|
{
|
|
|
|
|
if (take > 1024)
|
|
|
|
|
return BadRequest("limit mast be less then 1024");
|
|
|
|
|
|
|
|
|
|
if (begin > DateTime.Now)
|
|
|
|
|
begin = default;
|
|
|
|
|
|
|
|
|
|
var result = messageService.GetMessages(wellId, categoryids, begin, end, skip, take);
|
|
|
|
|
return Ok(result);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|