forked from ddrilling/AsbCloudServer
Make EF default data public
This commit is contained in:
parent
0ea49dd72f
commit
fee2b19b46
@ -1,10 +1,11 @@
|
|||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
namespace AsbCloudDb.Model.DefaultData
|
namespace AsbCloudDb.Model.DefaultData
|
||||||
{
|
{
|
||||||
internal static class DefaultContextData
|
internal static class DefaultContextData
|
||||||
{
|
{
|
||||||
public static void Fill(ModelBuilder modelBuilder)
|
public static IEnumerable<IEntityFiller> GetFillers()
|
||||||
{
|
{
|
||||||
var fillers = new IEntityFiller[]
|
var fillers = new IEntityFiller[]
|
||||||
{
|
{
|
||||||
@ -24,6 +25,12 @@ namespace AsbCloudDb.Model.DefaultData
|
|||||||
new EntityFillerCompanyType(),
|
new EntityFillerCompanyType(),
|
||||||
new EntityFillerSubsystem(),
|
new EntityFillerSubsystem(),
|
||||||
};
|
};
|
||||||
|
return fillers;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void Fill(ModelBuilder modelBuilder)
|
||||||
|
{
|
||||||
|
var fillers = GetFillers();
|
||||||
|
|
||||||
foreach (var filler in fillers)
|
foreach (var filler in fillers)
|
||||||
filler.FillData(modelBuilder);
|
filler.FillData(modelBuilder);
|
||||||
|
@ -1,11 +1,12 @@
|
|||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
namespace AsbCloudDb.Model.DefaultData
|
namespace AsbCloudDb.Model.DefaultData
|
||||||
{
|
{
|
||||||
internal abstract class EntityFiller<TEntity> : IEntityFiller
|
internal abstract class EntityFiller<TEntity> : IEntityFiller
|
||||||
where TEntity : class
|
where TEntity : class
|
||||||
{
|
{
|
||||||
protected abstract TEntity[] GetData();
|
public abstract TEntity[] GetData();
|
||||||
|
|
||||||
public void FillData(ModelBuilder modelBuilder)
|
public void FillData(ModelBuilder modelBuilder)
|
||||||
{
|
{
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
{
|
{
|
||||||
internal class EntityFillerCompany : EntityFiller<Company>
|
internal class EntityFillerCompany : EntityFiller<Company>
|
||||||
{
|
{
|
||||||
protected override Company[] GetData() => new Company[]
|
public override Company[] GetData() => new Company[]
|
||||||
{
|
{
|
||||||
new (){ Id = 1, Caption = "ООО \"АСБ\"", IdCompanyType = 3},
|
new (){ Id = 1, Caption = "ООО \"АСБ\"", IdCompanyType = 3},
|
||||||
};
|
};
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
{
|
{
|
||||||
internal class EntityFillerCompanyType : EntityFiller<CompanyType>
|
internal class EntityFillerCompanyType : EntityFiller<CompanyType>
|
||||||
{
|
{
|
||||||
protected override CompanyType[] GetData() => new CompanyType[] {
|
public override CompanyType[] GetData() => new CompanyType[] {
|
||||||
new (){ Id = 1, Caption = "Недрапользователь", },
|
new (){ Id = 1, Caption = "Недрапользователь", },
|
||||||
new (){ Id = 2, Caption = "Буровой подрядчик", },
|
new (){ Id = 2, Caption = "Буровой подрядчик", },
|
||||||
new (){ Id = 3, Caption = "Сервис автоматизации бурения", },
|
new (){ Id = 3, Caption = "Сервис автоматизации бурения", },
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
{
|
{
|
||||||
internal class EntityFillerFileCategory: EntityFiller<FileCategory>
|
internal class EntityFillerFileCategory: EntityFiller<FileCategory>
|
||||||
{
|
{
|
||||||
protected override FileCategory[] GetData() => new FileCategory[]{
|
public override FileCategory[] GetData() => new FileCategory[]{
|
||||||
new () {Id = 1, Name = "Растворный сервис", ShortName = "fluidService"},
|
new () {Id = 1, Name = "Растворный сервис", ShortName = "fluidService"},
|
||||||
new () {Id = 2, Name = "Цементирование", ShortName = "cement"},
|
new () {Id = 2, Name = "Цементирование", ShortName = "cement"},
|
||||||
new () {Id = 3, Name = "ННБ", ShortName = "nnb"},
|
new () {Id = 3, Name = "ННБ", ShortName = "nnb"},
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
{
|
{
|
||||||
internal class EntityFillerMeasureCategory : EntityFiller<MeasureCategory>
|
internal class EntityFillerMeasureCategory : EntityFiller<MeasureCategory>
|
||||||
{
|
{
|
||||||
protected override MeasureCategory[] GetData() => new MeasureCategory[] {
|
public override MeasureCategory[] GetData() => new MeasureCategory[] {
|
||||||
new (){ Id = 1, Name = "Показатели бурового раствора", ShortName = "Раствор"},
|
new (){ Id = 1, Name = "Показатели бурового раствора", ShortName = "Раствор"},
|
||||||
new (){ Id = 2, Name = "Шламограмма", ShortName = "Шламограмма"},
|
new (){ Id = 2, Name = "Шламограмма", ShortName = "Шламограмма"},
|
||||||
new (){ Id = 3, Name = "ННБ", ShortName = "ННБ"},
|
new (){ Id = 3, Name = "ННБ", ShortName = "ННБ"},
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
{
|
{
|
||||||
internal class EntityFillerPermission : EntityFiller<Permission>
|
internal class EntityFillerPermission : EntityFiller<Permission>
|
||||||
{
|
{
|
||||||
protected override Permission[] GetData() => new Permission[]{
|
public override Permission[] GetData() => new Permission[]{
|
||||||
new (){ Id = 100, Name="AdminCluster.delete", Description="Разрешение удалять админ. Кусты"},
|
new (){ Id = 100, Name="AdminCluster.delete", Description="Разрешение удалять админ. Кусты"},
|
||||||
new (){ Id = 101, Name="AdminCluster.edit", Description="Разрешение редактировать админ. Кусты"},
|
new (){ Id = 101, Name="AdminCluster.edit", Description="Разрешение редактировать админ. Кусты"},
|
||||||
new (){ Id = 102, Name="AdminCluster.get", Description="Разрешение просматривать админ. Кусты"},
|
new (){ Id = 102, Name="AdminCluster.get", Description="Разрешение просматривать админ. Кусты"},
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
{
|
{
|
||||||
internal class EntityFillerRelationUserRolePermission: EntityFiller<RelationUserRolePermission>
|
internal class EntityFillerRelationUserRolePermission: EntityFiller<RelationUserRolePermission>
|
||||||
{
|
{
|
||||||
protected override RelationUserRolePermission[] GetData() => new RelationUserRolePermission[]{
|
public override RelationUserRolePermission[] GetData() => new RelationUserRolePermission[]{
|
||||||
new (){ IdUserRole = 1100, IdPermission = 102}, new (){ IdUserRole = 1100, IdPermission = 111},
|
new (){ IdUserRole = 1100, IdPermission = 102}, new (){ IdUserRole = 1100, IdPermission = 111},
|
||||||
new (){ IdUserRole = 1101, IdPermission = 101}, new (){ IdUserRole = 1101, IdPermission = 100},
|
new (){ IdUserRole = 1101, IdPermission = 101}, new (){ IdUserRole = 1101, IdPermission = 100},
|
||||||
new (){ IdUserRole = 1102, IdPermission = 105}, new (){ IdUserRole = 1102, IdPermission = 108},
|
new (){ IdUserRole = 1102, IdPermission = 105}, new (){ IdUserRole = 1102, IdPermission = 108},
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
{
|
{
|
||||||
internal class EntityFillerRelationUserRoleUserRole: EntityFiller< RelationUserRoleUserRole>
|
internal class EntityFillerRelationUserRoleUserRole: EntityFiller< RelationUserRoleUserRole>
|
||||||
{
|
{
|
||||||
protected override RelationUserRoleUserRole[] GetData() => new RelationUserRoleUserRole[]{
|
public override RelationUserRoleUserRole[] GetData() => new RelationUserRoleUserRole[]{
|
||||||
new (){ Id = 1101, IdInclude = 1100 },
|
new (){ Id = 1101, IdInclude = 1100 },
|
||||||
new (){ Id = 1103, IdInclude = 1102 },
|
new (){ Id = 1103, IdInclude = 1102 },
|
||||||
new (){ Id = 1105, IdInclude = 1104 },
|
new (){ Id = 1105, IdInclude = 1104 },
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
{
|
{
|
||||||
internal class EntityFillerRelationUserUserRole : EntityFiller<RelationUserUserRole>
|
internal class EntityFillerRelationUserUserRole : EntityFiller<RelationUserUserRole>
|
||||||
{
|
{
|
||||||
protected override RelationUserUserRole[] GetData() => new RelationUserUserRole[]
|
public override RelationUserUserRole[] GetData() => new RelationUserUserRole[]
|
||||||
{
|
{
|
||||||
new () { IdUser = 1, IdUserRole = 1, },
|
new () { IdUser = 1, IdUserRole = 1, },
|
||||||
};
|
};
|
||||||
|
@ -3,7 +3,7 @@ namespace AsbCloudDb.Model.DefaultData
|
|||||||
{
|
{
|
||||||
internal class EntityFillerSubsystem : EntityFiller<Subsystem>
|
internal class EntityFillerSubsystem : EntityFiller<Subsystem>
|
||||||
{
|
{
|
||||||
protected override Subsystem[] GetData() => new Subsystem[]{
|
public override Subsystem[] GetData() => new Subsystem[]{
|
||||||
// САУБ - ид подсистем с 1 до 65_535
|
// САУБ - ид подсистем с 1 до 65_535
|
||||||
new () {Id = 1, Name = "АКБ", Description = "Совместная работа режимов \"Бурение в роторе\" и \"Бурение в слайде\""},
|
new () {Id = 1, Name = "АКБ", Description = "Совместная работа режимов \"Бурение в роторе\" и \"Бурение в слайде\""},
|
||||||
new () {Id = 2, Name = "MSE", Description = "Алгоритм поиска оптимальных параметров бурения САУБ"},
|
new () {Id = 2, Name = "MSE", Description = "Алгоритм поиска оптимальных параметров бурения САУБ"},
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
{
|
{
|
||||||
internal class EntityFillerUser : EntityFiller<User>
|
internal class EntityFillerUser : EntityFiller<User>
|
||||||
{
|
{
|
||||||
protected override User[] GetData() => new User[]{
|
public override User[] GetData() => new User[]{
|
||||||
new (){
|
new (){
|
||||||
Id = 1,
|
Id = 1,
|
||||||
IdCompany = 1,
|
IdCompany = 1,
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
{
|
{
|
||||||
internal class EntityFillerUserRole : EntityFiller<UserRole>
|
internal class EntityFillerUserRole : EntityFiller<UserRole>
|
||||||
{
|
{
|
||||||
protected override UserRole[] GetData() => new UserRole[]{
|
public override UserRole[] GetData() => new UserRole[]{
|
||||||
new (){ Id = 1, Caption = "root", IdType = 1},
|
new (){ Id = 1, Caption = "root", IdType = 1},
|
||||||
new (){ Id = 1100, Caption = "admin_cluster.view", IdType = 1},
|
new (){ Id = 1100, Caption = "admin_cluster.view", IdType = 1},
|
||||||
new (){ Id = 1101, Caption = "admin_cluster.edit", IdType = 1},
|
new (){ Id = 1101, Caption = "admin_cluster.edit", IdType = 1},
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
{
|
{
|
||||||
internal class EntityFillerWellOperationCategory : EntityFiller<WellOperationCategory>
|
internal class EntityFillerWellOperationCategory : EntityFiller<WellOperationCategory>
|
||||||
{
|
{
|
||||||
protected override WellOperationCategory[] GetData() => new WellOperationCategory[]{
|
public override WellOperationCategory[] GetData() => new WellOperationCategory[]{
|
||||||
// Автоматически определяемые операции
|
// Автоматически определяемые операции
|
||||||
new () {Id = 1, Name = "Невозможно определить операцию", Code = 0, KeyValueName = "dT", KeyValueUnits = "мин"},
|
new () {Id = 1, Name = "Невозможно определить операцию", Code = 0, KeyValueName = "dT", KeyValueUnits = "мин"},
|
||||||
new () {Id = 2, Name = "Роторное бурение", Code = 0, KeyValueName = "МСП", KeyValueUnits = "м/ч" },
|
new () {Id = 2, Name = "Роторное бурение", Code = 0, KeyValueName = "МСП", KeyValueUnits = "м/ч" },
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
{
|
{
|
||||||
internal class EntityFillerWellSectionType : EntityFiller<WellSectionType>
|
internal class EntityFillerWellSectionType : EntityFiller<WellSectionType>
|
||||||
{
|
{
|
||||||
protected override WellSectionType[] GetData() => new WellSectionType[]
|
public override WellSectionType[] GetData() => new WellSectionType[]
|
||||||
{
|
{
|
||||||
new (){ Id = 1, Caption = "Пилотный ствол"},
|
new (){ Id = 1, Caption = "Пилотный ствол"},
|
||||||
new (){ Id = 2, Caption = "Направление"},
|
new (){ Id = 2, Caption = "Направление"},
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
{
|
{
|
||||||
internal class EntityFillerWellType : EntityFiller<WellType>
|
internal class EntityFillerWellType : EntityFiller<WellType>
|
||||||
{
|
{
|
||||||
protected override WellType[] GetData() => new WellType[]
|
public override WellType[] GetData() => new WellType[]
|
||||||
{
|
{
|
||||||
new (){ Id = 1, Caption = "Наклонно-направленная"},
|
new (){ Id = 1, Caption = "Наклонно-направленная"},
|
||||||
new (){ Id = 2, Caption = "Горизонтальная"},
|
new (){ Id = 2, Caption = "Горизонтальная"},
|
||||||
|
Loading…
Reference in New Issue
Block a user