เพิ่ม api วันที่จ้างลูกจ้าง

This commit is contained in:
Kittapath 2023-10-24 18:22:20 +07:00
parent 929d9d5c96
commit 97b85a34e7
8 changed files with 17220 additions and 3 deletions

View file

@ -325,5 +325,6 @@ namespace BMA.EHR.Domain.Models.HR
public virtual List<ProfileChildren> Childrens { get; set; } = new List<ProfileChildren>();
public virtual List<ProfileChangeName> ChangeNames { get; set; } = new List<ProfileChangeName>();
public virtual List<ProfileEmployment> Employments { get; set; } = new List<ProfileEmployment>();
}
}

View file

@ -0,0 +1,16 @@
using System;
using System.ComponentModel.DataAnnotations;
using BMA.EHR.Domain.Models.Base;
using Microsoft.EntityFrameworkCore;
namespace BMA.EHR.Domain.Models.HR
{
public class ProfileEmployment : EntityBase
{
[Comment("คำสั่ง")]
public string? Command { get; set; }
[Comment("วันที่จ้าง")]
public DateTime? Date { get; set; }
public virtual Profile? Profile { get; set; }
}
}

View file

@ -0,0 +1,16 @@
using System;
using System.ComponentModel.DataAnnotations;
using BMA.EHR.Domain.Models.Base;
using Microsoft.EntityFrameworkCore;
namespace BMA.EHR.Domain.Models.HR
{
public class ProfileEmploymentHistory : EntityBase
{
[Comment("คำสั่ง")]
public string? Command { get; set; }
[Comment("วันที่จ้าง")]
public DateTime? Date { get; set; }
public virtual ProfileEmployment? ProfileEmployment { get; set; }
}
}

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,109 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace BMA.EHR.Infrastructure.Migrations
{
/// <inheritdoc />
public partial class addtableProfileEmployment : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
// migrationBuilder.AddColumn<string>(
// name: "RefCommandNo",
// table: "ProfileSalaries",
// type: "longtext",
// nullable: true,
// comment: "เอกสารอ้างอิง (เลขที่คำสั่ง)")
// .Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.CreateTable(
name: "ProfileEmployments",
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"),
Command = table.Column<string>(type: "longtext", nullable: true, comment: "คำสั่ง")
.Annotation("MySql:CharSet", "utf8mb4"),
Date = table.Column<DateTime>(type: "datetime(6)", nullable: true, comment: "วันที่จ้าง"),
ProfileId = table.Column<Guid>(type: "char(36)", nullable: true, collation: "ascii_general_ci")
},
constraints: table =>
{
table.PrimaryKey("PK_ProfileEmployments", x => x.Id);
table.ForeignKey(
name: "FK_ProfileEmployments_Profiles_ProfileId",
column: x => x.ProfileId,
principalTable: "Profiles",
principalColumn: "Id");
})
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.CreateTable(
name: "ProfileEmploymentHistorys",
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"),
Command = table.Column<string>(type: "longtext", nullable: true, comment: "คำสั่ง")
.Annotation("MySql:CharSet", "utf8mb4"),
Date = table.Column<DateTime>(type: "datetime(6)", nullable: true, comment: "วันที่จ้าง"),
ProfileEmploymentId = table.Column<Guid>(type: "char(36)", nullable: true, collation: "ascii_general_ci")
},
constraints: table =>
{
table.PrimaryKey("PK_ProfileEmploymentHistorys", x => x.Id);
table.ForeignKey(
name: "FK_ProfileEmploymentHistorys_ProfileEmployments_ProfileEmployme~",
column: x => x.ProfileEmploymentId,
principalTable: "ProfileEmployments",
principalColumn: "Id");
})
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.CreateIndex(
name: "IX_ProfileEmploymentHistorys_ProfileEmploymentId",
table: "ProfileEmploymentHistorys",
column: "ProfileEmploymentId");
migrationBuilder.CreateIndex(
name: "IX_ProfileEmployments_ProfileId",
table: "ProfileEmployments",
column: "ProfileId");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "ProfileEmploymentHistorys");
migrationBuilder.DropTable(
name: "ProfileEmployments");
// migrationBuilder.DropColumn(
// name: "RefCommandNo",
// table: "ProfileSalaries");
}
}
}

