This commit is contained in:
ngfrolov 2022-04-14 13:46:51 +05:00
parent b6b5039d97
commit 5359beb9aa
7 changed files with 57 additions and 43 deletions

View File

@ -2,6 +2,7 @@
<PropertyGroup> <PropertyGroup>
<TargetFramework>net6.0</TargetFramework> <TargetFramework>net6.0</TargetFramework>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
</PropertyGroup> </PropertyGroup>
</Project> </Project>

View File

@ -1,8 +1,18 @@
namespace AsbCloudApp.Data namespace AsbCloudApp.Data
{ {
/// <summary>
/// DTO для авторизации
/// </summary>
public class AuthDto public class AuthDto
{ {
/// <summary>
/// Имя пользователя для входа
/// </summary>
public string Login { get; set; } public string Login { get; set; }
/// <summary>
/// Пароль пользователя для входа
/// </summary>
public string Password { get; set; } public string Password { get; set; }
} }
} }

View File

@ -7,24 +7,6 @@
<UserSecretsId>80899ceb-210f-4f19-ac56-aa90a5d666d4</UserSecretsId> <UserSecretsId>80899ceb-210f-4f19-ac56-aa90a5d666d4</UserSecretsId>
</PropertyGroup> </PropertyGroup>
<ItemGroup>
<Compile Remove="wwwroot\admin\**" />
<Content Remove="wwwroot\admin\**" />
<EmbeddedResource Remove="wwwroot\admin\**" />
<None Remove="wwwroot\admin\**" />
</ItemGroup>
<ItemGroup>
<None Remove="AsbCloudWebApi.service" />
<None Remove="NetRest.service" />
</ItemGroup>
<ItemGroup>
<Content Include="AsbCloudWebApi.service">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="6.0.1" /> <PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="6.0.1" />
<PackageReference Include="Microsoft.AspNetCore.SpaServices.Extensions" Version="6.0.1" /> <PackageReference Include="Microsoft.AspNetCore.SpaServices.Extensions" Version="6.0.1" />
@ -40,24 +22,11 @@
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Content Update="wwwroot\asset-manifest.json"> <Content Update="wwwroot\**">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Update="wwwroot\favicon.ico">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Update="wwwroot\index.html">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Update="wwwroot\manifest.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Update="wwwroot\robots.txt">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content> </Content>
<Content Include="AsbCloudWebApi.service">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup> </ItemGroup>
<ProjectExtensions><VisualStudio><UserProperties appsettings_1json__JsonSchema="" /></VisualStudio></ProjectExtensions>
</Project> </Project>

View File

