diff --git a/BMA.EHR.Report.Service.csproj b/BMA.EHR.Report.Service.csproj index a10b360..598d881 100644 --- a/BMA.EHR.Report.Service.csproj +++ b/BMA.EHR.Report.Service.csproj @@ -1,17 +1,60 @@ - + - - net7.0 - enable - enable - dce859f2-cd46-4149-910b-bea19ed278b2 - Linux - + + net7.0 + enable + enable + dce859f2-cd46-4149-910b-bea19ed278b2 + Linux + True + BMA.EHR.Report.Service + - - - - - + + 1701;1702;1591;0436; + + + + 1701;1702;1591;0436; + + + + + + + + + + + + + + + runtime; build; native; contentfiles; analyzers; buildtransitive + all + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/ConfigureSwaggerOptions.cs b/ConfigureSwaggerOptions.cs new file mode 100644 index 0000000..72a8e06 --- /dev/null +++ b/ConfigureSwaggerOptions.cs @@ -0,0 +1,84 @@ +using Microsoft.AspNetCore.Mvc.ApiExplorer; +using Microsoft.Extensions.Options; +using Microsoft.OpenApi.Models; +using Swashbuckle.AspNetCore.SwaggerGen; +using System.Reflection; + +namespace BMA.EHR.Report.Service +{ + public class ConfigureSwaggerOptions : IConfigureNamedOptions + { + private readonly IApiVersionDescriptionProvider _provider; + + public ConfigureSwaggerOptions( + IApiVersionDescriptionProvider provider) + { + _provider = provider; + } + + public void Configure(SwaggerGenOptions options) + { + // add swagger document for every API version discovered + foreach (var description in _provider.ApiVersionDescriptions) + { + options.EnableAnnotations(); + + options.SwaggerDoc( + description.GroupName, + CreateVersionInfo(description)); + } + + options.AddSecurityDefinition("Bearer", new OpenApiSecurityScheme + { + In = ParameterLocation.Header, + Description = "Please enter a valid token", + Name = "Authorization", + Type = SecuritySchemeType.Http, + BearerFormat = "JWT", + Scheme = "Bearer" + }); + + options.AddSecurityRequirement(new OpenApiSecurityRequirement + { + { + new OpenApiSecurityScheme + { + Reference = new OpenApiReference + { + Type = ReferenceType.SecurityScheme, + Id = "Bearer" + } + }, + new string[]{} + } + }); + + // generate the XML docs that'll drive the swagger docs + var xmlFile = $"{Assembly.GetExecutingAssembly().GetName().Name}.xml"; + var xmlPath = Path.Combine(AppContext.BaseDirectory, xmlFile); + options.IncludeXmlComments(xmlPath); + } + + public void Configure(string name, SwaggerGenOptions options) + { + Configure(options); + } + + private OpenApiInfo CreateVersionInfo( + ApiVersionDescription desc) + { + var info = new OpenApiInfo() + { + Title = "BMA EHR Report Service Document", + Version = desc.ApiVersion.ToString() + }; + + if (desc.IsDeprecated) + { + info.Description += " This API version has been deprecated. Please use one of the new APIs available from the explorer."; + } + + return info; + } + } +} diff --git a/Controllers/BaseController.cs b/Controllers/BaseController.cs new file mode 100644 index 0000000..80b8f8a --- /dev/null +++ b/Controllers/BaseController.cs @@ -0,0 +1,90 @@ +using BMA.EHR.Core; +using BMA.EHR.Report.Service.Responses; +using Microsoft.AspNetCore.Mvc; + +namespace BMA.EHR.Profile.Service.Controllers +{ + public class BaseController : ControllerBase + { + #region " Methods " + + #region " Protected " + + #region " IActionResult " + + protected virtual ActionResult Success(string message, object? result = null) + { + if (result != null) + { + return Ok(new ResponseObject + { + Status = StatusCodes.Status200OK, + Message = message, + Result = result + }); + } + else + { + return Ok(new ResponseObject + { + Status = StatusCodes.Status200OK, + Message = message + }); + } + + } + + protected virtual ActionResult Success(object? result = null) + { + return Success(GlobalMessages.Success, result); + } + + protected virtual ActionResult Error(string message, string result, int statusCode = StatusCodes.Status500InternalServerError) + { + return StatusCode((int)statusCode, new ResponseObject + { + Status = statusCode, + Message = message, + Result = result + }); + } + + protected virtual ActionResult Error(string message, int statusCode = StatusCodes.Status500InternalServerError) + { + return Error(message, message, statusCode); + } + + protected virtual ActionResult Error(Exception exception, string message, int statusCode = StatusCodes.Status500InternalServerError) + { + var msg = exception.Message; + var inner = exception.InnerException; + while (inner != null) + { + msg += $" {inner.Message}\r\n"; + inner = inner.InnerException; + } + + return Error(message, msg, statusCode); + } + + protected virtual ActionResult Error(Exception exception, int statusCode = StatusCodes.Status500InternalServerError) + { + var msg = exception.Message; + var inner = exception.InnerException; + while (inner != null) + { + msg += $" {inner.Message}\r\n"; + inner = inner.InnerException; + } + + return Error(msg, msg, statusCode); + } + + + #endregion + + #endregion + + #endregion + } +} diff --git a/Controllers/RecruitReportController.cs b/Controllers/RecruitReportController.cs new file mode 100644 index 0000000..4ecbd36 --- /dev/null +++ b/Controllers/RecruitReportController.cs @@ -0,0 +1,121 @@ +using BMA.EHR.Extensions; +using BMA.EHR.Profile.Service.Controllers; +using BMA.EHR.Report.Service.Data; +using BMA.EHR.Report.Service.Responses; +using Microsoft.AspNetCore.Authorization; +using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Mvc; +using Microsoft.EntityFrameworkCore; +using Swashbuckle.AspNetCore.Annotations; +using Telerik.Reporting; +using Telerik.Reporting.Processing; + +namespace BMA.EHR.Report.Service.Controllers +{ + [Route("api/v{version:apiVersion}/report/recruit")] + [ApiVersion("1.0")] + [ApiController] + [Produces("application/json")] + [Authorize] + [SwaggerTag("รายงานข้อมูลการสอบแข่งขัน")] + public class RecruitReportController : BaseController + { + #region " Fields " + + private readonly ApplicationDbContext _context; + private readonly IWebHostEnvironment _hostingEnvironment; + private readonly IConfiguration _configuration; + private readonly string space = "ㅤ"; + + #endregion + + #region " Constructor and Destructor " + + public RecruitReportController(ApplicationDbContext context, + IWebHostEnvironment hostingEnvironment, + IConfiguration configuration) + { + this._context = context; + this._hostingEnvironment = hostingEnvironment; + this._configuration = configuration; + } + + #endregion + + #region " Methods " + + /// + /// แสดงหนังสือรับรอง + /// + /// รหัสรอบการสอบ + /// เลขประจำตัวผู้สมัครสอบ + /// + /// เมื่อแสดงรายงานสำเร็จ + /// ค่าตัวแปรที่ส่งมาไม่ถูกต้อง + /// ไม่ได้ Login เข้าระบบ + /// เมื่อเกิดข้อผิดพลาดในการทำงาน + + [HttpGet("certificate/{id:length(36)}/{examId}")] + [ProducesResponseType(StatusCodes.Status200OK)] + [ProducesResponseType(StatusCodes.Status400BadRequest)] + [ProducesResponseType(StatusCodes.Status401Unauthorized)] + [ProducesResponseType(StatusCodes.Status500InternalServerError)] + public async Task> GetPeriodByIdAsync(Guid id, string examId) + { + try + { + var data = await _context.Recruits.AsQueryable() + .Include(x => x.RecruitImport) + .Where(x => x.RecruitImport.Id == id) + .Where(x => x.ExamId == examId) + .Join(_context.RecruitScores.AsQueryable() + .Include(x => x.ScoreImport), + rc => new { rc.RecruitImport.Year, rc.ExamId }, + sc => new { sc.ScoreImport.Year, sc.ExamId }, + (p, sr) => new + { + ExamID = p.ExamId, + p.CitizenId, + Order = p.RecruitImport.Order, + Year = p.RecruitImport.Year, + FullName = $"{p.Prefix}{p.FirstName} {p.LastName}", + ExamResult = sr == null ? "" : sr.ExamStatus, + EndDate = DateTime.Now.ToThaiShortDate2() + + }) + .FirstOrDefaultAsync(); + + var rptFile = Path.Combine(_hostingEnvironment.ContentRootPath, "Report", "Recruit", "rptCertificate.trdp"); + ReportPackager reportPackager = new ReportPackager(); + Telerik.Reporting.Report report = null; + using (var sourceStream = System.IO.File.OpenRead(rptFile)) + { + report = (Telerik.Reporting.Report)reportPackager.UnpackageDocument(sourceStream); + } + + report.DataSource = data; + System.Collections.Hashtable deviceInfo = new System.Collections.Hashtable(); + + InstanceReportSource instanceReportSource = new InstanceReportSource() + { + ReportDocument = report + }; + + + ReportProcessor reportProcessor = new ReportProcessor(_configuration); + RenderingResult result = reportProcessor.RenderReport("PDF", instanceReportSource, deviceInfo); + + var content = result.DocumentBytes; + return File(content, "application/pdf", $"หนังสือรับรอง_{data.CitizenId}_{data.FullName}.pdf"); + + } + catch (Exception ex) + { + return Error(ex, "เกิดข้อผิดพลาดในการแสดงรายงาน"); + } + } + + + #endregion + } +} diff --git a/Controllers/WeatherForecastController.cs b/Controllers/WeatherForecastController.cs deleted file mode 100644 index 353d7d5..0000000 --- a/Controllers/WeatherForecastController.cs +++ /dev/null @@ -1,33 +0,0 @@ -using Microsoft.AspNetCore.Mvc; - -namespace BMA.EHR.Report.Service.Controllers -{ - [ApiController] - [Route("[controller]")] - public class WeatherForecastController : ControllerBase - { - private static readonly string[] Summaries = new[] - { - "Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching" - }; - - private readonly ILogger _logger; - - public WeatherForecastController(ILogger logger) - { - _logger = logger; - } - - [HttpGet(Name = "GetWeatherForecast")] - public IEnumerable Get() - { - return Enumerable.Range(1, 5).Select(index => new WeatherForecast - { - Date = DateOnly.FromDateTime(DateTime.Now.AddDays(index)), - TemperatureC = Random.Shared.Next(-20, 55), - Summary = Summaries[Random.Shared.Next(Summaries.Length)] - }) - .ToArray(); - } - } -} \ No newline at end of file diff --git a/Data/ApplicationDbContext.cs b/Data/ApplicationDbContext.cs new file mode 100644 index 0000000..78f6a1a --- /dev/null +++ b/Data/ApplicationDbContext.cs @@ -0,0 +1,56 @@ +using BMA.EHR.Recruit.Service.Models.Documents; +using BMA.EHR.Recruit.Service.Models.Recruits; +using Microsoft.EntityFrameworkCore; + +namespace BMA.EHR.Report.Service.Data +{ + public class ApplicationDbContext : DbContext + { + public ApplicationDbContext(DbContextOptions options) + : base(options) + { + } + + protected override void OnModelCreating(ModelBuilder modelBuilder) + { + //base.OnModelCreating(modelBuilder); + + //modelBuilder.Ignore(); + //modelBuilder.Ignore(); + //modelBuilder.Ignore(); + //modelBuilder.Ignore(); + //modelBuilder.Ignore(); + //modelBuilder.Ignore(); + //modelBuilder.Ignore(); + //modelBuilder.Ignore(); + //modelBuilder.Ignore(); + //modelBuilder.Ignore(); + //modelBuilder.Ignore(); + //modelBuilder.Ignore(); + } + + public DbSet Documents { get; set; } + + public DbSet RecruitImports { get; set; } + + public DbSet Recruits { get; set; } + + public DbSet RecruitAddresses { get; set; } + + public DbSet RecruitOccupations { get; set; } + + public DbSet RecruitCertificates { get; set; } + + public DbSet RecruitEducations { get; set; } + + public DbSet ScoreImports { get; set; } + + public DbSet RecruitScores { get; set; } + + public DbSet RecruitPayments { get; set; } + + public DbSet RecruitDocuments { get; set; } + + public DbSet RecruitImportHistories { get; set; } + } +} diff --git a/Migrations/20230417135602_Init.Designer.cs b/Migrations/20230417135602_Init.Designer.cs new file mode 100644 index 0000000..ef65a78 --- /dev/null +++ b/Migrations/20230417135602_Init.Designer.cs @@ -0,0 +1,26 @@ +// +using BMA.EHR.Report.Service.Data; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; + +#nullable disable + +namespace BMA.EHR.Report.Service.Migrations +{ + [DbContext(typeof(ApplicationDbContext))] + [Migration("20230417135602_Init")] + partial class Init + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "7.0.5") + .HasAnnotation("Relational:MaxIdentifierLength", 64); +#pragma warning restore 612, 618 + } + } +} diff --git a/Migrations/20230417135602_Init.cs b/Migrations/20230417135602_Init.cs new file mode 100644 index 0000000..772a128 --- /dev/null +++ b/Migrations/20230417135602_Init.cs @@ -0,0 +1,23 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace BMA.EHR.Report.Service.Migrations +{ + /// + public partial class Init : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.AlterDatabase() + .Annotation("MySql:CharSet", "utf8mb4"); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + + } + } +} diff --git a/Migrations/20230417141222_Init2.Designer.cs b/Migrations/20230417141222_Init2.Designer.cs new file mode 100644 index 0000000..9958c3d --- /dev/null +++ b/Migrations/20230417141222_Init2.Designer.cs @@ -0,0 +1,1284 @@ +// +using System; +using BMA.EHR.Report.Service.Data; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; + +#nullable disable + +namespace BMA.EHR.Report.Service.Migrations +{ + [DbContext(typeof(ApplicationDbContext))] + [Migration("20230417141222_Init2")] + partial class Init2 + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "7.0.5") + .HasAnnotation("Relational:MaxIdentifierLength", 64); + + modelBuilder.Entity("BMA.EHR.Recruit.Service.Models.Documents.Document", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("CreatedDate") + .HasColumnType("datetime(6)"); + + b.Property("Detail") + .IsRequired() + .HasColumnType("text"); + + b.Property("FileName") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("varchar(255)"); + + b.Property("FileSize") + .HasColumnType("int"); + + b.Property("FileType") + .IsRequired() + .HasMaxLength(128) + .HasColumnType("varchar(128)"); + + b.Property("ObjectRefId") + .HasColumnType("char(36)"); + + b.HasKey("Id"); + + b.ToTable("Documents"); + }); + + modelBuilder.Entity("BMA.EHR.Recruit.Service.Models.Recruits.Recruit", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)") + .HasColumnOrder(0) + .HasComment("PrimaryKey") + .HasAnnotation("Relational:JsonPropertyName", "id"); + + b.Property("ApplyDate") + .HasColumnType("datetime(6)"); + + b.Property("CitizenCardExpireDate") + .HasColumnType("datetime(6)"); + + b.Property("CitizenCardIssuer") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)"); + + b.Property("CitizenId") + .IsRequired() + .HasMaxLength(13) + .HasColumnType("varchar(13)") + .HasComment("เลขประจำตัวประชาชน"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(100) + .HasComment("สร้างข้อมูลเมื่อ"); + + b.Property("CreatedDate") + .HasColumnType("datetime(6)"); + + b.Property("CreatedFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(104) + .HasComment("ชื่อ User ที่สร้างข้อมูล"); + + b.Property("CreatedUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(101) + .HasComment("User Id ที่สร้างข้อมูล"); + + b.Property("DateOfBirth") + .HasColumnType("datetime(6)"); + + b.Property("ExamId") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("varchar(50)"); + + b.Property("FirstName") + .IsRequired() + .HasMaxLength(150) + .HasColumnType("varchar(150)"); + + b.Property("Gendor") + .IsRequired() + .HasMaxLength(20) + .HasColumnType("varchar(20)"); + + b.Property("Isspecial") + .IsRequired() + .HasMaxLength(1) + .HasColumnType("varchar(1)"); + + b.Property("LastName") + .IsRequired() + .HasMaxLength(150) + .HasColumnType("varchar(150)"); + + b.Property("LastUpdateFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(105) + .HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdateUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(103) + .HasComment("User Id ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(102) + .HasComment("แก้ไขข้อมูลล่าสุดเมื่อ"); + + b.Property("Marry") + .IsRequired() + .HasMaxLength(20) + .HasColumnType("varchar(20)"); + + b.Property("ModifiedDate") + .HasColumnType("datetime(6)"); + + b.Property("National") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)"); + + b.Property("Prefix") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("varchar(50)"); + + b.Property("Qualified") + .IsRequired() + .HasMaxLength(1) + .HasColumnType("varchar(1)"); + + b.Property("Race") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)"); + + b.Property("RecruitImportId") + .HasColumnType("char(36)"); + + b.Property("RefNo") + .IsRequired() + .HasMaxLength(20) + .HasColumnType("varchar(20)"); + + b.Property("Religion") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)"); + + b.Property("Remark") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)"); + + b.HasKey("Id"); + + b.HasIndex("RecruitImportId"); + + b.ToTable("Recruits"); + }); + + modelBuilder.Entity("BMA.EHR.Recruit.Service.Models.Recruits.RecruitAddress", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)") + .HasColumnOrder(0) + .HasComment("PrimaryKey") + .HasAnnotation("Relational:JsonPropertyName", "id"); + + b.Property("Address") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)"); + + b.Property("Address1") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)"); + + b.Property("Amphur") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)"); + + b.Property("Amphur1") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(100) + .HasComment("สร้างข้อมูลเมื่อ"); + + b.Property("CreatedFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(104) + .HasComment("ชื่อ User ที่สร้างข้อมูล"); + + b.Property("CreatedUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(101) + .HasComment("User Id ที่สร้างข้อมูล"); + + b.Property("District") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)"); + + b.Property("District1") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)"); + + b.Property("LastUpdateFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(105) + .HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdateUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(103) + .HasComment("User Id ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(102) + .HasComment("แก้ไขข้อมูลล่าสุดเมื่อ"); + + b.Property("Mobile") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)"); + + b.Property("Moo") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)"); + + b.Property("Moo1") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)"); + + b.Property("Province") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)"); + + b.Property("Province1") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)"); + + b.Property("RecruitId") + .HasColumnType("char(36)"); + + b.Property("Road") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)"); + + b.Property("Road1") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)"); + + b.Property("Soi") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)"); + + b.Property("Soi1") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)"); + + b.Property("Telephone") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)"); + + b.Property("ZipCode") + .IsRequired() + .HasMaxLength(5) + .HasColumnType("varchar(5)"); + + b.Property("ZipCode1") + .IsRequired() + .HasMaxLength(5) + .HasColumnType("varchar(5)"); + + b.HasKey("Id"); + + b.HasIndex("RecruitId"); + + b.ToTable("RecruitAddresses"); + }); + + modelBuilder.Entity("BMA.EHR.Recruit.Service.Models.Recruits.RecruitCertificate", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)") + .HasColumnOrder(0) + .HasComment("PrimaryKey") + .HasAnnotation("Relational:JsonPropertyName", "id"); + + b.Property("CertificateNo") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("varchar(50)"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(100) + .HasComment("สร้างข้อมูลเมื่อ"); + + b.Property("CreatedFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(104) + .HasComment("ชื่อ User ที่สร้างข้อมูล"); + + b.Property("CreatedUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(101) + .HasComment("User Id ที่สร้างข้อมูล"); + + b.Property("Description") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)"); + + b.Property("ExpiredDate") + .HasColumnType("datetime(6)"); + + b.Property("IssueDate") + .HasColumnType("datetime(6)"); + + b.Property("LastUpdateFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(105) + .HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdateUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(103) + .HasComment("User Id ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(102) + .HasComment("แก้ไขข้อมูลล่าสุดเมื่อ"); + + b.Property("RecruitId") + .HasColumnType("char(36)"); + + b.HasKey("Id"); + + b.HasIndex("RecruitId"); + + b.ToTable("RecruitCertificates"); + }); + + modelBuilder.Entity("BMA.EHR.Recruit.Service.Models.Recruits.RecruitDocument", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)") + .HasColumnOrder(0) + .HasComment("PrimaryKey") + .HasAnnotation("Relational:JsonPropertyName", "id"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(100) + .HasComment("สร้างข้อมูลเมื่อ"); + + b.Property("CreatedDate") + .HasColumnType("datetime(6)"); + + b.Property("CreatedFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(104) + .HasComment("ชื่อ User ที่สร้างข้อมูล"); + + b.Property("CreatedUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(101) + .HasComment("User Id ที่สร้างข้อมูล"); + + b.Property("DocumentFileId") + .HasColumnType("char(36)"); + + b.Property("LastUpdateFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(105) + .HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdateUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(103) + .HasComment("User Id ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(102) + .HasComment("แก้ไขข้อมูลล่าสุดเมื่อ"); + + b.Property("RecruitId") + .HasColumnType("char(36)"); + + b.HasKey("Id"); + + b.HasIndex("DocumentFileId"); + + b.HasIndex("RecruitId"); + + b.ToTable("RecruitDocuments"); + }); + + modelBuilder.Entity("BMA.EHR.Recruit.Service.Models.Recruits.RecruitEducation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)") + .HasColumnOrder(0) + .HasComment("PrimaryKey") + .HasAnnotation("Relational:JsonPropertyName", "id"); + + b.Property("BachelorDate") + .HasColumnType("datetime(6)"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(100) + .HasComment("สร้างข้อมูลเมื่อ"); + + b.Property("CreatedFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(104) + .HasComment("ชื่อ User ที่สร้างข้อมูล"); + + b.Property("CreatedUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(101) + .HasComment("User Id ที่สร้างข้อมูล"); + + b.Property("Degree") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)"); + + b.Property("GPA") + .HasColumnType("double"); + + b.Property("HighDegree") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)"); + + b.Property("LastUpdateFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(105) + .HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdateUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(103) + .HasComment("User Id ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(102) + .HasComment("แก้ไขข้อมูลล่าสุดเมื่อ"); + + b.Property("Major") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)"); + + b.Property("MajorGroupId") + .IsRequired() + .HasMaxLength(20) + .HasColumnType("varchar(20)"); + + b.Property("MajorGroupName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)"); + + b.Property("RecruitId") + .HasColumnType("char(36)"); + + b.Property("Specialist") + .IsRequired() + .HasMaxLength(1000) + .HasColumnType("varchar(1000)"); + + b.Property("University") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)"); + + b.HasKey("Id"); + + b.HasIndex("RecruitId"); + + b.ToTable("RecruitEducations"); + }); + + modelBuilder.Entity("BMA.EHR.Recruit.Service.Models.Recruits.RecruitImport", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)") + .HasColumnOrder(0) + .HasComment("PrimaryKey") + .HasAnnotation("Relational:JsonPropertyName", "id"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(100) + .HasComment("สร้างข้อมูลเมื่อ"); + + b.Property("CreatedFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(104) + .HasComment("ชื่อ User ที่สร้างข้อมูล"); + + b.Property("CreatedUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(101) + .HasComment("User Id ที่สร้างข้อมูล"); + + b.Property("ImportFileId") + .HasColumnType("char(36)"); + + b.Property("LastUpdateFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(105) + .HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdateUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(103) + .HasComment("User Id ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(102) + .HasComment("แก้ไขข้อมูลล่าสุดเมื่อ"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(250) + .HasColumnType("varchar(250)") + .HasColumnOrder(2) + .HasComment("ชื่อการสอบ"); + + b.Property("Order") + .HasColumnType("int") + .HasColumnOrder(3) + .HasComment("ครั้งที่"); + + b.Property("Year") + .HasColumnType("int") + .HasColumnOrder(1) + .HasComment("ปีที่จัดการสอบ"); + + b.HasKey("Id"); + + b.HasIndex("ImportFileId"); + + b.ToTable("RecruitImports"); + }); + + modelBuilder.Entity("BMA.EHR.Recruit.Service.Models.Recruits.RecruitImportHistory", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)") + .HasColumnOrder(0) + .HasComment("PrimaryKey") + .HasAnnotation("Relational:JsonPropertyName", "id"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(100) + .HasComment("สร้างข้อมูลเมื่อ"); + + b.Property("CreatedFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(104) + .HasComment("ชื่อ User ที่สร้างข้อมูล"); + + b.Property("CreatedUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(101) + .HasComment("User Id ที่สร้างข้อมูล"); + + b.Property("Description") + .IsRequired() + .HasColumnType("longtext") + .HasColumnOrder(1) + .HasComment("รายละเอียดการนำเข้า"); + + b.Property("LastUpdateFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(105) + .HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdateUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(103) + .HasComment("User Id ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(102) + .HasComment("แก้ไขข้อมูลล่าสุดเมื่อ"); + + b.Property("RecruitImportId") + .HasColumnType("char(36)"); + + b.HasKey("Id"); + + b.HasIndex("RecruitImportId"); + + b.ToTable("RecruitImportHistories"); + }); + + modelBuilder.Entity("BMA.EHR.Recruit.Service.Models.Recruits.RecruitOccupation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)") + .HasColumnOrder(0) + .HasComment("PrimaryKey") + .HasAnnotation("Relational:JsonPropertyName", "id"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(100) + .HasComment("สร้างข้อมูลเมื่อ"); + + b.Property("CreatedFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(104) + .HasComment("ชื่อ User ที่สร้างข้อมูล"); + + b.Property("CreatedUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(101) + .HasComment("User Id ที่สร้างข้อมูล"); + + b.Property("LastUpdateFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(105) + .HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdateUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(103) + .HasComment("User Id ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(102) + .HasComment("แก้ไขข้อมูลล่าสุดเมื่อ"); + + b.Property("Occupation") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)"); + + b.Property("Position") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)"); + + b.Property("RecruitId") + .HasColumnType("char(36)"); + + b.Property("Telephone") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)"); + + b.Property("WorkAge") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)"); + + b.Property("Workplace") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)"); + + b.HasKey("Id"); + + b.HasIndex("RecruitId"); + + b.ToTable("RecruitOccupations"); + }); + + modelBuilder.Entity("BMA.EHR.Recruit.Service.Models.Recruits.RecruitPayment", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)") + .HasColumnOrder(0) + .HasComment("PrimaryKey") + .HasAnnotation("Relational:JsonPropertyName", "id"); + + b.Property("AccountNumber") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("varchar(50)"); + + b.Property("Amount") + .HasColumnType("decimal(65,30)"); + + b.Property("BankCode") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("varchar(50)"); + + b.Property("ChequeNo") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("varchar(50)"); + + b.Property("ChqueBankCode") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("varchar(50)"); + + b.Property("CompanyCode") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("varchar(50)"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(100) + .HasComment("สร้างข้อมูลเมื่อ"); + + b.Property("CreatedFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(104) + .HasComment("ชื่อ User ที่สร้างข้อมูล"); + + b.Property("CreatedUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(101) + .HasComment("User Id ที่สร้างข้อมูล"); + + b.Property("CreditDebit") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("varchar(50)"); + + b.Property("CustomerName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)"); + + b.Property("LastUpdateFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(105) + .HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdateUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(103) + .HasComment("User Id ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(102) + .HasComment("แก้ไขข้อมูลล่าสุดเมื่อ"); + + b.Property("PaymentId") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("varchar(50)"); + + b.Property("PaymentType") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("varchar(50)"); + + b.Property("RecruitId") + .HasColumnType("char(36)"); + + b.Property("RefNo1") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("varchar(50)"); + + b.Property("TellerId") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("varchar(50)"); + + b.Property("TermBranch") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("varchar(50)"); + + b.Property("TextFile") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("varchar(50)"); + + b.Property("TransDate") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("varchar(50)"); + + b.Property("TransTime") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("varchar(50)"); + + b.HasKey("Id"); + + b.HasIndex("RecruitId"); + + b.ToTable("RecruitPayments"); + }); + + modelBuilder.Entity("BMA.EHR.Recruit.Service.Models.Recruits.RecruitScore", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)") + .HasColumnOrder(0) + .HasComment("PrimaryKey") + .HasAnnotation("Relational:JsonPropertyName", "id"); + + b.Property("ABStatus") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("varchar(50)"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(100) + .HasComment("สร้างข้อมูลเมื่อ"); + + b.Property("CreatedFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(104) + .HasComment("ชื่อ User ที่สร้างข้อมูล"); + + b.Property("CreatedUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(101) + .HasComment("User Id ที่สร้างข้อมูล"); + + b.Property("ExamId") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("varchar(50)"); + + b.Property("ExamStatus") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("varchar(50)"); + + b.Property("FullA") + .HasColumnType("int"); + + b.Property("FullB") + .HasColumnType("int"); + + b.Property("FullC") + .HasColumnType("int"); + + b.Property("LastUpdateFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(105) + .HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdateUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(103) + .HasComment("User Id ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(102) + .HasComment("แก้ไขข้อมูลล่าสุดเมื่อ"); + + b.Property("Major") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)"); + + b.Property("PercentageA") + .HasColumnType("double"); + + b.Property("PercentageB") + .HasColumnType("double"); + + b.Property("PercentageC") + .HasColumnType("double"); + + b.Property("ScoreImportId") + .HasColumnType("char(36)"); + + b.Property("SumA") + .HasColumnType("int"); + + b.Property("SumAB") + .HasColumnType("int"); + + b.Property("SumB") + .HasColumnType("int"); + + b.Property("SumC") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("ScoreImportId"); + + b.ToTable("RecruitScores"); + }); + + modelBuilder.Entity("BMA.EHR.Recruit.Service.Models.Recruits.ScoreImport", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)") + .HasColumnOrder(0) + .HasComment("PrimaryKey") + .HasAnnotation("Relational:JsonPropertyName", "id"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(100) + .HasComment("สร้างข้อมูลเมื่อ"); + + b.Property("CreatedFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(104) + .HasComment("ชื่อ User ที่สร้างข้อมูล"); + + b.Property("CreatedUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(101) + .HasComment("User Id ที่สร้างข้อมูล"); + + b.Property("ImportFileId") + .HasColumnType("char(36)"); + + b.Property("LastUpdateFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(105) + .HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdateUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(103) + .HasComment("User Id ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(102) + .HasComment("แก้ไขข้อมูลล่าสุดเมื่อ"); + + b.Property("RecruitImportId") + .HasColumnType("char(36)"); + + b.Property("Year") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("ImportFileId"); + + b.HasIndex("RecruitImportId") + .IsUnique(); + + b.ToTable("ScoreImports"); + }); + + modelBuilder.Entity("BMA.EHR.Recruit.Service.Models.Recruits.Recruit", b => + { + b.HasOne("BMA.EHR.Recruit.Service.Models.Recruits.RecruitImport", "RecruitImport") + .WithMany("Recruits") + .HasForeignKey("RecruitImportId"); + + b.Navigation("RecruitImport"); + }); + + modelBuilder.Entity("BMA.EHR.Recruit.Service.Models.Recruits.RecruitAddress", b => + { + b.HasOne("BMA.EHR.Recruit.Service.Models.Recruits.Recruit", "Recruit") + .WithMany("Addresses") + .HasForeignKey("RecruitId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Recruit"); + }); + + modelBuilder.Entity("BMA.EHR.Recruit.Service.Models.Recruits.RecruitCertificate", b => + { + b.HasOne("BMA.EHR.Recruit.Service.Models.Recruits.Recruit", "Recruit") + .WithMany("Certificates") + .HasForeignKey("RecruitId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Recruit"); + }); + + modelBuilder.Entity("BMA.EHR.Recruit.Service.Models.Recruits.RecruitDocument", b => + { + b.HasOne("BMA.EHR.Recruit.Service.Models.Documents.Document", "DocumentFile") + .WithMany() + .HasForeignKey("DocumentFileId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("BMA.EHR.Recruit.Service.Models.Recruits.Recruit", "Recruit") + .WithMany("Documents") + .HasForeignKey("RecruitId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("DocumentFile"); + + b.Navigation("Recruit"); + }); + + modelBuilder.Entity("BMA.EHR.Recruit.Service.Models.Recruits.RecruitEducation", b => + { + b.HasOne("BMA.EHR.Recruit.Service.Models.Recruits.Recruit", "Recruit") + .WithMany("Educations") + .HasForeignKey("RecruitId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Recruit"); + }); + + modelBuilder.Entity("BMA.EHR.Recruit.Service.Models.Recruits.RecruitImport", b => + { + b.HasOne("BMA.EHR.Recruit.Service.Models.Documents.Document", "ImportFile") + .WithMany() + .HasForeignKey("ImportFileId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("ImportFile"); + }); + + modelBuilder.Entity("BMA.EHR.Recruit.Service.Models.Recruits.RecruitImportHistory", b => + { + b.HasOne("BMA.EHR.Recruit.Service.Models.Recruits.RecruitImport", "RecruitImport") + .WithMany("ImportHostories") + .HasForeignKey("RecruitImportId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("RecruitImport"); + }); + + modelBuilder.Entity("BMA.EHR.Recruit.Service.Models.Recruits.RecruitOccupation", b => + { + b.HasOne("BMA.EHR.Recruit.Service.Models.Recruits.Recruit", "Recruit") + .WithMany("Occupations") + .HasForeignKey("RecruitId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Recruit"); + }); + + modelBuilder.Entity("BMA.EHR.Recruit.Service.Models.Recruits.RecruitPayment", b => + { + b.HasOne("BMA.EHR.Recruit.Service.Models.Recruits.Recruit", "Recruit") + .WithMany("Payments") + .HasForeignKey("RecruitId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Recruit"); + }); + + modelBuilder.Entity("BMA.EHR.Recruit.Service.Models.Recruits.RecruitScore", b => + { + b.HasOne("BMA.EHR.Recruit.Service.Models.Recruits.ScoreImport", "ScoreImport") + .WithMany("Scores") + .HasForeignKey("ScoreImportId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("ScoreImport"); + }); + + modelBuilder.Entity("BMA.EHR.Recruit.Service.Models.Recruits.ScoreImport", b => + { + b.HasOne("BMA.EHR.Recruit.Service.Models.Documents.Document", "ImportFile") + .WithMany() + .HasForeignKey("ImportFileId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("BMA.EHR.Recruit.Service.Models.Recruits.RecruitImport", "RecruitImport") + .WithOne("ScoreImport") + .HasForeignKey("BMA.EHR.Recruit.Service.Models.Recruits.ScoreImport", "RecruitImportId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("ImportFile"); + + b.Navigation("RecruitImport"); + }); + + modelBuilder.Entity("BMA.EHR.Recruit.Service.Models.Recruits.Recruit", b => + { + b.Navigation("Addresses"); + + b.Navigation("Certificates"); + + b.Navigation("Documents"); + + b.Navigation("Educations"); + + b.Navigation("Occupations"); + + b.Navigation("Payments"); + }); + + modelBuilder.Entity("BMA.EHR.Recruit.Service.Models.Recruits.RecruitImport", b => + { + b.Navigation("ImportHostories"); + + b.Navigation("Recruits"); + + b.Navigation("ScoreImport") + .IsRequired(); + }); + + modelBuilder.Entity("BMA.EHR.Recruit.Service.Models.Recruits.ScoreImport", b => + { + b.Navigation("Scores"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/Migrations/20230417141222_Init2.cs b/Migrations/20230417141222_Init2.cs new file mode 100644 index 0000000..5025373 --- /dev/null +++ b/Migrations/20230417141222_Init2.cs @@ -0,0 +1,22 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace BMA.EHR.Report.Service.Migrations +{ + /// + public partial class Init2 : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + + } + } +} diff --git a/Migrations/ApplicationDbContextModelSnapshot.cs b/Migrations/ApplicationDbContextModelSnapshot.cs new file mode 100644 index 0000000..04cbb3f --- /dev/null +++ b/Migrations/ApplicationDbContextModelSnapshot.cs @@ -0,0 +1,1281 @@ +// +using System; +using BMA.EHR.Report.Service.Data; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; + +#nullable disable + +namespace BMA.EHR.Report.Service.Migrations +{ + [DbContext(typeof(ApplicationDbContext))] + partial class ApplicationDbContextModelSnapshot : ModelSnapshot + { + protected override void BuildModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "7.0.5") + .HasAnnotation("Relational:MaxIdentifierLength", 64); + + modelBuilder.Entity("BMA.EHR.Recruit.Service.Models.Documents.Document", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("CreatedDate") + .HasColumnType("datetime(6)"); + + b.Property("Detail") + .IsRequired() + .HasColumnType("text"); + + b.Property("FileName") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("varchar(255)"); + + b.Property("FileSize") + .HasColumnType("int"); + + b.Property("FileType") + .IsRequired() + .HasMaxLength(128) + .HasColumnType("varchar(128)"); + + b.Property("ObjectRefId") + .HasColumnType("char(36)"); + + b.HasKey("Id"); + + b.ToTable("Documents"); + }); + + modelBuilder.Entity("BMA.EHR.Recruit.Service.Models.Recruits.Recruit", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)") + .HasColumnOrder(0) + .HasComment("PrimaryKey") + .HasAnnotation("Relational:JsonPropertyName", "id"); + + b.Property("ApplyDate") + .HasColumnType("datetime(6)"); + + b.Property("CitizenCardExpireDate") + .HasColumnType("datetime(6)"); + + b.Property("CitizenCardIssuer") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)"); + + b.Property("CitizenId") + .IsRequired() + .HasMaxLength(13) + .HasColumnType("varchar(13)") + .HasComment("เลขประจำตัวประชาชน"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(100) + .HasComment("สร้างข้อมูลเมื่อ"); + + b.Property("CreatedDate") + .HasColumnType("datetime(6)"); + + b.Property("CreatedFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(104) + .HasComment("ชื่อ User ที่สร้างข้อมูล"); + + b.Property("CreatedUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(101) + .HasComment("User Id ที่สร้างข้อมูล"); + + b.Property("DateOfBirth") + .HasColumnType("datetime(6)"); + + b.Property("ExamId") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("varchar(50)"); + + b.Property("FirstName") + .IsRequired() + .HasMaxLength(150) + .HasColumnType("varchar(150)"); + + b.Property("Gendor") + .IsRequired() + .HasMaxLength(20) + .HasColumnType("varchar(20)"); + + b.Property("Isspecial") + .IsRequired() + .HasMaxLength(1) + .HasColumnType("varchar(1)"); + + b.Property("LastName") + .IsRequired() + .HasMaxLength(150) + .HasColumnType("varchar(150)"); + + b.Property("LastUpdateFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(105) + .HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdateUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(103) + .HasComment("User Id ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(102) + .HasComment("แก้ไขข้อมูลล่าสุดเมื่อ"); + + b.Property("Marry") + .IsRequired() + .HasMaxLength(20) + .HasColumnType("varchar(20)"); + + b.Property("ModifiedDate") + .HasColumnType("datetime(6)"); + + b.Property("National") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)"); + + b.Property("Prefix") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("varchar(50)"); + + b.Property("Qualified") + .IsRequired() + .HasMaxLength(1) + .HasColumnType("varchar(1)"); + + b.Property("Race") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)"); + + b.Property("RecruitImportId") + .HasColumnType("char(36)"); + + b.Property("RefNo") + .IsRequired() + .HasMaxLength(20) + .HasColumnType("varchar(20)"); + + b.Property("Religion") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)"); + + b.Property("Remark") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)"); + + b.HasKey("Id"); + + b.HasIndex("RecruitImportId"); + + b.ToTable("Recruits"); + }); + + modelBuilder.Entity("BMA.EHR.Recruit.Service.Models.Recruits.RecruitAddress", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)") + .HasColumnOrder(0) + .HasComment("PrimaryKey") + .HasAnnotation("Relational:JsonPropertyName", "id"); + + b.Property("Address") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)"); + + b.Property("Address1") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)"); + + b.Property("Amphur") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)"); + + b.Property("Amphur1") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(100) + .HasComment("สร้างข้อมูลเมื่อ"); + + b.Property("CreatedFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(104) + .HasComment("ชื่อ User ที่สร้างข้อมูล"); + + b.Property("CreatedUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(101) + .HasComment("User Id ที่สร้างข้อมูล"); + + b.Property("District") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)"); + + b.Property("District1") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)"); + + b.Property("LastUpdateFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(105) + .HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdateUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(103) + .HasComment("User Id ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(102) + .HasComment("แก้ไขข้อมูลล่าสุดเมื่อ"); + + b.Property("Mobile") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)"); + + b.Property("Moo") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)"); + + b.Property("Moo1") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)"); + + b.Property("Province") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)"); + + b.Property("Province1") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)"); + + b.Property("RecruitId") + .HasColumnType("char(36)"); + + b.Property("Road") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)"); + + b.Property("Road1") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)"); + + b.Property("Soi") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)"); + + b.Property("Soi1") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)"); + + b.Property("Telephone") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)"); + + b.Property("ZipCode") + .IsRequired() + .HasMaxLength(5) + .HasColumnType("varchar(5)"); + + b.Property("ZipCode1") + .IsRequired() + .HasMaxLength(5) + .HasColumnType("varchar(5)"); + + b.HasKey("Id"); + + b.HasIndex("RecruitId"); + + b.ToTable("RecruitAddresses"); + }); + + modelBuilder.Entity("BMA.EHR.Recruit.Service.Models.Recruits.RecruitCertificate", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)") + .HasColumnOrder(0) + .HasComment("PrimaryKey") + .HasAnnotation("Relational:JsonPropertyName", "id"); + + b.Property("CertificateNo") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("varchar(50)"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(100) + .HasComment("สร้างข้อมูลเมื่อ"); + + b.Property("CreatedFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(104) + .HasComment("ชื่อ User ที่สร้างข้อมูล"); + + b.Property("CreatedUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(101) + .HasComment("User Id ที่สร้างข้อมูล"); + + b.Property("Description") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)"); + + b.Property("ExpiredDate") + .HasColumnType("datetime(6)"); + + b.Property("IssueDate") + .HasColumnType("datetime(6)"); + + b.Property("LastUpdateFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(105) + .HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdateUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(103) + .HasComment("User Id ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(102) + .HasComment("แก้ไขข้อมูลล่าสุดเมื่อ"); + + b.Property("RecruitId") + .HasColumnType("char(36)"); + + b.HasKey("Id"); + + b.HasIndex("RecruitId"); + + b.ToTable("RecruitCertificates"); + }); + + modelBuilder.Entity("BMA.EHR.Recruit.Service.Models.Recruits.RecruitDocument", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)") + .HasColumnOrder(0) + .HasComment("PrimaryKey") + .HasAnnotation("Relational:JsonPropertyName", "id"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(100) + .HasComment("สร้างข้อมูลเมื่อ"); + + b.Property("CreatedDate") + .HasColumnType("datetime(6)"); + + b.Property("CreatedFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(104) + .HasComment("ชื่อ User ที่สร้างข้อมูล"); + + b.Property("CreatedUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(101) + .HasComment("User Id ที่สร้างข้อมูล"); + + b.Property("DocumentFileId") + .HasColumnType("char(36)"); + + b.Property("LastUpdateFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(105) + .HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdateUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(103) + .HasComment("User Id ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(102) + .HasComment("แก้ไขข้อมูลล่าสุดเมื่อ"); + + b.Property("RecruitId") + .HasColumnType("char(36)"); + + b.HasKey("Id"); + + b.HasIndex("DocumentFileId"); + + b.HasIndex("RecruitId"); + + b.ToTable("RecruitDocuments"); + }); + + modelBuilder.Entity("BMA.EHR.Recruit.Service.Models.Recruits.RecruitEducation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)") + .HasColumnOrder(0) + .HasComment("PrimaryKey") + .HasAnnotation("Relational:JsonPropertyName", "id"); + + b.Property("BachelorDate") + .HasColumnType("datetime(6)"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(100) + .HasComment("สร้างข้อมูลเมื่อ"); + + b.Property("CreatedFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(104) + .HasComment("ชื่อ User ที่สร้างข้อมูล"); + + b.Property("CreatedUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(101) + .HasComment("User Id ที่สร้างข้อมูล"); + + b.Property("Degree") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)"); + + b.Property("GPA") + .HasColumnType("double"); + + b.Property("HighDegree") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)"); + + b.Property("LastUpdateFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(105) + .HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdateUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(103) + .HasComment("User Id ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(102) + .HasComment("แก้ไขข้อมูลล่าสุดเมื่อ"); + + b.Property("Major") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)"); + + b.Property("MajorGroupId") + .IsRequired() + .HasMaxLength(20) + .HasColumnType("varchar(20)"); + + b.Property("MajorGroupName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)"); + + b.Property("RecruitId") + .HasColumnType("char(36)"); + + b.Property("Specialist") + .IsRequired() + .HasMaxLength(1000) + .HasColumnType("varchar(1000)"); + + b.Property("University") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)"); + + b.HasKey("Id"); + + b.HasIndex("RecruitId"); + + b.ToTable("RecruitEducations"); + }); + + modelBuilder.Entity("BMA.EHR.Recruit.Service.Models.Recruits.RecruitImport", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)") + .HasColumnOrder(0) + .HasComment("PrimaryKey") + .HasAnnotation("Relational:JsonPropertyName", "id"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(100) + .HasComment("สร้างข้อมูลเมื่อ"); + + b.Property("CreatedFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(104) + .HasComment("ชื่อ User ที่สร้างข้อมูล"); + + b.Property("CreatedUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(101) + .HasComment("User Id ที่สร้างข้อมูล"); + + b.Property("ImportFileId") + .HasColumnType("char(36)"); + + b.Property("LastUpdateFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(105) + .HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdateUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(103) + .HasComment("User Id ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(102) + .HasComment("แก้ไขข้อมูลล่าสุดเมื่อ"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(250) + .HasColumnType("varchar(250)") + .HasColumnOrder(2) + .HasComment("ชื่อการสอบ"); + + b.Property("Order") + .HasColumnType("int") + .HasColumnOrder(3) + .HasComment("ครั้งที่"); + + b.Property("Year") + .HasColumnType("int") + .HasColumnOrder(1) + .HasComment("ปีที่จัดการสอบ"); + + b.HasKey("Id"); + + b.HasIndex("ImportFileId"); + + b.ToTable("RecruitImports"); + }); + + modelBuilder.Entity("BMA.EHR.Recruit.Service.Models.Recruits.RecruitImportHistory", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)") + .HasColumnOrder(0) + .HasComment("PrimaryKey") + .HasAnnotation("Relational:JsonPropertyName", "id"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(100) + .HasComment("สร้างข้อมูลเมื่อ"); + + b.Property("CreatedFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(104) + .HasComment("ชื่อ User ที่สร้างข้อมูล"); + + b.Property("CreatedUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(101) + .HasComment("User Id ที่สร้างข้อมูล"); + + b.Property("Description") + .IsRequired() + .HasColumnType("longtext") + .HasColumnOrder(1) + .HasComment("รายละเอียดการนำเข้า"); + + b.Property("LastUpdateFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(105) + .HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdateUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(103) + .HasComment("User Id ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(102) + .HasComment("แก้ไขข้อมูลล่าสุดเมื่อ"); + + b.Property("RecruitImportId") + .HasColumnType("char(36)"); + + b.HasKey("Id"); + + b.HasIndex("RecruitImportId"); + + b.ToTable("RecruitImportHistories"); + }); + + modelBuilder.Entity("BMA.EHR.Recruit.Service.Models.Recruits.RecruitOccupation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)") + .HasColumnOrder(0) + .HasComment("PrimaryKey") + .HasAnnotation("Relational:JsonPropertyName", "id"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(100) + .HasComment("สร้างข้อมูลเมื่อ"); + + b.Property("CreatedFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(104) + .HasComment("ชื่อ User ที่สร้างข้อมูล"); + + b.Property("CreatedUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(101) + .HasComment("User Id ที่สร้างข้อมูล"); + + b.Property("LastUpdateFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(105) + .HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdateUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(103) + .HasComment("User Id ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(102) + .HasComment("แก้ไขข้อมูลล่าสุดเมื่อ"); + + b.Property("Occupation") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)"); + + b.Property("Position") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)"); + + b.Property("RecruitId") + .HasColumnType("char(36)"); + + b.Property("Telephone") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)"); + + b.Property("WorkAge") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)"); + + b.Property("Workplace") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)"); + + b.HasKey("Id"); + + b.HasIndex("RecruitId"); + + b.ToTable("RecruitOccupations"); + }); + + modelBuilder.Entity("BMA.EHR.Recruit.Service.Models.Recruits.RecruitPayment", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)") + .HasColumnOrder(0) + .HasComment("PrimaryKey") + .HasAnnotation("Relational:JsonPropertyName", "id"); + + b.Property("AccountNumber") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("varchar(50)"); + + b.Property("Amount") + .HasColumnType("decimal(65,30)"); + + b.Property("BankCode") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("varchar(50)"); + + b.Property("ChequeNo") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("varchar(50)"); + + b.Property("ChqueBankCode") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("varchar(50)"); + + b.Property("CompanyCode") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("varchar(50)"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(100) + .HasComment("สร้างข้อมูลเมื่อ"); + + b.Property("CreatedFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(104) + .HasComment("ชื่อ User ที่สร้างข้อมูล"); + + b.Property("CreatedUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(101) + .HasComment("User Id ที่สร้างข้อมูล"); + + b.Property("CreditDebit") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("varchar(50)"); + + b.Property("CustomerName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)"); + + b.Property("LastUpdateFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(105) + .HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdateUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(103) + .HasComment("User Id ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(102) + .HasComment("แก้ไขข้อมูลล่าสุดเมื่อ"); + + b.Property("PaymentId") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("varchar(50)"); + + b.Property("PaymentType") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("varchar(50)"); + + b.Property("RecruitId") + .HasColumnType("char(36)"); + + b.Property("RefNo1") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("varchar(50)"); + + b.Property("TellerId") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("varchar(50)"); + + b.Property("TermBranch") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("varchar(50)"); + + b.Property("TextFile") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("varchar(50)"); + + b.Property("TransDate") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("varchar(50)"); + + b.Property("TransTime") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("varchar(50)"); + + b.HasKey("Id"); + + b.HasIndex("RecruitId"); + + b.ToTable("RecruitPayments"); + }); + + modelBuilder.Entity("BMA.EHR.Recruit.Service.Models.Recruits.RecruitScore", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)") + .HasColumnOrder(0) + .HasComment("PrimaryKey") + .HasAnnotation("Relational:JsonPropertyName", "id"); + + b.Property("ABStatus") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("varchar(50)"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(100) + .HasComment("สร้างข้อมูลเมื่อ"); + + b.Property("CreatedFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(104) + .HasComment("ชื่อ User ที่สร้างข้อมูล"); + + b.Property("CreatedUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(101) + .HasComment("User Id ที่สร้างข้อมูล"); + + b.Property("ExamId") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("varchar(50)"); + + b.Property("ExamStatus") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("varchar(50)"); + + b.Property("FullA") + .HasColumnType("int"); + + b.Property("FullB") + .HasColumnType("int"); + + b.Property("FullC") + .HasColumnType("int"); + + b.Property("LastUpdateFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(105) + .HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdateUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(103) + .HasComment("User Id ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(102) + .HasComment("แก้ไขข้อมูลล่าสุดเมื่อ"); + + b.Property("Major") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)"); + + b.Property("PercentageA") + .HasColumnType("double"); + + b.Property("PercentageB") + .HasColumnType("double"); + + b.Property("PercentageC") + .HasColumnType("double"); + + b.Property("ScoreImportId") + .HasColumnType("char(36)"); + + b.Property("SumA") + .HasColumnType("int"); + + b.Property("SumAB") + .HasColumnType("int"); + + b.Property("SumB") + .HasColumnType("int"); + + b.Property("SumC") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("ScoreImportId"); + + b.ToTable("RecruitScores"); + }); + + modelBuilder.Entity("BMA.EHR.Recruit.Service.Models.Recruits.ScoreImport", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)") + .HasColumnOrder(0) + .HasComment("PrimaryKey") + .HasAnnotation("Relational:JsonPropertyName", "id"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(100) + .HasComment("สร้างข้อมูลเมื่อ"); + + b.Property("CreatedFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(104) + .HasComment("ชื่อ User ที่สร้างข้อมูล"); + + b.Property("CreatedUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(101) + .HasComment("User Id ที่สร้างข้อมูล"); + + b.Property("ImportFileId") + .HasColumnType("char(36)"); + + b.Property("LastUpdateFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(105) + .HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdateUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(103) + .HasComment("User Id ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(102) + .HasComment("แก้ไขข้อมูลล่าสุดเมื่อ"); + + b.Property("RecruitImportId") + .HasColumnType("char(36)"); + + b.Property("Year") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("ImportFileId"); + + b.HasIndex("RecruitImportId") + .IsUnique(); + + b.ToTable("ScoreImports"); + }); + + modelBuilder.Entity("BMA.EHR.Recruit.Service.Models.Recruits.Recruit", b => + { + b.HasOne("BMA.EHR.Recruit.Service.Models.Recruits.RecruitImport", "RecruitImport") + .WithMany("Recruits") + .HasForeignKey("RecruitImportId"); + + b.Navigation("RecruitImport"); + }); + + modelBuilder.Entity("BMA.EHR.Recruit.Service.Models.Recruits.RecruitAddress", b => + { + b.HasOne("BMA.EHR.Recruit.Service.Models.Recruits.Recruit", "Recruit") + .WithMany("Addresses") + .HasForeignKey("RecruitId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Recruit"); + }); + + modelBuilder.Entity("BMA.EHR.Recruit.Service.Models.Recruits.RecruitCertificate", b => + { + b.HasOne("BMA.EHR.Recruit.Service.Models.Recruits.Recruit", "Recruit") + .WithMany("Certificates") + .HasForeignKey("RecruitId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Recruit"); + }); + + modelBuilder.Entity("BMA.EHR.Recruit.Service.Models.Recruits.RecruitDocument", b => + { + b.HasOne("BMA.EHR.Recruit.Service.Models.Documents.Document", "DocumentFile") + .WithMany() + .HasForeignKey("DocumentFileId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("BMA.EHR.Recruit.Service.Models.Recruits.Recruit", "Recruit") + .WithMany("Documents") + .HasForeignKey("RecruitId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("DocumentFile"); + + b.Navigation("Recruit"); + }); + + modelBuilder.Entity("BMA.EHR.Recruit.Service.Models.Recruits.RecruitEducation", b => + { + b.HasOne("BMA.EHR.Recruit.Service.Models.Recruits.Recruit", "Recruit") + .WithMany("Educations") + .HasForeignKey("RecruitId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Recruit"); + }); + + modelBuilder.Entity("BMA.EHR.Recruit.Service.Models.Recruits.RecruitImport", b => + { + b.HasOne("BMA.EHR.Recruit.Service.Models.Documents.Document", "ImportFile") + .WithMany() + .HasForeignKey("ImportFileId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("ImportFile"); + }); + + modelBuilder.Entity("BMA.EHR.Recruit.Service.Models.Recruits.RecruitImportHistory", b => + { + b.HasOne("BMA.EHR.Recruit.Service.Models.Recruits.RecruitImport", "RecruitImport") + .WithMany("ImportHostories") + .HasForeignKey("RecruitImportId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("RecruitImport"); + }); + + modelBuilder.Entity("BMA.EHR.Recruit.Service.Models.Recruits.RecruitOccupation", b => + { + b.HasOne("BMA.EHR.Recruit.Service.Models.Recruits.Recruit", "Recruit") + .WithMany("Occupations") + .HasForeignKey("RecruitId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Recruit"); + }); + + modelBuilder.Entity("BMA.EHR.Recruit.Service.Models.Recruits.RecruitPayment", b => + { + b.HasOne("BMA.EHR.Recruit.Service.Models.Recruits.Recruit", "Recruit") + .WithMany("Payments") + .HasForeignKey("RecruitId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Recruit"); + }); + + modelBuilder.Entity("BMA.EHR.Recruit.Service.Models.Recruits.RecruitScore", b => + { + b.HasOne("BMA.EHR.Recruit.Service.Models.Recruits.ScoreImport", "ScoreImport") + .WithMany("Scores") + .HasForeignKey("ScoreImportId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("ScoreImport"); + }); + + modelBuilder.Entity("BMA.EHR.Recruit.Service.Models.Recruits.ScoreImport", b => + { + b.HasOne("BMA.EHR.Recruit.Service.Models.Documents.Document", "ImportFile") + .WithMany() + .HasForeignKey("ImportFileId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("BMA.EHR.Recruit.Service.Models.Recruits.RecruitImport", "RecruitImport") + .WithOne("ScoreImport") + .HasForeignKey("BMA.EHR.Recruit.Service.Models.Recruits.ScoreImport", "RecruitImportId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("ImportFile"); + + b.Navigation("RecruitImport"); + }); + + modelBuilder.Entity("BMA.EHR.Recruit.Service.Models.Recruits.Recruit", b => + { + b.Navigation("Addresses"); + + b.Navigation("Certificates"); + + b.Navigation("Documents"); + + b.Navigation("Educations"); + + b.Navigation("Occupations"); + + b.Navigation("Payments"); + }); + + modelBuilder.Entity("BMA.EHR.Recruit.Service.Models.Recruits.RecruitImport", b => + { + b.Navigation("ImportHostories"); + + b.Navigation("Recruits"); + + b.Navigation("ScoreImport") + .IsRequired(); + }); + + modelBuilder.Entity("BMA.EHR.Recruit.Service.Models.Recruits.ScoreImport", b => + { + b.Navigation("Scores"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/Models/Documents/Document.cs b/Models/Documents/Document.cs new file mode 100644 index 0000000..77486c9 --- /dev/null +++ b/Models/Documents/Document.cs @@ -0,0 +1,29 @@ +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; + +namespace BMA.EHR.Recruit.Service.Models.Documents +{ + public class Document + { + [Key] + public Guid Id { get; set; } + + [Required, MaxLength(255)] + public string FileName { get; set; } = string.Empty; + + [Required] + public int FileSize { get; set; } = 0; + + [Required, MaxLength(128)] + public string FileType { get; set; } = string.Empty; + + [Column(TypeName = "text")] + public string Detail { get; set; } = string.Empty; + + [Required] + public Guid ObjectRefId { get; set; } + + [Required] + public DateTime CreatedDate { get; set; } = DateTime.Now; + } +} diff --git a/Models/EntityBase.cs b/Models/EntityBase.cs new file mode 100644 index 0000000..e657f3b --- /dev/null +++ b/Models/EntityBase.cs @@ -0,0 +1,32 @@ +using Microsoft.EntityFrameworkCore; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; +using System.Text.Json.Serialization; + +namespace BMA.EHR.Report.Service.Models +{ + public class EntityBase + { + [Key, Column(Order = 0), Comment("PrimaryKey")] + [JsonPropertyName("id")] + public Guid Id { get; set; } + + [Required, Column(Order = 100), Comment("สร้างข้อมูลเมื่อ")] + public DateTime CreatedAt { get; set; } = DateTime.Now; + + [Column(Order = 101), Comment("User Id ที่สร้างข้อมูล"), MaxLength(40)] + public string CreatedUserId { get; set; } = string.Empty; + + [Column(Order = 102), Comment("แก้ไขข้อมูลล่าสุดเมื่อ")] + public DateTime? LastUpdatedAt { get; set; } + + [Column(Order = 103), Comment("User Id ที่แก้ไขข้อมูลล่าสุด"), MaxLength(40)] + public string LastUpdateUserId { get; set; } = string.Empty; + + [Column(Order = 104), Comment("ชื่อ User ที่สร้างข้อมูล"), MaxLength(200)] + public string CreatedFullName { get; set; } = string.Empty; + + [Column(Order = 105), Comment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด"), MaxLength(200)] + public string LastUpdateFullName { get; set; } = string.Empty; + } +} diff --git a/Models/Recruits/Recruit.cs b/Models/Recruits/Recruit.cs new file mode 100644 index 0000000..c089284 --- /dev/null +++ b/Models/Recruits/Recruit.cs @@ -0,0 +1,80 @@ +using BMA.EHR.Report.Service.Models; +using Microsoft.EntityFrameworkCore; +using System.ComponentModel.DataAnnotations; + +namespace BMA.EHR.Recruit.Service.Models.Recruits +{ + public class Recruit : EntityBase + { + + [Required, MaxLength(13), Comment("เลขประจำตัวประชาชน")] + public string CitizenId { get; set; } = string.Empty; + + [Required, MaxLength(50)] + public string ExamId { get; set; } = string.Empty; + + [Required, MaxLength(50)] + public string Prefix { get; set; } = string.Empty; + + [Required, MaxLength(150)] + public string FirstName { get; set; } = string.Empty; + + [Required, MaxLength(150)] + public string LastName { get; set; } = string.Empty; + + [MaxLength(20)] + public string Gendor { get; set; } = string.Empty; + + [MaxLength(200)] + public string National { get; set; } = string.Empty; + + [MaxLength(200)] + public string Race { get; set; } = string.Empty; + + [MaxLength(200)] + public string Religion { get; set; } = string.Empty; + + [Required] + public DateTime DateOfBirth { get; set; } + + [MaxLength(20)] + public string Marry { get; set; } = string.Empty; + + [MaxLength(1)] + public string Isspecial { get; set; } = "N"; + + [MaxLength(20)] + public string RefNo { get; set; } = string.Empty; + + [MaxLength(200)] + public string CitizenCardIssuer { get; set; } = string.Empty; + + public DateTime CitizenCardExpireDate { get; set; } + + [MaxLength(200)] + public string Remark { get; set; } = string.Empty; + + [MaxLength(1)] + public string Qualified { get; set; } = "Y"; + + public RecruitImport? RecruitImport { get; set; } + + public virtual List Addresses { get; set; } = new List(); + + public virtual List Occupations { get; set; } = new List(); + + public virtual List Certificates { get; set; } = new List(); + + public virtual List Educations { get; set; } = new List(); + + public virtual List Payments { get; set; } = new List(); + + public virtual List Documents { get; set; } = new List(); + + public DateTime CreatedDate { get; set; } = DateTime.Now; + + public DateTime ModifiedDate { get; set; } + + public DateTime ApplyDate { get; set; } + } +} diff --git a/Models/Recruits/RecruitAddress.cs b/Models/Recruits/RecruitAddress.cs new file mode 100644 index 0000000..5da0d02 --- /dev/null +++ b/Models/Recruits/RecruitAddress.cs @@ -0,0 +1,64 @@ +using System.ComponentModel.DataAnnotations; +using BMA.EHR.Report.Service.Models; + +namespace BMA.EHR.Recruit.Service.Models.Recruits +{ + public class RecruitAddress : EntityBase + { + [MaxLength(200)] + public string Address { get; set; } + + [MaxLength(200)] + public string Moo { get; set; } + + [MaxLength(200)] + public string Soi { get; set; } + + [MaxLength(200)] + public string Road { get; set; } + + [MaxLength(200)] + public string District { get; set; } + + [MaxLength(200)] + public string Amphur { get; set; } + + [MaxLength(200)] + public string Province { get; set; } + + [MaxLength(5)] + public string ZipCode { get; set; } + + [MaxLength(200)] + public string Telephone { get; set; } + + [MaxLength(200)] + public string Mobile { get; set; } + + [MaxLength(200)] + public string Address1 { get; set; } + + [MaxLength(200)] + public string Moo1 { get; set; } + + [MaxLength(200)] + public string Soi1 { get; set; } + + [MaxLength(200)] + public string Road1 { get; set; } + + [MaxLength(200)] + public string District1 { get; set; } + + [MaxLength(200)] + public string Amphur1 { get; set; } + + [MaxLength(200)] + public string Province1 { get; set; } + + [MaxLength(5)] + public string ZipCode1 { get; set; } + + public Recruit Recruit { get; set; } + } +} diff --git a/Models/Recruits/RecruitCertificate.cs b/Models/Recruits/RecruitCertificate.cs new file mode 100644 index 0000000..807112a --- /dev/null +++ b/Models/Recruits/RecruitCertificate.cs @@ -0,0 +1,20 @@ +using System.ComponentModel.DataAnnotations; +using BMA.EHR.Report.Service.Models; + +namespace BMA.EHR.Recruit.Service.Models.Recruits +{ + public class RecruitCertificate : EntityBase + { + [MaxLength(50)] + public string CertificateNo { get; set; } + + [MaxLength(200)] + public string Description { get; set; } + + public DateTime IssueDate { get; set; } + + public DateTime ExpiredDate { get; set; } + + public Recruit Recruit { get; set; } + } +} diff --git a/Models/Recruits/RecruitDocument.cs b/Models/Recruits/RecruitDocument.cs new file mode 100644 index 0000000..d6abe07 --- /dev/null +++ b/Models/Recruits/RecruitDocument.cs @@ -0,0 +1,15 @@ +using BMA.EHR.Recruit.Service.Models.Documents; +using BMA.EHR.Report.Service.Models; +using BMA.EHR.Report.Service.Models; + +namespace BMA.EHR.Recruit.Service.Models.Recruits +{ + public class RecruitDocument : EntityBase + { + public DateTime CreatedDate { get; set; } + + public Document DocumentFile { get; set; } + + public Recruit Recruit { get; set; } + } +} diff --git a/Models/Recruits/RecruitEducation.cs b/Models/Recruits/RecruitEducation.cs new file mode 100644 index 0000000..a4b7343 --- /dev/null +++ b/Models/Recruits/RecruitEducation.cs @@ -0,0 +1,34 @@ +using System.ComponentModel.DataAnnotations; +using BMA.EHR.Report.Service.Models; + +namespace BMA.EHR.Recruit.Service.Models.Recruits +{ + public class RecruitEducation : EntityBase + { + [MaxLength(200)] + public string Degree { get; set; } + + [MaxLength(200)] + public string Major { get; set; } + + [MaxLength(20)] + public string MajorGroupId { get; set; } + + [MaxLength(200)] + public string MajorGroupName { get; set; } + + [MaxLength(200)] + public string University { get; set; } + public double GPA { get; set; } = 0.0; + + [MaxLength(1000)] + public string Specialist { get; set; } + + [MaxLength(200)] + public string HighDegree { get; set; } + + public DateTime BachelorDate { get; set; } + + public Recruit Recruit { get; set; } + } +} diff --git a/Models/Recruits/RecruitImport.cs b/Models/Recruits/RecruitImport.cs new file mode 100644 index 0000000..83cd1dc --- /dev/null +++ b/Models/Recruits/RecruitImport.cs @@ -0,0 +1,28 @@ +using BMA.EHR.Recruit.Service.Models.Documents; +using Microsoft.EntityFrameworkCore; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; +using BMA.EHR.Report.Service.Models; + +namespace BMA.EHR.Recruit.Service.Models.Recruits +{ + public class RecruitImport : EntityBase + { + [Required, Comment("ปีที่จัดการสอบ"), Column(Order = 1)] + public int Year { get; set; } + + [Required, MaxLength(250), Comment("ชื่อการสอบ"), Column(Order = 2)] + public string Name { get; set; } = string.Empty; + + [Required, Comment("ครั้งที่"), Column(Order = 3)] + public int Order { get; set; } = 1; + + public Document ImportFile { get; set; } = new Document(); + + public List Recruits { get; set; } = new List(); + + public ScoreImport ScoreImport { get; set; } + + public List ImportHostories { get; set; } = new List(); + } +} diff --git a/Models/Recruits/RecruitImportHistory.cs b/Models/Recruits/RecruitImportHistory.cs new file mode 100644 index 0000000..8d63243 --- /dev/null +++ b/Models/Recruits/RecruitImportHistory.cs @@ -0,0 +1,15 @@ +using Microsoft.EntityFrameworkCore; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; +using BMA.EHR.Report.Service.Models; + +namespace BMA.EHR.Recruit.Service.Models.Recruits +{ + public class RecruitImportHistory : EntityBase + { + [Required, Comment("รายละเอียดการนำเข้า"), Column(Order = 1)] + public string Description { get; set; } = string.Empty; + + public RecruitImport RecruitImport { get; set; } + } +} \ No newline at end of file diff --git a/Models/Recruits/RecruitOccupation.cs b/Models/Recruits/RecruitOccupation.cs new file mode 100644 index 0000000..8488196 --- /dev/null +++ b/Models/Recruits/RecruitOccupation.cs @@ -0,0 +1,25 @@ +using System.ComponentModel.DataAnnotations; +using BMA.EHR.Report.Service.Models; + +namespace BMA.EHR.Recruit.Service.Models.Recruits +{ + public class RecruitOccupation : EntityBase + { + [MaxLength(200)] + public string Occupation { get; set; } + + [MaxLength(200)] + public string WorkAge { get; set; } + + [MaxLength(200)] + public string Position { get; set; } + + [MaxLength(200)] + public string Workplace { get; set; } + + [MaxLength(200)] + public string Telephone { get; set; } + + public Recruit Recruit { get; set; } + } +} diff --git a/Models/Recruits/RecruitPayment.cs b/Models/Recruits/RecruitPayment.cs new file mode 100644 index 0000000..c9e8b34 --- /dev/null +++ b/Models/Recruits/RecruitPayment.cs @@ -0,0 +1,57 @@ +using System.ComponentModel.DataAnnotations; +using BMA.EHR.Report.Service.Models; + +namespace BMA.EHR.Recruit.Service.Models.Recruits +{ + public class RecruitPayment : EntityBase + { + [MaxLength(50)] + public string PaymentId { get; set; } + + [MaxLength(50)] + public string CompanyCode { get; set; } + + [MaxLength(50)] + public string TextFile { get; set; } + + [MaxLength(50)] + public string BankCode { get; set; } + + [MaxLength(50)] + public string AccountNumber { get; set; } + + [MaxLength(50)] + public string TransDate { get; set; } + + [MaxLength(50)] + public string TransTime { get; set; } + + [MaxLength(200)] + public string CustomerName { get; set; } + + [MaxLength(50)] + public string RefNo1 { get; set; } + + [MaxLength(50)] + public string TermBranch { get; set; } + + [MaxLength(50)] + public string TellerId { get; set; } + + [MaxLength(50)] + public string CreditDebit { get; set; } + + [MaxLength(50)] + public string PaymentType { get; set; } + + [MaxLength(50)] + public string ChequeNo { get; set; } + + public decimal Amount { get; set; } + + [MaxLength(50)] + public string ChqueBankCode { get; set; } + + public Recruit Recruit { get; set; } + } +} diff --git a/Models/Recruits/RecruitScore.cs b/Models/Recruits/RecruitScore.cs new file mode 100644 index 0000000..43b1b10 --- /dev/null +++ b/Models/Recruits/RecruitScore.cs @@ -0,0 +1,42 @@ +using System.ComponentModel.DataAnnotations; +using BMA.EHR.Report.Service.Models; + +namespace BMA.EHR.Recruit.Service.Models.Recruits +{ + public class RecruitScore : EntityBase + { + [Required, MaxLength(50)] + public string ExamId { get; set; } + + public int SumA { get; set; } + + public int FullA { get; set; } + + public double PercentageA { get; set; } + + public int SumB { get; set; } + + public int FullB { get; set; } + + public double PercentageB { get; set; } + + public int SumAB { get; set; } + + [Required, MaxLength(50)] + public string ABStatus { get; set; } + + public int SumC { get; set; } + + public int FullC { get; set; } + + public double PercentageC { get; set; } + + [Required, MaxLength(50)] + public string ExamStatus { get; set; } + + [MaxLength(200)] + public string Major { get; set; } + + public ScoreImport ScoreImport { get; set; } + } +} diff --git a/Models/Recruits/ScoreImport.cs b/Models/Recruits/ScoreImport.cs new file mode 100644 index 0000000..fac9c61 --- /dev/null +++ b/Models/Recruits/ScoreImport.cs @@ -0,0 +1,20 @@ +using BMA.EHR.Recruit.Service.Models.Documents; +using System.ComponentModel.DataAnnotations.Schema; +using BMA.EHR.Report.Service.Models; + +namespace BMA.EHR.Recruit.Service.Models.Recruits +{ + public class ScoreImport : EntityBase + { + public int Year { get; set; } + + public Document ImportFile { get; set; } = new Document(); + + public virtual List Scores { get; set; } = new List(); + + [ForeignKey("FK_Score_Import_ID")] + public Guid RecruitImportId { get; set; } + + public RecruitImport RecruitImport { get; set; } + } +} diff --git a/Program.cs b/Program.cs index 48863a6..7fd7df2 100644 --- a/Program.cs +++ b/Program.cs @@ -1,25 +1,164 @@ +using Microsoft.AspNetCore.Authentication.JwtBearer; +using Microsoft.AspNetCore.Mvc.Versioning; +using Microsoft.AspNetCore.Mvc; +using Microsoft.IdentityModel.Logging; +using Microsoft.IdentityModel.Tokens; +using System.Text; +using Microsoft.EntityFrameworkCore; +using MongoDB.Bson.Serialization.Serializers; +using Serilog; +using Serilog.Exceptions; +using Serilog.Sinks.Elasticsearch; +using System.Reflection; +using BMA.EHR.Report.Service.Data; +using MongoDB.Bson; +using MongoDB.Bson.Serialization; +using BMA.EHR.Report.Service; +using Microsoft.AspNetCore.Mvc.ApiExplorer; + var builder = WebApplication.CreateBuilder(args); +var issuer = builder.Configuration["Jwt:Issuer"]; +var key = builder.Configuration["Jwt:Key"]; + +IdentityModelEventSource.ShowPII = true; + +builder.Services.AddHttpContextAccessor(); + +builder.Services.AddApiVersioning(opt => +{ + opt.DefaultApiVersion = new ApiVersion(1, 0); + opt.AssumeDefaultVersionWhenUnspecified = true; + opt.ReportApiVersions = true; + opt.ApiVersionReader = ApiVersionReader.Combine(new UrlSegmentApiVersionReader(), + new HeaderApiVersionReader("x-api-version"), + new MediaTypeApiVersionReader("x-api-version")); +}); + +builder.Services.AddVersionedApiExplorer(setup => +{ + setup.GroupNameFormat = "'v'VVV"; + setup.SubstituteApiVersionInUrl = true; +}); + +builder.Services.AddEndpointsApiExplorer(); + +// Authorization +builder.Services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme).AddJwtBearer(opt => +{ + opt.RequireHttpsMetadata = false; //false for dev + opt.Authority = issuer; + opt.TokenValidationParameters = new() + { + ValidateIssuer = true, + ValidateAudience = false, + ValidateLifetime = true, + ValidateIssuerSigningKey = true, + ValidIssuer = issuer, + IssuerSigningKey = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(key)) + }; +}); +builder.Services.AddAuthorization(); + +// use serilog +ConfigureLogs(); +builder.Host.UseSerilog(); + +BsonSerializer.RegisterSerializer(new GuidSerializer(BsonType.String)); +BsonSerializer.RegisterSerializer(new DateTimeSerializer(BsonType.String)); + +// Register DbContext +var recruitConnection = builder.Configuration.GetConnectionString("RecruitConnection"); +builder.Services.AddDbContext(options => + options.UseMySql(recruitConnection, ServerVersion.AutoDetect(recruitConnection), o => o.MigrationsHistoryTable("__ReportMigrationsHistory")) +); + + +// Add config CORS +builder.Services.AddCors(options => options.AddDefaultPolicy(builder => +{ + builder + .AllowAnyOrigin() + .AllowAnyMethod() + .AllowAnyHeader() + .SetIsOriginAllowedToAllowWildcardSubdomains(); +})); + +// Register Service +//builder.Services.AddTransient(); +//builder.Services.AddTransient(); // Add services to the container. +builder.Services.AddControllers(options => +{ + options.SuppressAsyncSuffixInActionNames = false; +}) +.AddNewtonsoftJson(x => x.SerializerSettings.ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Ignore); -builder.Services.AddControllers(); -// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle -builder.Services.AddEndpointsApiExplorer(); builder.Services.AddSwaggerGen(); +builder.Services.ConfigureOptions(); +builder.Services.AddHealthChecks(); var app = builder.Build(); -// Configure the HTTP request pipeline. +var apiVersionDescriptionProvider = app.Services.GetRequiredService(); + if (app.Environment.IsDevelopment()) { app.UseSwagger(); - app.UseSwaggerUI(); + app.UseSwaggerUI(options => + { + foreach (var description in apiVersionDescriptionProvider.ApiVersionDescriptions) + { + options.SwaggerEndpoint($"/swagger/{description.GroupName}/swagger.json", + description.GroupName.ToUpperInvariant()); + } + }); } +app.MapHealthChecks("/health"); + app.UseHttpsRedirection(); - +app.UseCors(); +app.UseAuthentication(); app.UseAuthorization(); - +app.UseDefaultFiles(); +app.UseStaticFiles(); app.MapControllers(); +// apply migrations +await using var scope = app.Services.CreateAsyncScope(); +await using var db = scope.ServiceProvider.GetRequiredService(); +await db.Database.MigrateAsync(); + app.Run(); +void ConfigureLogs() +{ + var environment = Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT"); + var configuration = new ConfigurationBuilder() + .AddJsonFile("appsettings.json", optional: false, reloadOnChange: true) + .AddJsonFile( + $"appsettings.{Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT")}.json", + optional: true) + .Build(); + + Log.Logger = new LoggerConfiguration() + .Enrich.FromLogContext() + // .WriteTo.Debug() + .MinimumLevel.Error() + .WriteTo.Console() + .Enrich.WithExceptionDetails() + // .Enrich.WithEnvironmentUserName() + .WriteTo.Elasticsearch(ConfigureElasticSink(configuration, environment ?? "")) + .Enrich.WithProperty("Environment", environment) + .ReadFrom.Configuration(configuration) + .CreateLogger(); +} + +ElasticsearchSinkOptions ConfigureElasticSink(IConfigurationRoot configuration, string environment) +{ + return new ElasticsearchSinkOptions(new Uri(configuration["ElasticConfiguration:Uri"] ?? "")) + { + AutoRegisterTemplate = true, + IndexFormat = $"{Assembly.GetExecutingAssembly()?.GetName()?.Name?.ToLower().Replace(".", "-")}-{environment?.ToLower().Replace(".", "-")}" + }; +} diff --git a/Report/Recruit/rptCertificate.trdp b/Report/Recruit/rptCertificate.trdp new file mode 100644 index 0000000..3654fda Binary files /dev/null and b/Report/Recruit/rptCertificate.trdp differ diff --git a/Responses/ResponseObject.cs b/Responses/ResponseObject.cs new file mode 100644 index 0000000..ac6c90a --- /dev/null +++ b/Responses/ResponseObject.cs @@ -0,0 +1,13 @@ +using System.Net; + +namespace BMA.EHR.Report.Service.Responses +{ + public class ResponseObject + { + public int Status { get; set; } + + public string? Message { get; set; } + + public object? Result { get; set; } + } +} diff --git a/WeatherForecast.cs b/WeatherForecast.cs deleted file mode 100644 index e38a453..0000000 --- a/WeatherForecast.cs +++ /dev/null @@ -1,13 +0,0 @@ -namespace BMA.EHR.Report.Service -{ - public class WeatherForecast - { - public DateOnly Date { get; set; } - - public int TemperatureC { get; set; } - - public int TemperatureF => 32 + (int)(TemperatureC / 0.5556); - - public string? Summary { get; set; } - } -} \ No newline at end of file diff --git a/appsettings.Development.json b/appsettings.Development.json index 0c208ae..a54f5fa 100644 --- a/appsettings.Development.json +++ b/appsettings.Development.json @@ -1,8 +1,34 @@ { - "Logging": { - "LogLevel": { - "Default": "Information", - "Microsoft.AspNetCore": "Warning" + "Serilog": { + "MinimumLevel": { + "Default": "Information", + "Override": { + "Microsoft": "Information", + "System": "Warning" + } + } + }, + "ElasticConfiguration": { + "Uri": "http://localhost:9200" + }, + "AllowedHosts": "*", + "ConnectionStrings": { + "MongoConnection": "mongodb://admin:adminVM123@127.0.0.1:27017", + "RecruitConnection": "server=127.0.0.1;user=root;password=P@ssw0rd;port=3308;database=bma_recruit;Convert Zero Datetime=True;Allow User Variables=true;Pooling=True;" + }, + "Jwt": { + "Key": "HP-FnQMUj9msHMSD3T9HtdEnphAKoCJLEl85CIqROFI", + "Issuer": "https://identity.frappet.com/realms/bma-ehr" + }, + "EPPlus": { + "ExcelPackage": { + "LicenseContext": "NonCommercial" + } + }, + "MinIO": { + "Endpoint": "http://127.0.0.1:9000", + "AccessKey": "XCiP1ubSyuGS5yDT", + "SecretKey": "LFnSRyk144oJERvump8UDxPcjjEyzgum", + "BucketName": "bma-recruit" } - } -} +} \ No newline at end of file diff --git a/appsettings.json b/appsettings.json index 10f68b8..a54f5fa 100644 --- a/appsettings.json +++ b/appsettings.json @@ -1,9 +1,34 @@ { - "Logging": { - "LogLevel": { - "Default": "Information", - "Microsoft.AspNetCore": "Warning" + "Serilog": { + "MinimumLevel": { + "Default": "Information", + "Override": { + "Microsoft": "Information", + "System": "Warning" + } + } + }, + "ElasticConfiguration": { + "Uri": "http://localhost:9200" + }, + "AllowedHosts": "*", + "ConnectionStrings": { + "MongoConnection": "mongodb://admin:adminVM123@127.0.0.1:27017", + "RecruitConnection": "server=127.0.0.1;user=root;password=P@ssw0rd;port=3308;database=bma_recruit;Convert Zero Datetime=True;Allow User Variables=true;Pooling=True;" + }, + "Jwt": { + "Key": "HP-FnQMUj9msHMSD3T9HtdEnphAKoCJLEl85CIqROFI", + "Issuer": "https://identity.frappet.com/realms/bma-ehr" + }, + "EPPlus": { + "ExcelPackage": { + "LicenseContext": "NonCommercial" + } + }, + "MinIO": { + "Endpoint": "http://127.0.0.1:9000", + "AccessKey": "XCiP1ubSyuGS5yDT", + "SecretKey": "LFnSRyk144oJERvump8UDxPcjjEyzgum", + "BucketName": "bma-recruit" } - }, - "AllowedHosts": "*" -} +} \ No newline at end of file diff --git a/nuget.config b/nuget.config new file mode 100644 index 0000000..7d34cfc --- /dev/null +++ b/nuget.config @@ -0,0 +1,10 @@ + + + + + + + + + +