#5998816 Permission, Controllers

This commit is contained in:
ai.astrakhantsev 2022-09-13 10:06:56 +05:00
parent 44be18f5ed
commit d42a5ee544
7 changed files with 6752 additions and 15 deletions

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,71 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace AsbCloudDb.Migrations
{
public partial class Update_t_permission_well_doument : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.UpdateData(
table: "t_permission",
keyColumn: "id",
keyValue: 503,
column: "name",
value: "WellFinalDocuments.delete");
migrationBuilder.UpdateData(
table: "t_permission",
keyColumn: "id",
keyValue: 504,
column: "name",
value: "WellFinalDocuments.edit");
migrationBuilder.UpdateData(
table: "t_permission",
keyColumn: "id",
keyValue: 505,
column: "name",
value: "WellFinalDocuments.get");
migrationBuilder.UpdateData(
table: "t_permission",
keyColumn: "id",
keyValue: 506,
column: "name",
value: "WellFinalDocuments.editPublisher");
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.UpdateData(
table: "t_permission",
keyColumn: "id",
keyValue: 503,
column: "name",
value: "WellFinalDocument.delete");
migrationBuilder.UpdateData(
table: "t_permission",
keyColumn: "id",
keyValue: 504,
column: "name",
value: "WellFinalDocument.edit");
migrationBuilder.UpdateData(
table: "t_permission",
keyColumn: "id",
keyValue: 505,
column: "name",
value: "WellFinalDocument.get");
migrationBuilder.UpdateData(
table: "t_permission",
keyColumn: "id",
keyValue: 506,
column: "name",
value: "WellFinalDocument.editPublisher");
}
}
}

View File

@ -1890,25 +1890,25 @@ namespace AsbCloudDb.Migrations
{
Id = 503,
Description = "Разрешение удалять Дело скважины",
Name = "WellFinalDocument.delete"
Name = "WellFinalDocuments.delete"
},
new
{
Id = 504,
Description = "Разрешение редактировать Дело скважины",
Name = "WellFinalDocument.edit"
Name = "WellFinalDocuments.edit"
},
new
{
Id = 505,
Description = "Разрешение просматривать Дело скважины",
Name = "WellFinalDocument.get"
Name = "WellFinalDocuments.get"
},
new
{
Id = 506,
Description = "Разрешение редактировать ответственных за загрузку файла Дело скважины",
Name = "WellFinalDocument.editPublisher"
Name = "WellFinalDocuments.editPublisher"
});
});

View File

@ -126,10 +126,10 @@
new (){ Id = 500, Name="FileCategory.delete", Description="Разрешение удалять Категорий документов файлов"},
new (){ Id = 501, Name="FileCategory.edit", Description="Разрешение редактировать Категорий документов файлов"},
new (){ Id = 502, Name="FileCategory.get", Description="Разрешение просматривать Категорий документов файлов"},
new (){ Id = 503, Name="WellFinalDocument.delete", Description="Разрешение удалять Дело скважины"},
new (){ Id = 504, Name="WellFinalDocument.edit", Description="Разрешение редактировать Дело скважины"},
new (){ Id = 505, Name="WellFinalDocument.get", Description="Разрешение просматривать Дело скважины"},
new (){ Id = 506, Name="WellFinalDocument.editPublisher", Description="Разрешение редактировать ответственных за загрузку файла Дело скважины"},
new (){ Id = 503, Name="WellFinalDocuments.delete", Description="Разрешение удалять Дело скважины"},
new (){ Id = 504, Name="WellFinalDocuments.edit", Description="Разрешение редактировать Дело скважины"},
new (){ Id = 505, Name="WellFinalDocuments.get", Description="Разрешение просматривать Дело скважины"},
new (){ Id = 506, Name="WellFinalDocuments.editPublisher", Description="Разрешение редактировать ответственных за загрузку файла Дело скважины"},
};
}
}

View File

@ -29,7 +29,7 @@ namespace AsbCloudWebApi.Tests.ServicesTests
[Fact]
public async Task GetWellCategoryAsync_return_cnt_file_category()
{
var cnt = (await service.GetWellCategoryAsync(CancellationToken.None)).Count();
var cnt = (await service.GetWellCategoryAsync(0, CancellationToken.None)).Count();
Assert.NotEqual(0, cnt);
}
}

View File

@ -11,7 +11,7 @@ namespace AsbCloudWebApi.Controllers
/// <summary>
/// Категорий документов файлов
/// </summary>
[Route("api/fileCategory")]
[Route("api/[Controller]")]
[ApiController]
[Authorize]
public class FileCategoryController : CrudController<FileCategoryDto, ICrudService<FileCategoryDto>>
@ -28,8 +28,8 @@ namespace AsbCloudWebApi.Controllers
/// </summary>
/// <returns></returns>
[HttpGet]
[Route("/getWellFileCategory")]
//[Permission]
[Route("/api/fileCategories")]
[Permission]
public async Task<IActionResult> GetWellFileCategory(CancellationToken token = default)
{
var data = await fileCategoryService.GetWellCategoryAsync(token);

View File

@ -21,10 +21,15 @@ namespace AsbCloudWebApi.Controllers
{
private readonly IWellFinalDocumentsService wellFinalDocumentsService;
private readonly IWellService wellService;
public WellFinalDocumentsController(IWellFinalDocumentsService wellFinalDocumentsService, IWellService wellService)
private readonly IFileCategoryService fileCategoryService;
public WellFinalDocumentsController(
IWellFinalDocumentsService wellFinalDocumentsService,
IWellService wellService,
IFileCategoryService fileCategoryService)
{
this.wellFinalDocumentsService = wellFinalDocumentsService;
this.wellService = wellService;
this.fileCategoryService = fileCategoryService;
}
/// <summary>
@ -54,7 +59,7 @@ namespace AsbCloudWebApi.Controllers
/// <returns></returns>
[HttpGet]
[Permission]
[Route("publishers")]
[Route("availableUsers")]
[ProducesResponseType(typeof(IEnumerable<UserDto>), (int)System.Net.HttpStatusCode.OK)]
public async Task<IActionResult> GetAvailableUsersAsync(int idWell, CancellationToken token = default)
{
@ -73,7 +78,7 @@ namespace AsbCloudWebApi.Controllers
/// <param name="token"></param>
/// <returns></returns>
[HttpPut]
[Permission("WellFinalDocument.editPublisher")]
[Permission("WellFinalDocuments.editPublisher")]
[ProducesResponseType(typeof(int), (int)System.Net.HttpStatusCode.OK)]
public async Task<IActionResult> UpdateRangeAsync(int idWell, IEnumerable<WellFinalDocumentInputDto> dtos, CancellationToken token = default)
{
@ -128,6 +133,19 @@ namespace AsbCloudWebApi.Controllers
return Ok(data);
}
/// <summary>
/// Получение справочника категорий файлов
/// </summary>
/// <returns></returns>
[HttpGet]
[Route("/api/wellFileCategories")]
[Permission]
public async Task<IActionResult> GetWellFileCategory(CancellationToken token = default)
{
var data = await fileCategoryService.GetWellCategoryAsync(token);
return Ok(data);
}
private async Task<bool> CanUserAccessToWellAsync(int idWell, CancellationToken token = default)
{
int? idCompany = User.GetCompanyId();