forked from ddrilling/AsbCloudServer
46 lines
1.8 KiB
C#
46 lines
1.8 KiB
C#
|
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)]
|
|||
|
public IActionResult Get(int wellId, [FromQuery] IEnumerable<int> categoryids = default, DateTime begin = default, DateTime end = default, int skip = 0, int take = 32)
|
|||
|
{
|
|||
|
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);
|
|||
|
}
|
|||
|
}
|
|||
|
}
|