@ -67,8 +67,7 @@ namespace AsbCloudWebApi.Controllers
/// <returns>id</returns> /// <returns>id</returns>
[HttpPost] [HttpPost]
[Permission] [Permission]
[ProducesResponseType(typeof(int), (int)System.Net.HttpStatusCode.OK)] public virtual async Task<ActionResult<int>> InsertAsync([FromBody] T value, CancellationToken token = default)
public virtual async Task<IActionResult> InsertAsync([FromBody] T value, CancellationToken token = default)
{ {
if (InsertForbidAsync is not null && await InsertForbidAsync(value, token)) if (InsertForbidAsync is not null && await InsertForbidAsync(value, token))
Forbid(); Forbid();
@ -86,8 +85,7 @@ namespace AsbCloudWebApi.Controllers
/// <returns>1 - успешно отредактировано, 0 - нет</returns> /// <returns>1 - успешно отредактировано, 0 - нет</returns>
[HttpPut("{id}")] [HttpPut("{id}")]
[Permission] [Permission]
[ProducesResponseType(typeof(int), (int)System.Net.HttpStatusCode.OK)] public virtual async Task<ActionResult<int>> UpdateAsync(int id, [FromBody] T value, CancellationToken token = default)
public virtual async Task<IActionResult> UpdateAsync(int id, [FromBody] T value, CancellationToken token = default)
{ {
if (UpdateForbidAsync is not null && await UpdateForbidAsync(id, value, token)) if (UpdateForbidAsync is not null && await UpdateForbidAsync(id, value, token))
Forbid(); Forbid();
@ -105,8 +103,7 @@ namespace AsbCloudWebApi.Controllers
/// <param name="token"></param> /// <param name="token"></param>
/// <returns>1 - успешно удалено, 0 - нет</returns> /// <returns>1 - успешно удалено, 0 - нет</returns>
[HttpDelete("{id}")] [HttpDelete("{id}")]
[ProducesResponseType(typeof(int), (int)System.Net.HttpStatusCode.OK)] public virtual async Task<ActionResult<int>> DeleteAsync(int id, CancellationToken token = default)
public virtual async Task<IActionResult> DeleteAsync(int id, CancellationToken token = default)
{ {
if (DeleteForbidAsync is not null && await DeleteForbidAsync(id, token)) if (DeleteForbidAsync is not null && await DeleteForbidAsync(id, token))
Forbid(); Forbid();

View File

@ -31,6 +31,16 @@ namespace AsbCloudWebApi.Controllers.WITS
this.telemetryHubContext = telemetryHubContext; this.telemetryHubContext = telemetryHubContext;
} }
/// <summary>
/// Метод для получения WITS записи от панели оператора.
/// Созраняет в БД.
/// Ретранслирует заинтересованным через SignalR.
/// </summary>
/// <param name="uid">уникальный идентификатор телеметрии</param>
/// <param name="dtos">WITS запись</param>
/// <param name="witsRecordRepository"></param>
/// <param name="token"></param>
/// <returns></returns>
[HttpPost("{uid}")] [HttpPost("{uid}")]
[AllowAnonymous] [AllowAnonymous]
public async virtual Task<IActionResult> PostDataAsync( public async virtual Task<IActionResult> PostDataAsync(
@ -49,9 +59,17 @@ namespace AsbCloudWebApi.Controllers.WITS
return Ok(); return Ok();
} }
/// <summary>
/// Получение списка архивных WITS записей за период.
/// </summary>
/// <param name="idWell">id скважины</param>
/// <param name="begin">начало диапазона</param>
/// <param name="end">конец диапазона</param>
/// <param name="witsRecordRepository"></param>
/// <param name="token"></param>
/// <returns></returns>
[HttpGet("{idWell}")] [HttpGet("{idWell}")]
[ProducesResponseType(StatusCodes.Status200OK, Type = typeof(IEnumerable<RecordBaseDto>))] public async virtual Task<ActionResult<IEnumerable<TDto>>> GetDataAsync(
public async virtual Task<IActionResult> GetDataAsync(
int idWell, int idWell,
DateTime begin, DateTime begin,
DateTime end, DateTime end,
@ -65,6 +83,14 @@ namespace AsbCloudWebApi.Controllers.WITS
return Ok(dtos); return Ok(dtos);
} }
/// <summary>
/// Получение статистики по WITS записи.
/// Диапазон дат и общее количество записей.
/// </summary>
/// <param name="idWell">id скважины</param>
/// <param name="witsRecordRepository"></param>
/// <param name="token"></param>
/// <returns></returns>
[HttpGet("{idWell}/datesRange")] [HttpGet("{idWell}/datesRange")]
[ProducesResponseType(StatusCodes.Status200OK, Type = typeof((DateTime begin, DateTime end, int count)?))] [ProducesResponseType(StatusCodes.Status200OK, Type = typeof((DateTime begin, DateTime end, int count)?))]
public async virtual Task<IActionResult> GetDatesRangeAsync( public async virtual Task<IActionResult> GetDatesRangeAsync(

View File

@ -1,5 +1,7 @@
using AsbCloudInfrastructure.Services; using AsbCloudInfrastructure.Services;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using System.Collections.Generic;
namespace AsbCloudWebApi.Controllers.WITS namespace AsbCloudWebApi.Controllers.WITS
{ {
@ -14,7 +16,12 @@ namespace AsbCloudWebApi.Controllers.WITS
this.witsInfoService = witsInfoService; this.witsInfoService = witsInfoService;
} }
/// <summary>
/// Список всех WITS items для всех известных records
/// </summary>
/// <returns></returns>
[HttpGet("item")] [HttpGet("item")]
[ProducesResponseType(typeof(IEnumerable<object>), (int)System.Net.HttpStatusCode.OK)]
public IActionResult GetItems() public IActionResult GetItems()
{ {
var result = witsInfoService.GetItems(); var result = witsInfoService.GetItems();
@ -22,6 +29,7 @@ namespace AsbCloudWebApi.Controllers.WITS
} }
[HttpGet("item/{idRecord}")] [HttpGet("item/{idRecord}")]
[ProducesResponseType(typeof(IEnumerable<object>), (int)System.Net.HttpStatusCode.OK)]
public IActionResult GetItems(int idRecord) public IActionResult GetItems(int idRecord)
{ {
var result = witsInfoService.GetItems(idRecord); var result = witsInfoService.GetItems(idRecord);
@ -29,6 +37,7 @@ namespace AsbCloudWebApi.Controllers.WITS
} }
[HttpGet("record")] [HttpGet("record")]
[ProducesResponseType(typeof(IEnumerable<object>), (int)System.Net.HttpStatusCode.OK)]
public IActionResult GetRecordInfo() public IActionResult GetRecordInfo()
{ {
var result = witsInfoService.GetRecords(); var result = witsInfoService.GetRecords();
@ -36,6 +45,7 @@ namespace AsbCloudWebApi.Controllers.WITS
} }
[HttpGet("record/{idRecord}")] [HttpGet("record/{idRecord}")]
[ProducesResponseType(typeof(IEnumerable<object>), (int)System.Net.HttpStatusCode.OK)]
public IActionResult GetRecordInfo(int idRecord) public IActionResult GetRecordInfo(int idRecord)
{ {
var result = witsInfoService.GetRecords(idRecord); var result = witsInfoService.GetRecords(idRecord);

View File

@ -54,6 +54,7 @@ namespace AsbCloudWebApi
var xmlFile = $"{Assembly.GetExecutingAssembly().GetName().Name}.xml"; var xmlFile = $"{Assembly.GetExecutingAssembly().GetName().Name}.xml";
var xmlPath = Path.Combine(AppContext.BaseDirectory, xmlFile); var xmlPath = Path.Combine(AppContext.BaseDirectory, xmlFile);
c.IncludeXmlComments(xmlPath); c.IncludeXmlComments(xmlPath);
c.IncludeXmlComments(Path.Combine(AppContext.BaseDirectory, "AsbCloudApp.xml"));
}); });
} }