ReportFields (#89)
XD XD XD fix rest merge XD XD Co-authored-by: Michal Bohdanowicz <m.w.bohdanowicz@gmail.com>
This commit is contained in:
parent
520e986a55
commit
d612e74e13
@ -1,5 +0,0 @@
|
||||
{
|
||||
"sdk": {
|
||||
"version": "3.1.301"
|
||||
}
|
||||
}
|
@ -20,7 +20,7 @@ namespace InternshipSystem.Api
|
||||
opt => opt.MapFrom(edition => edition.IsOpen ? "Open" : "Archival"));
|
||||
|
||||
CreateMap<Edition, EditionManagementResult>();
|
||||
|
||||
|
||||
CreateMap<Edition, EditionDetailsResult>();
|
||||
|
||||
CreateMap<Edition, EditionConfigurationResult>();
|
||||
|
@ -99,6 +99,8 @@ namespace InternshipSystem.Api.Controllers
|
||||
var edition =
|
||||
await Context.Editions
|
||||
.Include(e => e.AvailableSubjects)
|
||||
.Include(e => e.ReportSchema)
|
||||
.ThenInclude(e => e.Field)
|
||||
.Include(e => e.Course)
|
||||
.Where(e => e.Id == user.EditionId)
|
||||
.ProjectTo<EditionConfigurationResult>(Mapper.ConfigurationProvider)
|
||||
|
@ -43,6 +43,8 @@ namespace InternshipSystem.Api.Controllers
|
||||
.Skip(searchQuery.Page * searchQuery.PerPage)
|
||||
.Take(searchQuery.PerPage)
|
||||
.ToListAsync(token);
|
||||
|
||||
|
||||
|
||||
[HttpGet("{editionId}")]
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
@ -57,6 +59,8 @@ namespace InternshipSystem.Api.Controllers
|
||||
.ThenInclude(s => s.Subject)
|
||||
.Include(e => e.AvailableInternshipTypes)
|
||||
.ThenInclude(i => i.InternshipType)
|
||||
.Include(e => e.ReportSchema)
|
||||
.ThenInclude(er => er.Field)
|
||||
.Where(e => e.Id == editionId)
|
||||
.ProjectTo<EditionDetailsResult>(Mapper.ConfigurationProvider)
|
||||
.FirstOrDefaultAsync(token);
|
||||
@ -68,7 +72,7 @@ namespace InternshipSystem.Api.Controllers
|
||||
|
||||
return Ok(edition);
|
||||
}
|
||||
|
||||
|
||||
[HttpPut]
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||
@ -90,6 +94,7 @@ namespace InternshipSystem.Api.Controllers
|
||||
var editionToUpdate = await Context.Editions
|
||||
.Include(e => e.AvailableSubjects)
|
||||
.Include(e => e.AvailableInternshipTypes)
|
||||
.Include(e => e.ReportSchema)
|
||||
.FirstOrDefaultAsync(e => e.Id == editionForm.Id.Value, token);
|
||||
|
||||
if (editionToUpdate == null)
|
||||
@ -98,7 +103,7 @@ namespace InternshipSystem.Api.Controllers
|
||||
}
|
||||
|
||||
editionToUpdate.UpdateEdition(editionForm.EditionStart, editionForm.EditionFinish, editionForm.ReportingStart,
|
||||
editionForm.Course, editionForm.AvailableSubjectsIds, editionForm.AvailableInternshipTypesIds);
|
||||
editionForm.Course, editionForm.AvailableSubjectsIds, editionForm.AvailableInternshipTypesIds, editionForm.ReportSchema);
|
||||
|
||||
if (!editionToUpdate.IsValidDates)
|
||||
{
|
||||
@ -109,7 +114,7 @@ namespace InternshipSystem.Api.Controllers
|
||||
{
|
||||
var newEdition =
|
||||
Edition.CreateEdition(editionForm.EditionStart.Value, editionForm.EditionFinish.Value, editionForm.ReportingStart.Value,
|
||||
editionForm.Course, editionForm.AvailableSubjectsIds, editionForm.AvailableInternshipTypesIds);
|
||||
editionForm.Course, editionForm.AvailableSubjectsIds, editionForm.AvailableInternshipTypesIds, editionForm.ReportSchema);
|
||||
|
||||
if (!newEdition.IsValidDates)
|
||||
{
|
||||
@ -135,6 +140,7 @@ namespace InternshipSystem.Api.Controllers
|
||||
var editionToDelete = await Context.Editions
|
||||
.Include(e => e.AvailableSubjects)
|
||||
.Include(e => e.AvailableInternshipTypes)
|
||||
.Include(e => e.ReportSchema)
|
||||
.FirstOrDefaultAsync(e => e.Id.Equals(editionId), token);
|
||||
|
||||
if (editionToDelete == null)
|
||||
|
@ -0,0 +1,89 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using AutoMapper;
|
||||
using InternshipSystem.Api.Queries.SearchQuery;
|
||||
using InternshipSystem.Api.Security;
|
||||
using InternshipSystem.Core;
|
||||
using InternshipSystem.Core.Entity;
|
||||
using InternshipSystem.Repository;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace InternshipSystem.Api.Controllers
|
||||
{
|
||||
[Route("management/report")]
|
||||
public class ReportFieldsController : ControllerBase
|
||||
{
|
||||
private readonly InternshipDbContext _context;
|
||||
private readonly IMapper _mapper;
|
||||
|
||||
public ReportFieldsController(InternshipDbContext context, IMapper mapper)
|
||||
{
|
||||
_context = context;
|
||||
_mapper = mapper;
|
||||
}
|
||||
|
||||
[HttpGet("fields")]
|
||||
[Authorize(Policy = Policies.IsOverseer)]
|
||||
public async Task<IEnumerable<ReportField>> GetFields(FieldSearchQuery searchQuery, CancellationToken ct) =>
|
||||
await _context.ReportFields
|
||||
.Where(c => c.Label.ToLower().Contains(searchQuery.Label.ToLower()))
|
||||
.OrderBy(o => o.Label)
|
||||
.Skip(searchQuery.Page * searchQuery.PerPage)
|
||||
.Take(searchQuery.PerPage)
|
||||
.ToListAsync(ct);
|
||||
|
||||
[HttpPost("fields")]
|
||||
[Authorize(Policy = Policies.IsOverseer)]
|
||||
public async Task<ActionResult> CreateField([FromBody] FieldCreateRequest request, CancellationToken ct)
|
||||
{
|
||||
ReportField field;
|
||||
|
||||
switch (request.FieldType)
|
||||
{
|
||||
case FieldType.LongText:
|
||||
case FieldType.ShortText:
|
||||
field = new ReportField(request.Label, request.LabelEng, request.Description, request.DescriptionEng, request.FieldType);
|
||||
break;
|
||||
case FieldType.Select:
|
||||
case FieldType.Radial:
|
||||
case FieldType.Checkbox:
|
||||
field = new ReportChoiceField(request.Label, request.LabelEng, request.Description, request.DescriptionEng, request.FieldType, request.Choices);
|
||||
break;
|
||||
default:
|
||||
return BadRequest("Unknown field type");
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
await _context.ReportFields.AddAsync(field, ct);
|
||||
await _context.SaveChangesAsync(ct);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
return BadRequest("Failed");
|
||||
}
|
||||
|
||||
return Ok();
|
||||
}
|
||||
}
|
||||
|
||||
public class FieldSearchQuery : SearchQuery
|
||||
{
|
||||
public string Label { get; set; } = "";
|
||||
}
|
||||
|
||||
public class FieldCreateRequest
|
||||
{
|
||||
public string Label { get; set; }
|
||||
public string LabelEng { get; set; }
|
||||
public string Description { get; set; }
|
||||
public string DescriptionEng { get; set; }
|
||||
public FieldType FieldType { get; set; }
|
||||
public string[] Choices { get; set; }
|
||||
}
|
||||
}
|
@ -16,6 +16,7 @@ namespace InternshipSystem.Api.Queries
|
||||
public Course Course { get; set; }
|
||||
public List<long> AvailableSubjectsIds { get; set; } = new List<long>();
|
||||
public List<long> AvailableInternshipTypesIds { get; set; } = new List<long>();
|
||||
public List<long> ReportSchema { get; set; } = new List<long>();
|
||||
|
||||
public class Validator : AbstractValidator<EditionForm>
|
||||
{
|
||||
|
@ -10,6 +10,7 @@ namespace InternshipSystem.Api.Result
|
||||
public class EditionConfigurationResult
|
||||
{
|
||||
public List<InternshipSubject> AvailableSubjects { get; set; }
|
||||
public List<ReportField> ReportSchema { get; set; }
|
||||
public Course Course { get; set; }
|
||||
public DateTime EditionStart { get; set; }
|
||||
public DateTime EditionFinish { get; set; }
|
||||
|
@ -15,5 +15,6 @@ namespace InternshipSystem.Api.Result
|
||||
public Course Course { get; set; }
|
||||
public List<InternshipSubject> AvailableSubjects { get; set; }
|
||||
public List<InternshipType> AvailableInternshipTypes { get; set; }
|
||||
public List<ReportField> ReportSchema { get; set; }
|
||||
}
|
||||
}
|
@ -17,11 +17,12 @@ namespace InternshipSystem.Core
|
||||
public List<Internship> Internships { get; set; }
|
||||
public List<EditionSubject> AvailableSubjects { get; set; }
|
||||
public List<EditionInternshipType> AvailableInternshipTypes { get; set; }
|
||||
public List<ReportFieldEdition> ReportSchema { get; set; }
|
||||
|
||||
public bool IsOpen => EditionFinish < DateTime.Today;
|
||||
|
||||
public static Edition CreateEdition(DateTime start, DateTime end, DateTime reportingStart, Course course,
|
||||
IEnumerable<long> subjectsIds, IEnumerable<long> internshipTypesIds)
|
||||
IEnumerable<long> subjectsIds, IEnumerable<long> internshipTypesIds, IEnumerable<long> reportFieldIds)
|
||||
{
|
||||
var newEdition = CreateEdition(start, end, reportingStart, course);
|
||||
|
||||
@ -42,6 +43,15 @@ namespace InternshipSystem.Core
|
||||
InternshipTypeId = i,
|
||||
})
|
||||
.ToList();
|
||||
|
||||
newEdition.ReportSchema =
|
||||
reportFieldIds
|
||||
.Select(i => new ReportFieldEdition
|
||||
{
|
||||
Edition = newEdition,
|
||||
ReportFieldId = i,
|
||||
})
|
||||
.ToList();
|
||||
|
||||
return newEdition;
|
||||
}
|
||||
@ -56,11 +66,12 @@ namespace InternshipSystem.Core
|
||||
Course = course,
|
||||
AvailableSubjects = new List<EditionSubject>(),
|
||||
AvailableInternshipTypes = new List<EditionInternshipType>(),
|
||||
ReportSchema = new List<ReportFieldEdition>()
|
||||
};
|
||||
}
|
||||
|
||||
public void UpdateEdition(DateTime? start, DateTime? end, DateTime? reportingStart, Course course,
|
||||
IEnumerable<long> subjectsIds, IEnumerable<long> internshipTypesIds)
|
||||
IEnumerable<long> subjectsIds, IEnumerable<long> internshipTypesIds, IEnumerable<long> reportFieldIds)
|
||||
{
|
||||
EditionStart = start ?? EditionStart;
|
||||
EditionFinish = end ?? EditionFinish;
|
||||
@ -88,6 +99,17 @@ namespace InternshipSystem.Core
|
||||
})
|
||||
.ToList();
|
||||
}
|
||||
|
||||
if (reportFieldIds != null)
|
||||
{
|
||||
ReportSchema =
|
||||
reportFieldIds
|
||||
.Select(i => new ReportFieldEdition
|
||||
{
|
||||
ReportFieldId = i,
|
||||
})
|
||||
.ToList();
|
||||
}
|
||||
}
|
||||
|
||||
public void RegisterInternship(Student student)
|
||||
|
@ -6,8 +6,7 @@ namespace InternshipSystem.Core
|
||||
{
|
||||
public long Id { get; set; }
|
||||
public DocumentState State { get; set; }
|
||||
public RangeOfActivity Range { get; set; }
|
||||
public Uri SiteAddress { get; set; }
|
||||
public string Value { get; set; }
|
||||
|
||||
public static Report Create()
|
||||
{
|
||||
|
44
src/InternshipSystem.Core/Entity/ReportField.cs
Normal file
44
src/InternshipSystem.Core/Entity/ReportField.cs
Normal file
@ -0,0 +1,44 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace InternshipSystem.Core.Entity
|
||||
{
|
||||
public class ReportField
|
||||
{
|
||||
public ReportField(string label, string labelEng, string description, string descriptionEng, FieldType fieldType)
|
||||
{
|
||||
Label = label;
|
||||
LabelEng = labelEng;
|
||||
Description = description;
|
||||
DescriptionEng = descriptionEng;
|
||||
FieldType = fieldType;
|
||||
}
|
||||
|
||||
public long Id { get; set; }
|
||||
public string Label { get; set; }
|
||||
public string LabelEng { get; set; }
|
||||
public string Description { get; set; }
|
||||
public string DescriptionEng { get; set; }
|
||||
public FieldType FieldType { get; set; }
|
||||
}
|
||||
|
||||
public enum FieldType
|
||||
{
|
||||
LongText,
|
||||
ShortText,
|
||||
Select,
|
||||
Radial,
|
||||
Checkbox
|
||||
}
|
||||
|
||||
public class ReportChoiceField : ReportField
|
||||
{
|
||||
public ReportChoiceField(string label, string labelEng, string description, string descriptionEng,
|
||||
FieldType fieldType, string[] choices) : base(label, labelEng, description, descriptionEng, fieldType)
|
||||
{
|
||||
Choices = choices;
|
||||
}
|
||||
|
||||
public string[] Choices { get; set; }
|
||||
}
|
||||
}
|
@ -0,0 +1,13 @@
|
||||
using System;
|
||||
using InternshipSystem.Core.Entity;
|
||||
|
||||
namespace InternshipSystem.Core.UglyOrmArtifacts
|
||||
{
|
||||
public class ReportFieldEdition
|
||||
{
|
||||
public Guid EditionId { get; set; }
|
||||
public Edition Edition { get; set; }
|
||||
public long ReportFieldId { get; set; }
|
||||
public ReportField Field { get; set; }
|
||||
}
|
||||
}
|
@ -1,3 +1,5 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using InternshipSystem.Core;
|
||||
using InternshipSystem.Core.Entity;
|
||||
@ -16,6 +18,8 @@ namespace InternshipSystem.Repository
|
||||
public DbSet<Course> Courses { get; set; }
|
||||
public DbSet<Internship> Internships { get; set; }
|
||||
|
||||
public DbSet<ReportField> ReportFields { get; set; }
|
||||
|
||||
public InternshipDbContext(DbContextOptions<InternshipDbContext> options)
|
||||
: base(options)
|
||||
{
|
||||
@ -91,6 +95,37 @@ namespace InternshipSystem.Repository
|
||||
.WithMany()
|
||||
.HasForeignKey(subject => subject.InternshipSubjectId);
|
||||
});
|
||||
|
||||
modelBuilder.Entity<ReportFieldEdition>(builder =>
|
||||
{
|
||||
builder
|
||||
.HasKey(e => new {e.EditionId, e.ReportFieldId});
|
||||
|
||||
builder
|
||||
.HasOne(e => e.Edition)
|
||||
.WithMany(edition => edition.ReportSchema)
|
||||
.HasForeignKey(r => r.EditionId);
|
||||
|
||||
builder
|
||||
.HasOne(e => e.Field)
|
||||
.WithMany()
|
||||
.HasForeignKey(r => r.ReportFieldId);
|
||||
});
|
||||
|
||||
modelBuilder.Entity<ReportField>()
|
||||
.HasDiscriminator<string>("field_discrimnator")
|
||||
.HasValue<ReportField>("single")
|
||||
.HasValue<ReportChoiceField>("choice");
|
||||
|
||||
modelBuilder.Entity<ReportChoiceField>()
|
||||
.Property(r => r.Choices)
|
||||
.HasConversion(
|
||||
a => string.Join('#', a),
|
||||
s => s.Split('#', StringSplitOptions.RemoveEmptyEntries));
|
||||
|
||||
modelBuilder.Entity<Report>()
|
||||
.Property(r => r.Value)
|
||||
.HasColumnType("jsonb");
|
||||
}
|
||||
}
|
||||
}
|
@ -20,8 +20,4 @@
|
||||
<ProjectReference Include="..\InternshipSystem.Core\InternshipSystem.Core.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Folder Include="Migrations" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
@ -10,8 +10,8 @@ using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
||||
namespace InternshipSystem.Repository.Migrations
|
||||
{
|
||||
[DbContext(typeof(InternshipDbContext))]
|
||||
[Migration("20210110082601_init")]
|
||||
partial class init
|
||||
[Migration("20210110173104_Init")]
|
||||
partial class Init
|
||||
{
|
||||
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||
{
|
||||
@ -348,6 +348,47 @@ namespace InternshipSystem.Repository.Migrations
|
||||
b.ToTable("internship_types");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("InternshipSystem.Core.Entity.ReportField", b =>
|
||||
{
|
||||
b.Property<long>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnName("id")
|
||||
.HasColumnType("bigint")
|
||||
.HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
|
||||
|
||||
b.Property<string>("Description")
|
||||
.HasColumnName("description")
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<string>("DescriptionEng")
|
||||
.HasColumnName("description_eng")
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<int>("FieldType")
|
||||
.HasColumnName("field_type")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<string>("Label")
|
||||
.HasColumnName("label")
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<string>("LabelEng")
|
||||
.HasColumnName("label_eng")
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<string>("field_discrimnator")
|
||||
.IsRequired()
|
||||
.HasColumnName("field_discrimnator")
|
||||
.HasColumnType("text");
|
||||
|
||||
b.HasKey("Id")
|
||||
.HasName("pk_report_fields");
|
||||
|
||||
b.ToTable("report_fields");
|
||||
|
||||
b.HasDiscriminator<string>("field_discrimnator").HasValue("single");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("InternshipSystem.Core.Report", b =>
|
||||
{
|
||||
b.Property<long>("Id")
|
||||
@ -356,18 +397,14 @@ namespace InternshipSystem.Repository.Migrations
|
||||
.HasColumnType("bigint")
|
||||
.HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
|
||||
|
||||
b.Property<int>("Range")
|
||||
.HasColumnName("range")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<string>("SiteAddress")
|
||||
.HasColumnName("site_address")
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<int>("State")
|
||||
.HasColumnName("state")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<string>("Value")
|
||||
.HasColumnName("value")
|
||||
.HasColumnType("jsonb");
|
||||
|
||||
b.HasKey("Id")
|
||||
.HasName("pk_report");
|
||||
|
||||
@ -503,6 +540,36 @@ namespace InternshipSystem.Repository.Migrations
|
||||
b.ToTable("program_subject");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("InternshipSystem.Core.UglyOrmArtifacts.ReportFieldEdition", b =>
|
||||
{
|
||||
b.Property<Guid>("EditionId")
|
||||
.HasColumnName("edition_id")
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.Property<long>("ReportFieldId")
|
||||
.HasColumnName("report_field_id")
|
||||
.HasColumnType("bigint");
|
||||
|
||||
b.HasKey("EditionId", "ReportFieldId")
|
||||
.HasName("pk_report_field_edition");
|
||||
|
||||
b.HasIndex("ReportFieldId")
|
||||
.HasName("ix_report_field_edition_report_field_id");
|
||||
|
||||
b.ToTable("report_field_edition");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("InternshipSystem.Core.Entity.ReportChoiceField", b =>
|
||||
{
|
||||
b.HasBaseType("InternshipSystem.Core.Entity.ReportField");
|
||||
|
||||
b.Property<string>("Choices")
|
||||
.HasColumnName("choices")
|
||||
.HasColumnType("text");
|
||||
|
||||
b.HasDiscriminator().HasValue("choice");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("InternshipSystem.Core.BranchOffice", b =>
|
||||
{
|
||||
b.HasOne("InternshipSystem.Core.Company", null)
|
||||
@ -700,6 +767,23 @@ namespace InternshipSystem.Repository.Migrations
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
});
|
||||
|
||||
modelBuilder.Entity("InternshipSystem.Core.UglyOrmArtifacts.ReportFieldEdition", b =>
|
||||
{
|
||||
b.HasOne("InternshipSystem.Core.Edition", "Edition")
|
||||
.WithMany("ReportSchema")
|
||||
.HasForeignKey("EditionId")
|
||||
.HasConstraintName("fk_report_field_edition_editions_edition_id")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("InternshipSystem.Core.Entity.ReportField", "Field")
|
||||
.WithMany()
|
||||
.HasForeignKey("ReportFieldId")
|
||||
.HasConstraintName("fk_report_field_edition_report_fields_report_field_id")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
});
|
||||
#pragma warning restore 612, 618
|
||||
}
|
||||
}
|
@ -4,7 +4,7 @@ using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
||||
|
||||
namespace InternshipSystem.Repository.Migrations
|
||||
{
|
||||
public partial class init : Migration
|
||||
public partial class Init : Migration
|
||||
{
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
@ -74,14 +74,32 @@ namespace InternshipSystem.Repository.Migrations
|
||||
id = table.Column<long>(nullable: false)
|
||||
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
||||
state = table.Column<int>(nullable: false),
|
||||
range = table.Column<int>(nullable: false),
|
||||
site_address = table.Column<string>(nullable: true)
|
||||
value = table.Column<string>(type: "jsonb", nullable: true)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("pk_report", x => x.id);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "report_fields",
|
||||
columns: table => new
|
||||
{
|
||||
id = table.Column<long>(nullable: false)
|
||||
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
||||
label = table.Column<string>(nullable: true),
|
||||
label_eng = table.Column<string>(nullable: true),
|
||||
description = table.Column<string>(nullable: true),
|
||||
description_eng = table.Column<string>(nullable: true),
|
||||
field_type = table.Column<int>(nullable: false),
|
||||
field_discrimnator = table.Column<string>(nullable: false),
|
||||
choices = table.Column<string>(nullable: true)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("pk_report_fields", x => x.id);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "static_pages",
|
||||
columns: table => new
|
||||
@ -254,6 +272,30 @@ namespace InternshipSystem.Repository.Migrations
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "report_field_edition",
|
||||
columns: table => new
|
||||
{
|
||||
edition_id = table.Column<Guid>(nullable: false),
|
||||
report_field_id = table.Column<long>(nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("pk_report_field_edition", x => new { x.edition_id, x.report_field_id });
|
||||
table.ForeignKey(
|
||||
name: "fk_report_field_edition_editions_edition_id",
|
||||
column: x => x.edition_id,
|
||||
principalTable: "editions",
|
||||
principalColumn: "id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
table.ForeignKey(
|
||||
name: "fk_report_field_edition_report_fields_report_field_id",
|
||||
column: x => x.report_field_id,
|
||||
principalTable: "report_fields",
|
||||
principalColumn: "id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "internships",
|
||||
columns: table => new
|
||||
@ -427,6 +469,11 @@ namespace InternshipSystem.Repository.Migrations
|
||||
name: "ix_program_subject_internship_subject_id",
|
||||
table: "program_subject",
|
||||
column: "internship_subject_id");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "ix_report_field_edition_report_field_id",
|
||||
table: "report_field_edition",
|
||||
column: "report_field_id");
|
||||
}
|
||||
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
@ -443,6 +490,9 @@ namespace InternshipSystem.Repository.Migrations
|
||||
migrationBuilder.DropTable(
|
||||
name: "program_subject");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "report_field_edition");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "static_pages");
|
||||
|
||||
@ -452,6 +502,9 @@ namespace InternshipSystem.Repository.Migrations
|
||||
migrationBuilder.DropTable(
|
||||
name: "internship_subject");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "report_fields");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "internships");
|
||||
|
@ -346,6 +346,47 @@ namespace InternshipSystem.Repository.Migrations
|
||||
b.ToTable("internship_types");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("InternshipSystem.Core.Entity.ReportField", b =>
|
||||
{
|
||||
b.Property<long>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnName("id")
|
||||
.HasColumnType("bigint")
|
||||
.HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
|
||||
|
||||
b.Property<string>("Description")
|
||||
.HasColumnName("description")
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<string>("DescriptionEng")
|
||||
.HasColumnName("description_eng")
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<int>("FieldType")
|
||||
.HasColumnName("field_type")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<string>("Label")
|
||||
.HasColumnName("label")
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<string>("LabelEng")
|
||||
.HasColumnName("label_eng")
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<string>("field_discrimnator")
|
||||
.IsRequired()
|
||||
.HasColumnName("field_discrimnator")
|
||||
.HasColumnType("text");
|
||||
|
||||
b.HasKey("Id")
|
||||
.HasName("pk_report_fields");
|
||||
|
||||
b.ToTable("report_fields");
|
||||
|
||||
b.HasDiscriminator<string>("field_discrimnator").HasValue("single");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("InternshipSystem.Core.Report", b =>
|
||||
{
|
||||
b.Property<long>("Id")
|
||||
@ -354,18 +395,14 @@ namespace InternshipSystem.Repository.Migrations
|
||||
.HasColumnType("bigint")
|
||||
.HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
|
||||
|
||||
b.Property<int>("Range")
|
||||
.HasColumnName("range")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<string>("SiteAddress")
|
||||
.HasColumnName("site_address")
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<int>("State")
|
||||
.HasColumnName("state")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<string>("Value")
|
||||
.HasColumnName("value")
|
||||
.HasColumnType("jsonb");
|
||||
|
||||
b.HasKey("Id")
|
||||
.HasName("pk_report");
|
||||
|
||||
@ -501,6 +538,36 @@ namespace InternshipSystem.Repository.Migrations
|
||||
b.ToTable("program_subject");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("InternshipSystem.Core.UglyOrmArtifacts.ReportFieldEdition", b =>
|
||||
{
|
||||
b.Property<Guid>("EditionId")
|
||||
.HasColumnName("edition_id")
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.Property<long>("ReportFieldId")
|
||||
.HasColumnName("report_field_id")
|
||||
.HasColumnType("bigint");
|
||||
|
||||
b.HasKey("EditionId", "ReportFieldId")
|
||||
.HasName("pk_report_field_edition");
|
||||
|
||||
b.HasIndex("ReportFieldId")
|
||||
.HasName("ix_report_field_edition_report_field_id");
|
||||
|
||||
b.ToTable("report_field_edition");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("InternshipSystem.Core.Entity.ReportChoiceField", b =>
|
||||
{
|
||||
b.HasBaseType("InternshipSystem.Core.Entity.ReportField");
|
||||
|
||||
b.Property<string>("Choices")
|
||||
.HasColumnName("choices")
|
||||
.HasColumnType("text");
|
||||
|
||||
b.HasDiscriminator().HasValue("choice");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("InternshipSystem.Core.BranchOffice", b =>
|
||||
{
|
||||
b.HasOne("InternshipSystem.Core.Company", null)
|
||||
@ -698,6 +765,23 @@ namespace InternshipSystem.Repository.Migrations
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
});
|
||||
|
||||
modelBuilder.Entity("InternshipSystem.Core.UglyOrmArtifacts.ReportFieldEdition", b =>
|
||||
{
|
||||
b.HasOne("InternshipSystem.Core.Edition", "Edition")
|
||||
.WithMany("ReportSchema")
|
||||
.HasForeignKey("EditionId")
|
||||
.HasConstraintName("fk_report_field_edition_editions_edition_id")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("InternshipSystem.Core.Entity.ReportField", "Field")
|
||||
.WithMany()
|
||||
.HasForeignKey("ReportFieldId")
|
||||
.HasConstraintName("fk_report_field_edition_report_fields_report_field_id")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
});
|
||||
#pragma warning restore 612, 618
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user