View file

@ -3092,6 +3092,136 @@ namespace BMA.EHR.Infrastructure.Migrations
b.ToTable("ProfileEducationHistorys");
});
modelBuilder.Entity("BMA.EHR.Domain.Models.HR.ProfileEmployment", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("char(36)")
.HasColumnOrder(0)
.HasComment("PrimaryKey")
.HasAnnotation("Relational:JsonPropertyName", "id");
b.Property<string>("Command")
.HasColumnType("longtext")
.HasComment("คำสั่ง");
b.Property<DateTime>("CreatedAt")
.HasColumnType("datetime(6)")
.HasColumnOrder(100)
.HasComment("สร้างข้อมูลเมื่อ");
b.Property<string>("CreatedFullName")
.IsRequired()
.HasMaxLength(200)
.HasColumnType("varchar(200)")
.HasColumnOrder(104)
.HasComment("ชื่อ User ที่สร้างข้อมูล");
b.Property<string>("CreatedUserId")
.IsRequired()
.HasMaxLength(40)
.HasColumnType("varchar(40)")
.HasColumnOrder(101)
.HasComment("User Id ที่สร้างข้อมูล");
b.Property<DateTime?>("Date")
.HasColumnType("datetime(6)")
.HasComment("วันที่จ้าง");
b.Property<string>("LastUpdateFullName")
.IsRequired()
.HasMaxLength(200)
.HasColumnType("varchar(200)")
.HasColumnOrder(105)
.HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด");
b.Property<string>("LastUpdateUserId")
.IsRequired()
.HasMaxLength(40)
.HasColumnType("varchar(40)")
.HasColumnOrder(103)
.HasComment("User Id ที่แก้ไขข้อมูลล่าสุด");
b.Property<DateTime?>("LastUpdatedAt")
.HasColumnType("datetime(6)")
.HasColumnOrder(102)
.HasComment("แก้ไขข้อมูลล่าสุดเมื่อ");
b.Property<Guid?>("ProfileId")
.HasColumnType("char(36)");
b.HasKey("Id");
b.HasIndex("ProfileId");
b.ToTable("ProfileEmployments");
});
modelBuilder.Entity("BMA.EHR.Domain.Models.HR.ProfileEmploymentHistory", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("char(36)")
.HasColumnOrder(0)
.HasComment("PrimaryKey")
.HasAnnotation("Relational:JsonPropertyName", "id");
b.Property<string>("Command")
.HasColumnType("longtext")
.HasComment("คำสั่ง");
b.Property<DateTime>("CreatedAt")
.HasColumnType("datetime(6)")
.HasColumnOrder(100)
.HasComment("สร้างข้อมูลเมื่อ");
b.Property<string>("CreatedFullName")
.IsRequired()
.HasMaxLength(200)
.HasColumnType("varchar(200)")
.HasColumnOrder(104)
.HasComment("ชื่อ User ที่สร้างข้อมูล");
b.Property<string>("CreatedUserId")
.IsRequired()
.HasMaxLength(40)
.HasColumnType("varchar(40)")
.HasColumnOrder(101)
.HasComment("User Id ที่สร้างข้อมูล");
b.Property<DateTime?>("Date")
.HasColumnType("datetime(6)")
.HasComment("วันที่จ้าง");
b.Property<string>("LastUpdateFullName")
.IsRequired()
.HasMaxLength(200)
.HasColumnType("varchar(200)")
.HasColumnOrder(105)
.HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด");
b.Property<string>("LastUpdateUserId")
.IsRequired()
.HasMaxLength(40)
.HasColumnType("varchar(40)")
.HasColumnOrder(103)
.HasComment("User Id ที่แก้ไขข้อมูลล่าสุด");
b.Property<DateTime?>("LastUpdatedAt")
.HasColumnType("datetime(6)")
.HasColumnOrder(102)
.HasComment("แก้ไขข้อมูลล่าสุดเมื่อ");
b.Property<Guid?>("ProfileEmploymentId")
.HasColumnType("char(36)");
b.HasKey("Id");
b.HasIndex("ProfileEmploymentId");
b.ToTable("ProfileEmploymentHistorys");
});
modelBuilder.Entity("BMA.EHR.Domain.Models.HR.ProfileFamilyHistory", b =>
{
b.Property<Guid>("Id")
@ -4712,6 +4842,10 @@ namespace BMA.EHR.Infrastructure.Migrations
b.Property<Guid?>("ProfileId")
.HasColumnType("char(36)");
b.Property<string>("RefCommandNo")
.HasColumnType("longtext")
.HasComment("เอกสารอ้างอิง (เลขที่คำสั่ง)");
b.Property<string>("SalaryClass")
.HasColumnType("longtext")
.HasComment("ตำแหน่ง (รายละเอียด)");
@ -14781,6 +14915,24 @@ namespace BMA.EHR.Infrastructure.Migrations
b.Navigation("ProfileEducation");
});
modelBuilder.Entity("BMA.EHR.Domain.Models.HR.ProfileEmployment", b =>
{
b.HasOne("BMA.EHR.Domain.Models.HR.Profile", "Profile")
.WithMany("Employments")
.HasForeignKey("ProfileId");
b.Navigation("Profile");
});
modelBuilder.Entity("BMA.EHR.Domain.Models.HR.ProfileEmploymentHistory", b =>
{
b.HasOne("BMA.EHR.Domain.Models.HR.ProfileEmployment", "ProfileEmployment")
.WithMany()
.HasForeignKey("ProfileEmploymentId");
b.Navigation("ProfileEmployment");
});
modelBuilder.Entity("BMA.EHR.Domain.Models.HR.ProfileFamilyHistory", b =>
{
b.HasOne("BMA.EHR.Domain.Models.HR.Profile", "Profile")
@ -16529,6 +16681,8 @@ namespace BMA.EHR.Infrastructure.Migrations
b.Navigation("Educations");
b.Navigation("Employments");
b.Navigation("FamilyHistory");
b.Navigation("FatherHistory");

View file

@ -239,6 +239,10 @@ namespace BMA.EHR.Infrastructure.Persistence
public DbSet<LimitTypeLeave> LimitTypeLeaves { get; set; }
public DbSet<ProfileEmployment> ProfileEmployments { get; set; }
public DbSet<ProfileEmploymentHistory> ProfileEmploymentHistorys { get; set; }
#endregion
#endregion

View file

@ -545,8 +545,8 @@ namespace BMA.EHR.Placement.Service.Controllers
/// <response code="400">ค่าตัวแปรที่ส่งมาไม่ถูกต้อง</response>
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
[HttpPost("report")]
public async Task<ActionResult<ResponseObject>> PostToReport([FromBody] PlacementProfileRequest req)
[HttpPost("report/{commandTypeId:length(36)}")]
public async Task<ActionResult<ResponseObject>> PostToReport([FromBody] PlacementProfileRequest req, Guid commandTypeId)
{
foreach (var item in req.Id)
{
@ -556,7 +556,7 @@ namespace BMA.EHR.Placement.Service.Controllers
if (uppdated == null)
continue;
// uppdated.CommandType = await _context.CommandTypes.FindAsync(commandTypeId);
uppdated.CommandType = await _context.CommandTypes.FindAsync(commandTypeId);
uppdated.Status = "REPORT";
uppdated.LastUpdateFullName = FullName ?? "System Administrator";
uppdated.LastUpdateUserId = UserId ?? "";