Правки по результатам тестирования контактов скважины

This commit is contained in:
Olga Nemt 2023-07-13 10:51:38 +05:00
parent b7d9ec8183
commit 71fd3264e3
8 changed files with 8440 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,90 @@
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);
migrationBuilder.InsertData(
table: "t_company_type",
columns: new[] { "id", "caption", "IsContact", "order" },
values: new object[,]
{
{ 8, "Сервис по ННБ", false, 4 },
{ 9, "Сервис по ГТИ", false, 5 },
{ 10, "Супервайзинг", false, 6 },
{ 11, "Сервис по цементированию", false, 7 },
{ 12, "Сервис по обслуживанию верхних силовых приводов", false, 8 },
{ 13, "Сервис по обслуживанию электроустановок", false, 9 }
});
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DeleteData(
table: "t_company_type",
keyColumn: "id",
keyValue: 8);
migrationBuilder.DeleteData(
table: "t_company_type",
keyColumn: "id",
keyValue: 9);
migrationBuilder.DeleteData(
table: "t_company_type",
keyColumn: "id",
keyValue: 10);
migrationBuilder.DeleteData(
table: "t_company_type",
keyColumn: "id",
keyValue: 11);
migrationBuilder.DeleteData(
table: "t_company_type",
keyColumn: "id",
keyValue: 12);
migrationBuilder.DeleteData(
table: "t_company_type",
keyColumn: "id",
keyValue: 13);
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,64 @@ 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
},
new
{
Id = 8,
Caption = "Сервис по ННБ",
IsContact = false,
Order = 4
},
new
{
Id = 9,
Caption = "Сервис по ГТИ",
IsContact = false,
Order = 5
},
new
{
Id = 10,
Caption = "Супервайзинг",
IsContact = false,
Order = 6
},
new
{
Id = 11,
Caption = "Сервис по цементированию",
IsContact = false,
Order = 7
},
new
{
Id = 12,
Caption = "Сервис по обслуживанию верхних силовых приводов",
IsContact = false,
Order = 8
},
new
{
Id = 13,
Caption = "Сервис по обслуживанию электроустановок",
IsContact = false,
Order = 9
});
});
@ -989,7 +1038,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,15 @@
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 },
new (){ Id = 8, Caption = "Сервис по ННБ", Order = 4 },
new (){ Id = 9, Caption = "Сервис по ГТИ", Order = 5 },
new (){ Id = 10, Caption = "Супервайзинг", Order = 6 },
new (){ Id = 11, Caption = "Сервис по цементированию", Order = 7 },
new (){ Id = 12, Caption = "Сервис по обслуживанию верхних силовых приводов", Order = 8 },
new (){ Id = 13, Caption = "Сервис по обслуживанию электроустановок", Order = 9 },
};
}
}

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);
}