add table certificate

This commit is contained in:
Kittapath 2023-07-05 19:41:40 +07:00
parent 0a626fb393
commit 55a5914967
4 changed files with 10631 additions and 32 deletions

View file

@ -0,0 +1,185 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace BMA.EHR.Infrastructure.Migrations
{
/// <inheritdoc />
public partial class UpdatetablePlacementaddcertificate : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "PlacementCareers");
migrationBuilder.AddColumn<Guid>(
name: "BloodGroupId",
table: "PlacementProfiles",
type: "char(36)",
nullable: true,
collation: "ascii_general_ci");
migrationBuilder.AddColumn<string>(
name: "Race",
table: "PlacementProfiles",
type: "varchar(40)",
maxLength: 40,
nullable: true,
comment: "เชื้อชาติ")
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.AddColumn<Guid>(
name: "ReligionId",
table: "PlacementProfiles",
type: "char(36)",
nullable: true,
collation: "ascii_general_ci");
migrationBuilder.CreateTable(
name: "PlacementCertificates",
columns: table => new
{
Id = table.Column<Guid>(type: "char(36)", nullable: false, comment: "PrimaryKey", collation: "ascii_general_ci"),
CreatedAt = table.Column<DateTime>(type: "datetime(6)", nullable: false, comment: "สร้างข้อมูลเมื่อ"),
CreatedUserId = table.Column<string>(type: "varchar(40)", maxLength: 40, nullable: false, comment: "User Id ที่สร้างข้อมูล")
.Annotation("MySql:CharSet", "utf8mb4"),
LastUpdatedAt = table.Column<DateTime>(type: "datetime(6)", nullable: true, comment: "แก้ไขข้อมูลล่าสุดเมื่อ"),
LastUpdateUserId = table.Column<string>(type: "varchar(40)", maxLength: 40, nullable: false, comment: "User Id ที่แก้ไขข้อมูลล่าสุด")
.Annotation("MySql:CharSet", "utf8mb4"),
CreatedFullName = table.Column<string>(type: "varchar(200)", maxLength: 200, nullable: false, comment: "ชื่อ User ที่สร้างข้อมูล")
.Annotation("MySql:CharSet", "utf8mb4"),
LastUpdateFullName = table.Column<string>(type: "varchar(200)", maxLength: 200, nullable: false, comment: "ชื่อ User ที่แก้ไขข้อมูลล่าสุด")
.Annotation("MySql:CharSet", "utf8mb4"),
PlacementProfileId = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
CertificateNo = table.Column<string>(type: "varchar(20)", maxLength: 20, nullable: true, comment: "เลขที่ใบอนุญาต")
.Annotation("MySql:CharSet", "utf8mb4"),
Issuer = table.Column<string>(type: "varchar(200)", maxLength: 200, nullable: true, comment: "หน่วยงานผู้ออกใบอนุญาต")
.Annotation("MySql:CharSet", "utf8mb4"),
IssueDate = table.Column<DateTime>(type: "datetime(6)", nullable: true, comment: "วันที่ออกใบอนุญาต"),
ExpireDate = table.Column<DateTime>(type: "datetime(6)", nullable: true, comment: "วันที่หมดอายุ"),
CertificateType = table.Column<string>(type: "varchar(100)", maxLength: 100, nullable: true, comment: "ชื่อใบอนุญาต")
.Annotation("MySql:CharSet", "utf8mb4")
},
constraints: table =>
{
table.PrimaryKey("PK_PlacementCertificates", x => x.Id);
table.ForeignKey(
name: "FK_PlacementCertificates_PlacementProfiles_PlacementProfileId",
column: x => x.PlacementProfileId,
principalTable: "PlacementProfiles",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
})
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.CreateIndex(
name: "IX_PlacementProfiles_BloodGroupId",
table: "PlacementProfiles",
column: "BloodGroupId");
migrationBuilder.CreateIndex(
name: "IX_PlacementProfiles_ReligionId",
table: "PlacementProfiles",
column: "ReligionId");
migrationBuilder.CreateIndex(
name: "IX_PlacementCertificates_PlacementProfileId",
table: "PlacementCertificates",
column: "PlacementProfileId");
migrationBuilder.AddForeignKey(
name: "FK_PlacementProfiles_BloodGroups_BloodGroupId",
table: "PlacementProfiles",
column: "BloodGroupId",
principalTable: "BloodGroups",
principalColumn: "Id");
migrationBuilder.AddForeignKey(
name: "FK_PlacementProfiles_Religions_ReligionId",
table: "PlacementProfiles",
column: "ReligionId",
principalTable: "Religions",
principalColumn: "Id");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_PlacementProfiles_BloodGroups_BloodGroupId",
table: "PlacementProfiles");
migrationBuilder.DropForeignKey(
name: "FK_PlacementProfiles_Religions_ReligionId",
table: "PlacementProfiles");
migrationBuilder.DropTable(
name: "PlacementCertificates");
migrationBuilder.DropIndex(
name: "IX_PlacementProfiles_BloodGroupId",
table: "PlacementProfiles");
migrationBuilder.DropIndex(
name: "IX_PlacementProfiles_ReligionId",
table: "PlacementProfiles");
migrationBuilder.DropColumn(
name: "BloodGroupId",
table: "PlacementProfiles");
migrationBuilder.DropColumn(
name: "Race",
table: "PlacementProfiles");
migrationBuilder.DropColumn(
name: "ReligionId",
table: "PlacementProfiles");
migrationBuilder.CreateTable(
name: "PlacementCareers",
columns: table => new
{
Id = table.Column<Guid>(type: "char(36)", nullable: false, comment: "PrimaryKey", collation: "ascii_general_ci"),
CreatedAt = table.Column<DateTime>(type: "datetime(6)", nullable: false, comment: "สร้างข้อมูลเมื่อ"),
CreatedUserId = table.Column<string>(type: "varchar(40)", maxLength: 40, nullable: false, comment: "User Id ที่สร้างข้อมูล")
.Annotation("MySql:CharSet", "utf8mb4"),
LastUpdatedAt = table.Column<DateTime>(type: "datetime(6)", nullable: true, comment: "แก้ไขข้อมูลล่าสุดเมื่อ"),
LastUpdateUserId = table.Column<string>(type: "varchar(40)", maxLength: 40, nullable: false, comment: "User Id ที่แก้ไขข้อมูลล่าสุด")
.Annotation("MySql:CharSet", "utf8mb4"),
CreatedFullName = table.Column<string>(type: "varchar(200)", maxLength: 200, nullable: false, comment: "ชื่อ User ที่สร้างข้อมูล")
.Annotation("MySql:CharSet", "utf8mb4"),
LastUpdateFullName = table.Column<string>(type: "varchar(200)", maxLength: 200, nullable: false, comment: "ชื่อ User ที่แก้ไขข้อมูลล่าสุด")
.Annotation("MySql:CharSet", "utf8mb4"),
PlacementProfileId = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
DurationEnd = table.Column<DateTime>(type: "datetime(6)", nullable: false, comment: "ระยะเวลาสิ้นสุด"),
DurationStart = table.Column<DateTime>(type: "datetime(6)", nullable: false, comment: "ระยะเวลาเริ่ม"),
Name = table.Column<string>(type: "longtext", nullable: false, comment: "สถานที่ทำงาน/ฝึกงาน")
.Annotation("MySql:CharSet", "utf8mb4"),
Position = table.Column<string>(type: "longtext", nullable: false, comment: "ตำแหน่ง/ลักษณะงาน")
.Annotation("MySql:CharSet", "utf8mb4"),
Reason = table.Column<string>(type: "longtext", nullable: false, comment: "เหตุผลที่ออก")
.Annotation("MySql:CharSet", "utf8mb4"),
Salary = table.Column<int>(type: "int", maxLength: 20, nullable: false, comment: "เงินเดือนสุดท้ายก่อนออก")
},
constraints: table =>
{
table.PrimaryKey("PK_PlacementCareers", x => x.Id);
table.ForeignKey(
name: "FK_PlacementCareers_PlacementProfiles_PlacementProfileId",
column: x => x.PlacementProfileId,
principalTable: "PlacementProfiles",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
})
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.CreateIndex(
name: "IX_PlacementCareers_PlacementProfileId",
table: "PlacementCareers",
column: "PlacementProfileId");
}
}
}

