add commander position and leave approvers

This commit is contained in:
Suphonchai Phoonsawat 2025-04-17 09:31:05 +07:00
parent 59be7ac619
commit 885478f672
8 changed files with 1685 additions and 2 deletions

View file

@ -81,6 +81,8 @@ namespace BMA.EHR.Application.Responses.Profiles
public string? PositionLeaveName { get; set; }
public string? CommanderPositionName { get; set; } = string.Empty;
}
public class PosLevel

View file

@ -195,5 +195,7 @@ namespace BMA.EHR.Domain.Models.Leave.Requests
public string? CommanderPosition { get; set; } = string.Empty;
public List<LeaveRequestApprover> Approvers { get; set; } = new();
}
}

View file

@ -0,0 +1,27 @@
using BMA.EHR.Domain.Models.Base;
namespace BMA.EHR.Domain.Models.Leave.Requests
{
public class LeaveRequestApprover: EntityBase
{
public LeaveRequest LeaveRequest { get; set; }
public int Seq { get; set; } = 0;
public string Prefix { get; set; } = string.Empty;
public string FirstName { get; set; } = string.Empty;
public string LastName { get; set; } = string.Empty;
public string PositionName { get; set; } = string.Empty;
public Guid ProfileId { get; set; } = Guid.Empty;
public Guid KeycloakId { get; set; } = Guid.Empty;
public string ApproveStatus { get; set; } = string.Empty;
public string Comment { get; set; } = string.Empty;
}
}

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,71 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace BMA.EHR.Infrastructure.Migrations.LeaveDb
{
/// <inheritdoc />
public partial class AddLeaveApprovers : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "LeaveRequestApprovers",
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"),
LeaveRequestId = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
Seq = table.Column<int>(type: "int", nullable: false),
Prefix = table.Column<string>(type: "longtext", nullable: false)
.Annotation("MySql:CharSet", "utf8mb4"),
FirstName = table.Column<string>(type: "longtext", nullable: false)
.Annotation("MySql:CharSet", "utf8mb4"),
LastName = table.Column<string>(type: "longtext", nullable: false)
.Annotation("MySql:CharSet", "utf8mb4"),
PositionName = table.Column<string>(type: "longtext", nullable: false)
.Annotation("MySql:CharSet", "utf8mb4"),
ProfileId = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
KeycloakId = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
ApproveStatus = table.Column<string>(type: "longtext", nullable: false)
.Annotation("MySql:CharSet", "utf8mb4"),
Comment = table.Column<string>(type: "longtext", nullable: false)
.Annotation("MySql:CharSet", "utf8mb4")
},
constraints: table =>
{
table.PrimaryKey("PK_LeaveRequestApprovers", x => x.Id);
table.ForeignKey(
name: "FK_LeaveRequestApprovers_LeaveRequests_LeaveRequestId",
column: x => x.LeaveRequestId,
principalTable: "LeaveRequests",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
})
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.CreateIndex(
name: "IX_LeaveRequestApprovers_LeaveRequestId",
table: "LeaveRequestApprovers",
column: "LeaveRequestId");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "LeaveRequestApprovers");
}
}
}

View file

@ -608,6 +608,96 @@ namespace BMA.EHR.Infrastructure.Migrations.LeaveDb
b.ToTable("LeaveRequests");
});
modelBuilder.Entity("BMA.EHR.Domain.Models.Leave.Requests.LeaveRequestApprover", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("char(36)")
.HasColumnOrder(0)
.HasComment("PrimaryKey")
.HasAnnotation("Relational:JsonPropertyName", "id");
b.Property<string>("ApproveStatus")
.IsRequired()
.HasColumnType("longtext");
b.Property<string>("Comment")
.IsRequired()
.HasColumnType("longtext");
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<string>("FirstName")
.IsRequired()
.HasColumnType("longtext");
b.Property<Guid>("KeycloakId")
.HasColumnType("char(36)");
b.Property<string>("LastName")
.IsRequired()
.HasColumnType("longtext");
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>("LeaveRequestId")
.HasColumnType("char(36)");
b.Property<string>("PositionName")
.IsRequired()
.HasColumnType("longtext");
b.Property<string>("Prefix")
.IsRequired()
.HasColumnType("longtext");
b.Property<Guid>("ProfileId")
.HasColumnType("char(36)");
b.Property<int>("Seq")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("LeaveRequestId");
b.ToTable("LeaveRequestApprovers");
});
modelBuilder.Entity("BMA.EHR.Domain.Models.Leave.TimeAttendants.AdditionalCheckRequest", b =>
{
b.Property<Guid>("Id")
@ -1347,6 +1437,17 @@ namespace BMA.EHR.Infrastructure.Migrations.LeaveDb
b.Navigation("Type");
});
modelBuilder.Entity("BMA.EHR.Domain.Models.Leave.Requests.LeaveRequestApprover", b =>
{
b.HasOne("BMA.EHR.Domain.Models.Leave.Requests.LeaveRequest", "LeaveRequest")
.WithMany("Approvers")
.HasForeignKey("LeaveRequestId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("LeaveRequest");
});
modelBuilder.Entity("BMA.EHR.Domain.Models.Leave.TimeAttendants.UserDutyTime", b =>
{
b.HasOne("BMA.EHR.Domain.Models.Leave.TimeAttendants.DutyTime", "DutyTime")
@ -1360,6 +1461,8 @@ namespace BMA.EHR.Infrastructure.Migrations.LeaveDb
modelBuilder.Entity("BMA.EHR.Domain.Models.Leave.Requests.LeaveRequest", b =>
{
b.Navigation("Approvers");
b.Navigation("LeaveDocument");
});
#pragma warning restore 612, 618

View file

@ -34,6 +34,8 @@ namespace BMA.EHR.Infrastructure.Persistence
public DbSet<LeaveBeginning> LeaveBeginnings { get; set; }
public DbSet<LeaveRequestApprover> LeaveRequestApprovers { get; set; }
#endregion

View file

@ -357,6 +357,7 @@ namespace BMA.EHR.Leave.Service.Controllers
leaveRequest.LeaveTypeCode = leaveType.Code;
leaveRequest.Dear = approver;
leaveRequest.CommanderPosition = profile.CommanderPositionName ?? "";
// เพิ่มตำแหน่ง
//leaveRequest.CommanderPosition = req.CommanderPosition ?? "";
@ -643,8 +644,7 @@ namespace BMA.EHR.Leave.Service.Controllers
oldData.LeaveTypeCode = leaveType.Code;
oldData.Dear = profile.Commander ?? "";
//oldData.CommanderPosition = profile.CommanderPosition ?? "";
oldData.CommanderPosition = profile.CommanderPositionName ?? "";
oldData.PositionName = profile.Position == null ? "" : profile.Position;
@ -802,6 +802,8 @@ namespace BMA.EHR.Leave.Service.Controllers
FullName = $"{profile.Prefix}{profile.FirstName} {profile.LastName}",
Dear = profile.Commander ?? "",
CommanderPosition = profile.CommanderPositionName ?? "",
PositionName = profile.Position == null ? "" : profile.Position,
PositionLevelName = profile.PosLevel == null ? "" : profile.PosLevel,
OrganizationName = orgName, //profile.Oc ?? "",