forked from ddrilling/AsbCloudServer
Merge branch 'dev' into feature/process_map
This commit is contained in:
commit
a97273eb54
@ -1,3 +1,4 @@
|
||||
using AsbCloudApp.ValidationAttributes;
|
||||
using System;
|
||||
|
||||
namespace AsbCloudApp.Requests;
|
||||
@ -20,10 +21,12 @@ public class ReportParametersRequest
|
||||
/// <summary>
|
||||
/// Дата начала интервала
|
||||
/// </summary>
|
||||
[DateValidation(GtDate ="2000-01-01")]
|
||||
public DateTime Begin { get; set; } = default;
|
||||
|
||||
/// <summary>
|
||||
/// Дата окончания интервала
|
||||
/// </summary>
|
||||
public DateTime End { get; set; } = default;
|
||||
/// <summary>
|
||||
/// Дата окончания интервала
|
||||
/// </summary>
|
||||
[DateValidation(GtDate ="2000-01-01")]
|
||||
public DateTime End { get; set; } = default;
|
||||
}
|
8544
AsbCloudDb/Migrations/20230925081405_Add_New_Permission_For_Manuals.Designer.cs
generated
Normal file
8544
AsbCloudDb/Migrations/20230925081405_Add_New_Permission_For_Manuals.Designer.cs
generated
Normal file
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,35 @@
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace AsbCloudDb.Migrations
|
||||
{
|
||||
public partial class Add_New_Permission_For_Manuals : Migration
|
||||
{
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.InsertData(
|
||||
table: "t_permission",
|
||||
columns: new[] { "id", "description", "name" },
|
||||
values: new object[] { 527, "Разрешение на удаление инструкций", "Manual.delete" });
|
||||
|
||||
migrationBuilder.InsertData(
|
||||
table: "t_relation_user_role_permission",
|
||||
columns: new[] { "id_permission", "id_user_role" },
|
||||
values: new object[] { 527, 1 });
|
||||
}
|
||||
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DeleteData(
|
||||
table: "t_relation_user_role_permission",
|
||||
keyColumns: new[] { "id_permission", "id_user_role" },
|
||||
keyValues: new object[] { 527, 1 });
|
||||
|
||||
migrationBuilder.DeleteData(
|
||||
table: "t_permission",
|
||||
keyColumn: "id",
|
||||
keyValue: 527);
|
||||
}
|
||||
}
|
||||
}
|
@ -2274,6 +2274,12 @@ namespace AsbCloudDb.Migrations
|
||||
Id = 526,
|
||||
Description = "Разрешение на редактирование операций у завершенной скважины",
|
||||
Name = "WellOperation.editCompletedWell"
|
||||
},
|
||||
new
|
||||
{
|
||||
Id = 527,
|
||||
Description = "Разрешение на удаление инструкций",
|
||||
Name = "Manual.delete"
|
||||
});
|
||||
});
|
||||
|
||||
@ -3931,6 +3937,11 @@ namespace AsbCloudDb.Migrations
|
||||
{
|
||||
IdUserRole = 1,
|
||||
IdPermission = 526
|
||||
},
|
||||
new
|
||||
{
|
||||
IdUserRole = 1,
|
||||
IdPermission = 527
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -161,7 +161,9 @@
|
||||
new() { Id = 524, Name = "Manual.get", Description = "Разрешить получение инструкций"},
|
||||
|
||||
new (){ Id = 525, Name = "ProcessMap.editCompletedWell", Description = "Разрешение на редактирование РТК у завершенной скважины"},
|
||||
new (){ Id = 526, Name = "WellOperation.editCompletedWell", Description = "Разрешение на редактирование операций у завершенной скважины"}
|
||||
new (){ Id = 526, Name = "WellOperation.editCompletedWell", Description = "Разрешение на редактирование операций у завершенной скважины"},
|
||||
|
||||
new() { Id = 527, Name = "Manual.delete", Description = "Разрешение на удаление инструкций"}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -40,6 +40,9 @@
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="AsbSaubReport" Version="3.2.1" />
|
||||
<PackageReference Include="AsbSaubReportLas" Version="3.2.1" />
|
||||
<PackageReference Include="AsbSaubReportPdf" Version="3.2.1" />
|
||||
<PackageReference Include="CliWrap" Version="3.6.0" />
|
||||
<PackageReference Include="ClosedXML" Version="0.96.0" />
|
||||
<PackageReference Include="itext7" Version="7.2.3" />
|
||||
@ -59,15 +62,6 @@
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Reference Include="AsbSaubReport">
|
||||
<HintPath>CommonLibs\AsbSaubReport.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="AsbSaubReportLas">
|
||||
<HintPath>CommonLibs\AsbSaubReportLas.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="AsbSaubReportPdf">
|
||||
<HintPath>CommonLibs\AsbSaubReportPdf.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="AsbWitsInfo">
|
||||
<HintPath>CommonLibs\AsbWitsInfo.dll</HintPath>
|
||||
</Reference>
|
||||
|
Binary file not shown.
Binary file not shown.
File diff suppressed because it is too large
Load Diff
Binary file not shown.
@ -1,7 +1,6 @@
|
||||
using AsbCloudApp.Exceptions;
|
||||
using AsbCloudDb.Model;
|
||||
using AsbSaubReport.Model;
|
||||
using iText.Forms.Xfdf;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
@ -168,6 +168,14 @@ namespace AsbCloudInfrastructure.Services
|
||||
//PDF
|
||||
_ => new AsbSaubReportPdf.ReprotGeneratorPdf(dataSource),
|
||||
};
|
||||
|
||||
if(begin == default || end == default)
|
||||
{
|
||||
var analyzeResult = dataSource.Analyze();
|
||||
begin = begin == default ? analyzeResult.MinDate : begin;
|
||||
end = end == default ? begin.AddDays(1) : end;
|
||||
}
|
||||
|
||||
generator.Begin = begin;
|
||||
generator.End = end;
|
||||
generator.Step = TimeSpan.FromSeconds(stepSeconds);
|
||||
|
@ -2,7 +2,6 @@ using System.ComponentModel.DataAnnotations;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using AsbCloudApp.Exceptions;
|
||||
using AsbCloudApp.Repositories;
|
||||
using AsbCloudApp.Services;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
@ -16,13 +15,10 @@ namespace AsbCloudWebApi.Controllers;
|
||||
public class ManualController : ControllerBase
|
||||
{
|
||||
private readonly IManualCatalogService manualCatalogService;
|
||||
private readonly IUserRepository userRepository;
|
||||
|
||||
public ManualController(IManualCatalogService manualCatalogService,
|
||||
IUserRepository userRepository)
|
||||
public ManualController(IManualCatalogService manualCatalogService)
|
||||
{
|
||||
this.manualCatalogService = manualCatalogService;
|
||||
this.userRepository = userRepository;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -46,8 +42,6 @@ public class ManualController : ControllerBase
|
||||
if(!idUser.HasValue)
|
||||
throw new ForbidException("Не удается вас опознать");
|
||||
|
||||
AssertUserHasAccessToManual("Manual.edit");
|
||||
|
||||
using var fileStream = file.OpenReadStream();
|
||||
|
||||
var id = await manualCatalogService.SaveFileAsync(idDirectory, idUser.Value, file.FileName, fileStream, cancellationToken);
|
||||
@ -68,8 +62,6 @@ public class ManualController : ControllerBase
|
||||
[ProducesResponseType(StatusCodes.Status403Forbidden)]
|
||||
public async Task<IActionResult> GetFileAsync(int id, CancellationToken cancellationToken)
|
||||
{
|
||||
AssertUserHasAccessToManual("Manual.get");
|
||||
|
||||
var file = await manualCatalogService.GetFileAsync(id, cancellationToken);
|
||||
|
||||
if (!file.HasValue)
|
||||
@ -90,16 +82,6 @@ public class ManualController : ControllerBase
|
||||
[ProducesResponseType(StatusCodes.Status403Forbidden)]
|
||||
public async Task<IActionResult> DeleteFileAsync(int id, CancellationToken cancellationToken)
|
||||
{
|
||||
AssertUserHasAccessToManual("Manual.edit");
|
||||
|
||||
return Ok(await manualCatalogService.DeleteFileAsync(id, cancellationToken));
|
||||
}
|
||||
|
||||
private void AssertUserHasAccessToManual(string permissionName)
|
||||
{
|
||||
var idUser = User.GetUserId();
|
||||
|
||||
if (!idUser.HasValue || !userRepository.HasPermission(idUser.Value, permissionName))
|
||||
throw new ForbidException("У вас недостаточно прав");
|
||||
}
|
||||
}
|
@ -2,7 +2,6 @@ using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using AsbCloudApp.Data.Manuals;
|
||||
using AsbCloudApp.Exceptions;
|
||||
using AsbCloudApp.Repositories;
|
||||
using AsbCloudApp.Services;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
@ -17,15 +16,12 @@ public class ManualDirectoryController : ControllerBase
|
||||
{
|
||||
private readonly IManualDirectoryRepository manualDirectoryRepository;
|
||||
private readonly IManualCatalogService manualCatalogService;
|
||||
private readonly IUserRepository userRepository;
|
||||
|
||||
public ManualDirectoryController(IManualDirectoryRepository manualDirectoryRepository,
|
||||
IManualCatalogService manualCatalogService,
|
||||
IUserRepository userRepository)
|
||||
IManualCatalogService manualCatalogService)
|
||||
{
|
||||
this.manualDirectoryRepository = manualDirectoryRepository;
|
||||
this.manualCatalogService = manualCatalogService;
|
||||
this.userRepository = userRepository;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -36,14 +32,12 @@ public class ManualDirectoryController : ControllerBase
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
[Permission]
|
||||
[Permission("Manual.edit")]
|
||||
[ProducesResponseType(typeof(int), StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||
[ProducesResponseType(StatusCodes.Status403Forbidden)]
|
||||
public async Task<IActionResult> AddDirectoryAsync(string name, int? idParent, CancellationToken cancellationToken)
|
||||
{
|
||||
AssertUserHasAccessToManualDirectory("Manual.edit");
|
||||
|
||||
return Ok(await manualCatalogService.AddDirectoryAsync(name, idParent, cancellationToken));
|
||||
}
|
||||
|
||||
@ -55,13 +49,11 @@ public class ManualDirectoryController : ControllerBase
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPut]
|
||||
[Permission]
|
||||
[Permission("Manual.edit")]
|
||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||
[ProducesResponseType(StatusCodes.Status403Forbidden)]
|
||||
public async Task<IActionResult> UpdateDirectoryAsync(int id, string name, CancellationToken cancellationToken)
|
||||
{
|
||||
AssertUserHasAccessToManualDirectory("Manual.edit");
|
||||
|
||||
await manualCatalogService.UpdateDirectoryAsync(id, name, cancellationToken);
|
||||
|
||||
return Ok();
|
||||
@ -74,13 +66,11 @@ public class ManualDirectoryController : ControllerBase
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns></returns>
|
||||
[HttpDelete]
|
||||
[Permission]
|
||||
[Permission("Manual.delete")]
|
||||
[ProducesResponseType(typeof(int), StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(StatusCodes.Status403Forbidden)]
|
||||
public async Task<IActionResult> DeleteDirectoryAsync(int id, CancellationToken cancellationToken)
|
||||
{
|
||||
AssertUserHasAccessToManualDirectory("Manual.edit");
|
||||
|
||||
return Ok(await manualCatalogService.DeleteDirectoryAsync(id, cancellationToken));
|
||||
}
|
||||
|
||||
@ -90,21 +80,11 @@ public class ManualDirectoryController : ControllerBase
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet]
|
||||
[Permission]
|
||||
[Permission("Manual.get")]
|
||||
[ProducesResponseType(typeof(IEnumerable<ManualDirectoryDto>), StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(StatusCodes.Status403Forbidden)]
|
||||
public async Task<IActionResult> GetAsync(CancellationToken cancellationToken)
|
||||
{
|
||||
AssertUserHasAccessToManualDirectory("Manual.get");
|
||||
|
||||
return Ok(await manualDirectoryRepository.GetTreeAsync(cancellationToken));
|
||||
}
|
||||
|
||||
private void AssertUserHasAccessToManualDirectory(string permissionName)
|
||||
{
|
||||
var idUser = User.GetUserId();
|
||||
|
||||
if (!idUser.HasValue || !userRepository.HasPermission(idUser.Value, permissionName))
|
||||
throw new ForbidException("У вас недостаточно прав");
|
||||
}
|
||||
}
|
@ -1 +1 @@
|
||||
<!doctype html><html lang="ru"><head><meta charset="utf-8"/><link rel="icon" href="/favicon.ico"/><meta name="viewport" content="width=device-width,initial-scale=1"/><meta name="theme-color" content="white"/><meta name="theme-color" media="(prefers-color-scheme: light)" content="white"/><meta name="theme-color" media="(prefers-color-scheme: dark)" content="black"/><meta name="description" content="Онлайн мониторинг процесса бурения в реальном времени в офисе заказчика"/><title>DDrilling</title><script defer="defer" src="/runtime~main.af5f343a.js"></script><script defer="defer" src="/vendors.a8e3bd9c.js"></script><script defer="defer" src="/main.8a0ba951.js"></script></head><body><noscript>You need to enable JavaScript to run this app.</noscript><div id="root"></div></body></html>
|
||||
<!doctype html><html lang="ru"><head><meta charset="utf-8"/><link rel="icon" href="/favicon.ico"/><meta name="viewport" content="width=device-width,initial-scale=1"/><meta name="theme-color" content="white"/><meta name="theme-color" media="(prefers-color-scheme: light)" content="white"/><meta name="theme-color" media="(prefers-color-scheme: dark)" content="black"/><meta name="description" content="Онлайн мониторинг процесса бурения в реальном времени в офисе заказчика"/><title>DDrill</title><script defer="defer" src="/runtime~main.5f05be65.js"></script><script defer="defer" src="/vendors.408d069b.js"></script><script defer="defer" src="/main.c3c166db.js"></script></head><body><noscript>You need to enable JavaScript to run this app.</noscript><div id="root"></div></body></html>
|
Loading…
Reference in New Issue
Block a user