View file

@ -8529,7 +8529,7 @@ namespace BMA.EHR.Infrastructure.Migrations
b.ToTable("Placements");
});
modelBuilder.Entity("BMA.EHR.Domain.Models.Placement.PlacementCareer", b =>
modelBuilder.Entity("BMA.EHR.Domain.Models.Placement.PlacementCertificate", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
@ -8538,6 +8538,16 @@ namespace BMA.EHR.Infrastructure.Migrations
.HasComment("PrimaryKey")
.HasAnnotation("Relational:JsonPropertyName", "id");
b.Property<string>("CertificateNo")
.HasMaxLength(20)
.HasColumnType("varchar(20)")
.HasComment("เลขที่ใบอนุญาต");
b.Property<string>("CertificateType")
.HasMaxLength(100)
.HasColumnType("varchar(100)")
.HasComment("ชื่อใบอนุญาต");
b.Property<DateTime>("CreatedAt")
.HasColumnType("datetime(6)")
.HasColumnOrder(100)
@ -8557,13 +8567,18 @@ namespace BMA.EHR.Infrastructure.Migrations
.HasColumnOrder(101)
.HasComment("User Id ที่สร้างข้อมูล");
b.Property<DateTime>("DurationEnd")
b.Property<DateTime?>("ExpireDate")
.HasColumnType("datetime(6)")
.HasComment("ระยะเวลาสิ้นสุด");
.HasComment("วันที่หมดอายุ");
b.Property<DateTime>("DurationStart")
b.Property<DateTime?>("IssueDate")
.HasColumnType("datetime(6)")
.HasComment("ระยะเวลาเริ่ม");
.HasComment("วันที่ออกใบอนุญาต");
b.Property<string>("Issuer")
.HasMaxLength(200)
.HasColumnType("varchar(200)")
.HasComment("หน่วยงานผู้ออกใบอนุญาต");
b.Property<string>("LastUpdateFullName")
.IsRequired()
@ -8584,34 +8599,14 @@ namespace BMA.EHR.Infrastructure.Migrations
.HasColumnOrder(102)
.HasComment("แก้ไขข้อมูลล่าสุดเมื่อ");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("longtext")
.HasComment("สถานที่ทำงาน/ฝึกงาน");
b.Property<Guid>("PlacementProfileId")
.HasColumnType("char(36)");
b.Property<string>("Position")
.IsRequired()
.HasColumnType("longtext")
.HasComment("ตำแหน่ง/ลักษณะงาน");
b.Property<string>("Reason")
.IsRequired()
.HasColumnType("longtext")
.HasComment("เหตุผลที่ออก");
b.Property<int>("Salary")
.HasMaxLength(20)
.HasColumnType("int")
.HasComment("เงินเดือนสุดท้ายก่อนออก");
b.HasKey("Id");
b.HasIndex("PlacementProfileId");
b.ToTable("PlacementCareers");
b.ToTable("PlacementCertificates");
});
modelBuilder.Entity("BMA.EHR.Domain.Models.Placement.PlacementEducation", b =>
@ -8773,6 +8768,9 @@ namespace BMA.EHR.Infrastructure.Migrations
.HasColumnType("double")
.HasComment("เงินเดือน");
b.Property<Guid?>("BloodGroupId")
.HasColumnType("char(36)");
b.Property<DateTime?>("CitizenDate")
.HasColumnType("datetime(6)")
.HasComment("วันที่ออกบัตร");
@ -9070,6 +9068,11 @@ namespace BMA.EHR.Infrastructure.Migrations
b.Property<Guid?>("PrefixId")
.HasColumnType("char(36)");
b.Property<string>("Race")
.HasMaxLength(40)
.HasColumnType("varchar(40)")
.HasComment("เชื้อชาติ");
b.Property<DateTime?>("RecruitDate")
.HasColumnType("datetime(6)")
.HasComment("วันที่บรรจุ");
@ -9110,6 +9113,9 @@ namespace BMA.EHR.Infrastructure.Migrations
.HasColumnType("longtext")
.HasComment("เหตุผลผ่อนผัน");
b.Property<Guid?>("ReligionId")
.HasColumnType("char(36)");
b.Property<DateTime?>("ReportingDate")
.HasColumnType("datetime(6)")
.HasComment("วันที่รายงานตัว");
@ -9129,6 +9135,8 @@ namespace BMA.EHR.Infrastructure.Migrations
b.HasKey("Id");
b.HasIndex("BloodGroupId");
b.HasIndex("CitizenDistrictId");
b.HasIndex("CitizenProvinceId");
@ -9175,6 +9183,8 @@ namespace BMA.EHR.Infrastructure.Migrations
b.HasIndex("ReliefDocId");
b.HasIndex("ReligionId");
b.ToTable("PlacementProfiles");
});
@ -9956,10 +9966,10 @@ namespace BMA.EHR.Infrastructure.Migrations
b.Navigation("PlacementType");
});
modelBuilder.Entity("BMA.EHR.Domain.Models.Placement.PlacementCareer", b =>
modelBuilder.Entity("BMA.EHR.Domain.Models.Placement.PlacementCertificate", b =>
{
b.HasOne("BMA.EHR.Domain.Models.Placement.PlacementProfile", "PlacementProfile")
.WithMany("PlacementCareers")
.WithMany("PlacementCertificates")
.HasForeignKey("PlacementProfileId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
@ -9986,6 +9996,10 @@ namespace BMA.EHR.Infrastructure.Migrations
modelBuilder.Entity("BMA.EHR.Domain.Models.Placement.PlacementProfile", b =>
{
b.HasOne("BMA.EHR.Domain.Models.MetaData.BloodGroup", "BloodGroup")
.WithMany()
.HasForeignKey("BloodGroupId");
b.HasOne("BMA.EHR.Domain.Models.MetaData.District", "CitizenDistrict")
.WithMany()
.HasForeignKey("CitizenDistrictId");
@ -10078,6 +10092,12 @@ namespace BMA.EHR.Infrastructure.Migrations
.WithMany()
.HasForeignKey("ReliefDocId");
b.HasOne("BMA.EHR.Domain.Models.MetaData.Religion", "Religion")
.WithMany()
.HasForeignKey("ReligionId");
b.Navigation("BloodGroup");
b.Navigation("CitizenDistrict");
b.Navigation("CitizenProvince");
@ -10123,6 +10143,8 @@ namespace BMA.EHR.Infrastructure.Migrations
b.Navigation("Relationship");
b.Navigation("ReliefDoc");
b.Navigation("Religion");
});
modelBuilder.Entity("BMA.EHR.Domain.Models.HR.LimitLeave", b =>
@ -10299,7 +10321,7 @@ namespace BMA.EHR.Infrastructure.Migrations
modelBuilder.Entity("BMA.EHR.Domain.Models.Placement.PlacementProfile", b =>
{
b.Navigation("PlacementCareers");
b.Navigation("PlacementCertificates");
b.Navigation("PlacementEducations");
});

View file

@ -1,5 +1,6 @@
using BMA.EHR.Application.Repositories;
using BMA.EHR.Domain.Common;
using BMA.EHR.Domain.Extensions;
using BMA.EHR.Domain.Models.Placement;
using BMA.EHR.Domain.Shared;
using BMA.EHR.Infrastructure.Persistence;
@ -135,9 +136,24 @@ namespace BMA.EHR.Placement.Service.Controllers
{
PersonalId = x.Id,
IdCard = x.CitizenId,
Prefix = x.Prefix == null ? null : x.Prefix.Name,
PrefixId = x.Prefix == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : x.Prefix.Id,
FullName = x.Prefix == null ? null : x.Prefix.Name + $"{x.Firstname} {x.Lastname}",
Firstname = x.Firstname,
Lastname = x.Lastname,
Nationality = x.Nationality,
Race = x.Race,
DateOfBirth = x.DateOfBirth,
Age = x.DateOfBirth == null ? null : x.DateOfBirth.Value.CalculateAgeStrV2(0, 0),
Telephone = x.Telephone,
Gender = x.Gender == null ? null : x.Gender.Name,
GenderId = x.Gender == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : x.Gender.Id,
Relationship = x.Relationship == null ? null : x.Relationship.Name,
RelationshipId = x.Relationship == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : x.Relationship.Id,
BloodGroup = x.BloodGroup == null ? null : x.BloodGroup.Name,
BloodGroupId = x.BloodGroup == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : x.BloodGroup.Id,
Religion = x.Religion == null ? null : x.Religion.Name,
ReligionId = x.Religion == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : x.Religion.Id,
Address = $"{x.RegistAddress}" +
(x.RegistSubDistrict == null ? null : " แขวง") + (x.RegistSubDistrict == null ? null : x.RegistSubDistrict.Name) +
(x.RegistDistrict == null ? null : " เขต") + (x.RegistDistrict == null ? null : x.RegistDistrict.Name) +
@ -145,6 +161,7 @@ namespace BMA.EHR.Placement.Service.Controllers
(x.RegistSubDistrict == null ? null : " ") + (x.RegistSubDistrict == null ? null : x.RegistSubDistrict.ZipCode),
Education = x.PlacementEducations.Select(p => new
{
Id = p.Id,
EducationLevel = p.EducationLevel == null ? null : p.EducationLevel.Name,
Major = p.Major,
Scores = p.Scores,
@ -152,6 +169,46 @@ namespace BMA.EHR.Placement.Service.Controllers
DurationStart = p.DurationStart,
DurationEnd = p.DurationEnd,
}),
RegistSubDistrict = x.RegistSubDistrict == null ? null : x.RegistSubDistrict.Name,
RegistSubDistrictId = x.RegistSubDistrict == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : x.RegistSubDistrict.Id,
RegistZipCode = x.RegistSubDistrict == null ? null : x.RegistSubDistrict.ZipCode,
RegistDistrict = x.RegistDistrict == null ? null : x.RegistDistrict.Name,
RegistDistrictId = x.RegistDistrict == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : x.RegistDistrict.Id,
RegistProvince = x.RegistProvince == null ? null : x.RegistProvince.Name,
RegistProvinceId = x.RegistProvince == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : x.RegistProvince.Id,
CurrentSubDistrict = x.CurrentSubDistrict == null ? null : x.CurrentSubDistrict.Name,
CurrentSubDistrictId = x.CurrentSubDistrict == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : x.CurrentSubDistrict.Id,
CurrentZipCode = x.CurrentSubDistrict == null ? null : x.CurrentSubDistrict.ZipCode,
CurrentDistrict = x.CurrentDistrict == null ? null : x.CurrentDistrict.Name,
CurrentDistrictId = x.CurrentDistrict == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : x.CurrentDistrict.Id,
CurrentProvince = x.CurrentProvince == null ? null : x.CurrentProvince.Name,
CurrentProvinceId = x.CurrentProvince == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : x.CurrentProvince.Id,
RegistSame = x.RegistSame,
MarryPrefix = x.MarryPrefix == null ? null : x.MarryPrefix.Name,
MarryPrefixId = x.MarryPrefix == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : x.MarryPrefix.Id,
Couple = x.Marry,
MarryFirstName = x.MarryFirstName,
MarryLastName = x.MarryLastName,
MarryOccupation = x.MarryOccupation,
FatherPrefix = x.FatherPrefix == null ? null : x.FatherPrefix.Name,
FatherPrefixId = x.FatherPrefix == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : x.FatherPrefix.Id,
FatherFirstName = x.FatherFirstName,
FatherLastName = x.FatherLastName,
FatherOccupation = x.FatherOccupation,
MotherPrefix = x.MotherPrefix == null ? null : x.MotherPrefix.Name,
MotherPrefixId = x.MotherPrefix == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : x.MotherPrefix.Id,
MotherFirstName = x.MotherFirstName,
MotherLastName = x.MotherLastName,
MotherOccupation = x.MotherOccupation,
Certificates = x.PlacementCertificates.Select(p => new
{
Id = p.Id,
CertificateNo = p.CertificateNo,
Issuer = p.Issuer,
IssueDate = p.IssueDate,
ExpireDate = p.ExpireDate,
CertificateType = p.CertificateType,
}),
PointA = x.PointA,
PointB = x.PointB,
PointC = x.PointC,
@ -346,7 +403,7 @@ namespace BMA.EHR.Placement.Service.Controllers
return Success();
}
[HttpGet("information/{personalId:length(36)}")]
[HttpPut("information/{personalId:length(36)}")]
public async Task<ActionResult<ResponseObject>> UpdateInformation([FromBody] PersonInformationRequest req, Guid personalId)
{
var person = await _context.PlacementProfiles.FindAsync(personalId);
@ -414,7 +471,7 @@ namespace BMA.EHR.Placement.Service.Controllers
return Success();
}
[HttpGet("address/{personalId:length(36)}")]
[HttpPut("address/{personalId:length(36)}")]
public async Task<ActionResult<ResponseObject>> UpdateAddress([FromBody] PersonAddressRequest req, Guid personalId)
{
var person = await _context.PlacementProfiles.FindAsync(personalId);
@ -480,7 +537,7 @@ namespace BMA.EHR.Placement.Service.Controllers
return Success();
}
[HttpGet("family/{personalId:length(36)}")]
[HttpPut("family/{personalId:length(36)}")]
public async Task<ActionResult<ResponseObject>> UpdateFamily([FromBody] PersonFamilyRequest req, Guid personalId)
{
var person = await _context.PlacementProfiles.FindAsync(personalId);
@ -568,6 +625,7 @@ namespace BMA.EHR.Placement.Service.Controllers
LastUpdateUserId = UserId ?? "",
LastUpdatedAt = DateTime.Now,
};
await _context.PlacementCertificates.AddAsync(data);
}
else
{