Merge pull request 'Правки по результатам тестирования контактов скважины' (#76) from fix/well-contacts into dev

Reviewed-on: http://test.digitaldrilling.ru:8080/DDrilling/AsbCloudServer/pulls/76
This commit is contained in:
Никита Фролов 2023-07-13 13:29:54 +05:00
commit a04a105b91
8 changed files with 8307 additions and 13 deletions

View File

@ -22,9 +22,10 @@ namespace AsbCloudApp.Services
/// <summary>
/// Получение типов контаков
/// </summary>
/// <param name="idWell">ключ скважины</param>
/// <param name="token"></param>
/// <returns></returns>
Task<IEnumerable<CompanyTypeDto>> GetTypesAsync(CancellationToken token);
Task<IEnumerable<CompanyTypeDto>> GetTypesAsync(int idWell, CancellationToken token);
/// <summary>
/// Обновление контактов по ключу скважины, типу контакта и ключам пользователей

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,47 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace AsbCloudDb.Migrations
{
public partial class Add_Order_For_CompanyType : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<int>(
name: "order",
table: "t_company_type",
type: "integer",
nullable: false,
defaultValue: 0);
migrationBuilder.UpdateData(
table: "t_company_type",
keyColumn: "id",
keyValue: 1,
column: "order",
value: 1);
migrationBuilder.UpdateData(
table: "t_company_type",
keyColumn: "id",
keyValue: 2,
column: "order",
value: 2);
migrationBuilder.UpdateData(
table: "t_company_type",
keyColumn: "id",
keyValue: 5,
column: "order",
value: 3);
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "order",
table: "t_company_type");
}
}
}

View File

@ -122,6 +122,10 @@ namespace AsbCloudDb.Migrations
b.Property<bool>("IsContact")
.HasColumnType("boolean");
b.Property<int>("Order")
.HasColumnType("integer")
.HasColumnName("order");
b.HasKey("Id");
b.ToTable("t_company_type");
@ -131,19 +135,22 @@ namespace AsbCloudDb.Migrations
{
Id = 1,
Caption = "Недрапользователь",
IsContact = false
IsContact = false,
Order = 1
},
new
{
Id = 2,
Caption = "Буровой подрядчик",
IsContact = false
IsContact = false,
Order = 2
},
new
{
Id = 3,
Caption = "Сервис автоматизации бурения",
IsContact = false
IsContact = false,
Order = 0
});
});
@ -989,7 +996,7 @@ namespace AsbCloudDb.Migrations
b.Property<int>("IdCategory")
.HasColumnType("integer")
.HasColumnName("id_category")
.HasComment("id категории файла");
.HasComment("Id категории файла");
b.Property<string>("Name")
.IsRequired()

View File

@ -16,6 +16,9 @@ namespace AsbCloudDb.Model
public string Caption { get; set; } = null!;
public bool IsContact { get; set; }
[Column("order")]
public int Order { get; set; }
[InverseProperty(nameof(Company.CompanyType))]
public virtual ICollection<Company> Companies { get; set; } = null!;
}

View File

@ -3,9 +3,9 @@
internal class EntityFillerCompanyType : EntityFiller<CompanyType>
{
public override CompanyType[] GetData() => new CompanyType[] {
new (){ Id = 1, Caption = "Недрапользователь", },
new (){ Id = 2, Caption = "Буровой подрядчик", },
new (){ Id = 3, Caption = "Сервис автоматизации бурения", },
new (){ Id = 1, Caption = "Недрапользователь", Order = 1 },
new (){ Id = 2, Caption = "Буровой подрядчик", Order = 2 },
new (){ Id = 3, Caption = "Сервис автоматизации бурения", Order = 0 }
};
}
}

View File

@ -50,9 +50,12 @@ namespace AsbCloudInfrastructure.Services
return entities;
}
public async Task<IEnumerable<CompanyTypeDto>> GetTypesAsync(CancellationToken token)
public async Task<IEnumerable<CompanyTypeDto>> GetTypesAsync(int idWell, CancellationToken token)
{
var query = db.CompaniesTypes.Where(t => t.IsContact);
var query = db.CompaniesTypes
.Where(t => t.IsContact)
.Where(t => t.Companies.Any(c => c.Users.Any() && c.RelationCompaniesWells.Any(w => w.IdWell == idWell)))
.OrderBy(t => t.Order);
var entities = await query.AsNoTracking()
.ToArrayAsync(token)

View File

@ -29,13 +29,14 @@ namespace AsbCloudWebApi.Controllers
/// <summary>
/// получение списка типов контактов
/// </summary>
/// <param name="idWell">ключ скважины</param>
/// <param name="token"></param>
/// <returns></returns>
[HttpGet("api/contacts/types")]
[HttpGet("api/well/{idWell}/contacts/types")]
[ProducesResponseType(typeof(IEnumerable<CompanyTypeDto>), (int)System.Net.HttpStatusCode.OK)]
public async Task<IActionResult> GetTypesAsync(CancellationToken token)
public async Task<IActionResult> GetTypesAsync(int idWell, CancellationToken token)
{
var result = await wellContactsRepository.GetTypesAsync(token).ConfigureAwait(false);
var result = await wellContactsRepository.GetTypesAsync(idWell, token).ConfigureAwait(false);
return Ok(result);
}