api ตำแหน่ง draft

This commit is contained in:
Kittapath 2023-07-19 10:25:54 +07:00
parent 6b7fcaaba2
commit 6a572144ab
42 changed files with 32604 additions and 1 deletions

View file

@ -14,6 +14,7 @@ namespace BMA.EHR.Application
services.AddTransient<OrganizationEmployeeRepository>();
services.AddTransient<MessageQueueRepository>();
services.AddTransient<PlacementCommandRepository>();
// services.AddTransient<InsigniaPeriodsRepository>();
return services;
}

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,7 @@
namespace BMA.EHR.Application.Requests
{
public class InsigniaApproveRequest
{
public List<InsigniaReqApproveItem> Items { get; set; }
}
}

View file

@ -0,0 +1,15 @@
namespace BMA.EHR.Application.Requests
{
public class InsigniaItem
{
public Guid Id { get; set; }
public string Name { get; set; }
public string ShortName { get; set; }
public string Level { get; set; }
public Guid? LevelId { get; set; }
}
}

View file

@ -0,0 +1,19 @@
using Microsoft.EntityFrameworkCore;
namespace BMA.EHR.Application.Requests
{
public class InsigniaPeriodRequest
{
public string Name { get; set; }
public int Year { get; set; }
public DateTime StartDate { get; set; }
public DateTime EndDate { get; set; }
public string Amount { get; set; }
public string Type { get; set; }
}
}

View file

@ -0,0 +1,10 @@
namespace BMA.EHR.Application.Requests
{
public class InsigniaReqApproveItem
{
public Guid ProfileId { get; set; }
public bool IsApprove { get; set; } = false;
}
}

View file

@ -0,0 +1,9 @@
namespace BMA.EHR.Application.Requests
{
public class InsigniaRequestDoc
{
public int FileId { get; set; }
public int DocId { get; set; }
public string DocName { get; set; }
}
}

View file

@ -0,0 +1,22 @@
namespace BMA.EHR.Application.Requests
{
public class InsigniaRequestItem
{
public Guid ProfileId { get; set; }
public string FullName { get; set; }
public string Position { get; set; }
public string PosNo { get; set; }
public string Rank { get; set; }
public string Salary { get; set; }
public string LastInsignia { get; set; }
public string RequestInsignia { get; set; }
public string RequestInsigniaShortName { get; set; }
public string Level { get; set; }
public bool IsApprove { get; set; }
public DateTime? RequestDate { get; set; }
public string RequestNote { get; set; }
public List<InsigniaRequestDoc> Docs { get; set; }
public List<MatchingCondition> MatchingConditions { get; set; } = new List<MatchingCondition>();
}
}

View file

@ -0,0 +1,41 @@
using System.Collections.Generic;
namespace BMA.EHR.Application.Requests
{
public class InsigniaResultSet
{
public Guid ProfileId { get; set; }
public string Prefix { get; set; }
public string FullName { get; set; }
public string Position { get; set; }
public string Rank { get; set; }
public string GovAge { get; set; }
public string Salary { get; set; }
public string LastInsignia { get; set; }
public int? LastInsigniaId { get; set; }
public string PosNo { get; set; }
public InsigniaItem RequestInsignia { get; set; }
public string Gender { get; set; }
public int Seq { get; set; }
public List<MatchingCondition> MatchingConditions { get; set; } = new List<MatchingCondition>();
}
public class MatchingCondition
{
public string Condition { get; set; } = "";
public string Result { get; set; } = "";
}
}

View file

@ -0,0 +1,14 @@
using System.Collections.Generic;
namespace BMA.EHR.Application.Requests
{
public class InsigniaResults
{
public Guid PeriodId { get; set; }
public string Name { get; set; }
public string Year { get; set; }
public string RequestStatus { get; set; }
public string OrganizationName { get; set; }
public List<InsigniaRequestItem> Items { get; set; }
}
}

View file

@ -0,0 +1,9 @@
namespace BMA.EHR.Application.Requests
{
public class SaveRequsetNote
{
public Guid PeriodId { get; set; }
public Guid OcId { get; set; }
public string Note { get; set; }
}
}

View file

@ -0,0 +1,44 @@
using Microsoft.EntityFrameworkCore;
namespace BMA.EHR.Application.Requests
{
public class SaveToProfileRequest
{
public int OCId { get; set; }
public DateTime? InsigniaDatereceive { get; set; }
public string InsigniaLevel { get; set; }
public string InsigniaIssue { get; set; }
public int? InsigniaVolumeno { get; set; }
public string InsigniaVolume { get; set; }
public string InsigniaSection { get; set; }
public DateTime? InsigniaDateannounce { get; set; }
public List<ProfileInsignias> Profile { get; set; }
public List<DocReceive> Docs { get; set; }
}
public class ProfileInsignias
{
public string FkProfileId { get; set; }
public string InsigniaName { get; set; }
public string InsigniaPage { get; set; }
public string InsigniaNo { get; set; }
public int? Kp7InsigniaId { get; set; }
}
public class DocReceive
{
public int DocId { get; set; }
public int InsigniaType { get; set; }
public int Type { get; set; }
}
public class Kp7Item
{
public DateTime? InsigniaDatereceive { get; set; }
public string InsigniaLevel { get; set; }
public string InsigniaIssue { get; set; }
public int? InsigniaVolumeno { get; set; }
public string InsigniaVolume { get; set; }
public string InsigniaSection { get; set; }
public DateTime? InsigniaDateannounce { get; set; }
}
}

View file

@ -0,0 +1,27 @@
using Microsoft.EntityFrameworkCore;
using System.ComponentModel.DataAnnotations;
using BMA.EHR.Domain.Models.Base;
using System.ComponentModel.DataAnnotations.Schema;
namespace BMA.EHR.Domain.Models.Insignias
{
public class InsigniaPeriod : EntityBase
{
[Required, MaxLength(200)]
public string Name { get; set; }
public int Year { get; set; }
public DateTime StartDate { get; set; }
public DateTime EndDate { get; set; }
[MaxLength(50)]
public string Amount { get; set; }
[MaxLength(10)]
public string Type { get; set; }
public virtual List<InsigniaRequest> InsigniaRequests { get; set; }
}
}

View file

@ -0,0 +1,23 @@
using Microsoft.EntityFrameworkCore;
using System.ComponentModel.DataAnnotations;
using BMA.EHR.Domain.Models.Base;
using System.ComponentModel.DataAnnotations.Schema;
using BMA.EHR.Domain.Models.MetaData;
namespace BMA.EHR.Domain.Models.Insignias
{
public class InsigniaRequest : EntityBase
{
[Required, MaxLength(50)]
public string RequestStatus { get; set; }
[Column(TypeName = "text")]
public string RequestNote { get; set; }
public InsigniaPeriod Period { get; set; }
public OrganizationOrganization OrganizationOrganization { get; set; }
public virtual List<InsigniaRequestProfile> RequestProfiles { get; set; } = new List<InsigniaRequestProfile>();
}
}

View file

@ -0,0 +1,40 @@
using Microsoft.EntityFrameworkCore;
using System.ComponentModel.DataAnnotations;
using BMA.EHR.Domain.Models.Base;
using System.ComponentModel.DataAnnotations.Schema;
using BMA.EHR.Domain.Models.MetaData;
using BMA.EHR.Domain.Models.HR;
namespace BMA.EHR.Domain.Models.Insignias
{
public class InsigniaRequestProfile : EntityBase
{
[Required]
public DateTime RequestDate { get; set; }
public decimal? Salary { get; set; }
public bool IsApprove { get; set; } = false;
[MaxLength(50)]
public string QualificationStatus { get; set; }
[MaxLength(50)]
public string DocumentStatus { get; set; }
[Column(TypeName = "text")]
public string Note { get; set; }
[MaxLength(50)]
public string Special { get; set; }
[Column(TypeName = "text")]
public string MatchingConditions { get; set; }
public Profile Profile { get; set; }
public Insignia RequestInsignia { get; set; }
public InsigniaRequest Request { get; set; }
}
}

View file

@ -22,6 +22,9 @@ namespace BMA.EHR.Domain.Models.Placement
public Gender? Gender { get; set; }
[Comment("ลำดับที่สอบได้")]
public int? Number { get; set; }
[Comment("Id ตำแหน่งที่สอบได้")]
public PositionPath? PositionCandidate { get; set; }
[Comment("Id เลขที่ตำแหน่ง")]
public OrganizationPositionEntity? OrganizationPosition { get; set; }
[Comment("วันที่บรรจุ")]
@ -236,6 +239,9 @@ namespace BMA.EHR.Domain.Models.Placement
[Comment("ผลสมัครสอบ")]
public string? Pass { get; set; }
[Comment("ข้อมูลตำแหน่ง Draft")]
public bool? Draft { get; set; }
public virtual List<PlacementCertificate> PlacementCertificates { get; set; } = new List<PlacementCertificate>();
public virtual List<PlacementEducation> PlacementEducations { get; set; } = new List<PlacementEducation>();
}

View file

@ -63,5 +63,12 @@
#region " OrganizationEmployee "
public static readonly string OrganizationEmployeeNotFound = "ไม่พบข้อมูลโครงสร้างตำแหน่งลูกจ้าง";
#endregion
#region " Insignia "
public static readonly string InvalidInsigniaRequest = "ไม่พบข้อมูลการยื่นขอพระราชทานเครื่องราชย์ของหน่วยงานที่ระบุ!!";
public static readonly string InvalidInsigniaPeriod = "ไม่พบรอบการยื่นขอพระราชทานเครื่องราชย์อิสริยาภรณ์";
#endregion
}
}

View file

@ -0,0 +1,191 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace BMA.EHR.Infrastructure.Migrations
{
/// <inheritdoc />
public partial class UpdatetablePlacementProfileadddraft : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<bool>(
name: "Draft",
table: "PlacementProfiles",
type: "tinyint(1)",
nullable: true,
comment: "ข้อมูลตำแหน่ง Draft");
migrationBuilder.CreateTable(
name: "InsigniaPeriods",
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"),
Name = table.Column<string>(type: "varchar(200)", maxLength: 200, nullable: false)
.Annotation("MySql:CharSet", "utf8mb4"),
Year = table.Column<int>(type: "int", nullable: false),
StartDate = table.Column<DateTime>(type: "datetime(6)", nullable: false),
EndDate = table.Column<DateTime>(type: "datetime(6)", nullable: false),
Amount = table.Column<string>(type: "varchar(50)", maxLength: 50, nullable: false)
.Annotation("MySql:CharSet", "utf8mb4"),
Type = table.Column<string>(type: "varchar(10)", maxLength: 10, nullable: false)
.Annotation("MySql:CharSet", "utf8mb4")
},
constraints: table =>
{
table.PrimaryKey("PK_InsigniaPeriods", x => x.Id);
})
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.CreateTable(
name: "InsigniaRequests",
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"),
RequestStatus = table.Column<string>(type: "varchar(50)", maxLength: 50, nullable: false)
.Annotation("MySql:CharSet", "utf8mb4"),
RequestNote = table.Column<string>(type: "text", nullable: false)
.Annotation("MySql:CharSet", "utf8mb4"),
PeriodId = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
OrganizationOrganizationId = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci")
},
constraints: table =>
{
table.PrimaryKey("PK_InsigniaRequests", x => x.Id);
table.ForeignKey(
name: "FK_InsigniaRequests_InsigniaPeriods_PeriodId",
column: x => x.PeriodId,
principalTable: "InsigniaPeriods",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_InsigniaRequests_OrganizationOrganizations_OrganizationOrgan~",
column: x => x.OrganizationOrganizationId,
principalTable: "OrganizationOrganizations",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
})
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.CreateTable(
name: "InsigniaRequestProfiles",
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"),
RequestDate = table.Column<DateTime>(type: "datetime(6)", nullable: false),
Salary = table.Column<decimal>(type: "decimal(65,30)", nullable: true),
IsApprove = table.Column<bool>(type: "tinyint(1)", nullable: false),
QualificationStatus = table.Column<string>(type: "varchar(50)", maxLength: 50, nullable: false)
.Annotation("MySql:CharSet", "utf8mb4"),
DocumentStatus = table.Column<string>(type: "varchar(50)", maxLength: 50, nullable: false)
.Annotation("MySql:CharSet", "utf8mb4"),
Note = table.Column<string>(type: "text", nullable: false)
.Annotation("MySql:CharSet", "utf8mb4"),
Special = table.Column<string>(type: "varchar(50)", maxLength: 50, nullable: false)
.Annotation("MySql:CharSet", "utf8mb4"),
MatchingConditions = table.Column<string>(type: "text", nullable: false)
.Annotation("MySql:CharSet", "utf8mb4"),
ProfileId = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
RequestInsigniaId = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
RequestId = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci")
},
constraints: table =>
{
table.PrimaryKey("PK_InsigniaRequestProfiles", x => x.Id);
table.ForeignKey(
name: "FK_InsigniaRequestProfiles_InsigniaRequests_RequestId",
column: x => x.RequestId,
principalTable: "InsigniaRequests",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_InsigniaRequestProfiles_Insignias_RequestInsigniaId",
column: x => x.RequestInsigniaId,
principalTable: "Insignias",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_InsigniaRequestProfiles_Profiles_ProfileId",
column: x => x.ProfileId,
principalTable: "Profiles",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
})
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.CreateIndex(
name: "IX_InsigniaRequestProfiles_ProfileId",
table: "InsigniaRequestProfiles",
column: "ProfileId");
migrationBuilder.CreateIndex(
name: "IX_InsigniaRequestProfiles_RequestId",
table: "InsigniaRequestProfiles",
column: "RequestId");
migrationBuilder.CreateIndex(
name: "IX_InsigniaRequestProfiles_RequestInsigniaId",
table: "InsigniaRequestProfiles",
column: "RequestInsigniaId");
migrationBuilder.CreateIndex(
name: "IX_InsigniaRequests_OrganizationOrganizationId",
table: "InsigniaRequests",
column: "OrganizationOrganizationId");
migrationBuilder.CreateIndex(
name: "IX_InsigniaRequests_PeriodId",
table: "InsigniaRequests",
column: "PeriodId");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "InsigniaRequestProfiles");
migrationBuilder.DropTable(
name: "InsigniaRequests");
migrationBuilder.DropTable(
name: "InsigniaPeriods");
migrationBuilder.DropColumn(
name: "Draft",
table: "PlacementProfiles");
}
}
}

View file

@ -0,0 +1,50 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace BMA.EHR.Infrastructure.Migrations
{
/// <inheritdoc />
public partial class UpdatetablePlacementProfileaddpositioncandidate : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<Guid>(
name: "PositionCandidateId",
table: "PlacementProfiles",
type: "char(36)",
nullable: true,
collation: "ascii_general_ci");
migrationBuilder.CreateIndex(
name: "IX_PlacementProfiles_PositionCandidateId",
table: "PlacementProfiles",
column: "PositionCandidateId");
migrationBuilder.AddForeignKey(
name: "FK_PlacementProfiles_PositionPaths_PositionCandidateId",
table: "PlacementProfiles",
column: "PositionCandidateId",
principalTable: "PositionPaths",
principalColumn: "Id");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_PlacementProfiles_PositionPaths_PositionCandidateId",
table: "PlacementProfiles");
migrationBuilder.DropIndex(
name: "IX_PlacementProfiles_PositionCandidateId",
table: "PlacementProfiles");
migrationBuilder.DropColumn(
name: "PositionCandidateId",
table: "PlacementProfiles");
}
}
}

View file

@ -4820,6 +4820,252 @@ namespace BMA.EHR.Infrastructure.Migrations
b.ToTable("TypeLeaves");
});
modelBuilder.Entity("BMA.EHR.Domain.Models.Insignias.InsigniaPeriod", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("char(36)")
.HasColumnOrder(0)
.HasComment("PrimaryKey")
.HasAnnotation("Relational:JsonPropertyName", "id");
b.Property<string>("Amount")
.IsRequired()
.HasMaxLength(50)
.HasColumnType("varchar(50)");
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>("EndDate")
.HasColumnType("datetime(6)");
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<string>("Name")
.IsRequired()
.HasMaxLength(200)
.HasColumnType("varchar(200)");
b.Property<DateTime>("StartDate")
.HasColumnType("datetime(6)");
b.Property<string>("Type")
.IsRequired()
.HasMaxLength(10)
.HasColumnType("varchar(10)");
b.Property<int>("Year")
.HasColumnType("int");
b.HasKey("Id");
b.ToTable("InsigniaPeriods");
});
modelBuilder.Entity("BMA.EHR.Domain.Models.Insignias.InsigniaRequest", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("char(36)")
.HasColumnOrder(0)
.HasComment("PrimaryKey")
.HasAnnotation("Relational:JsonPropertyName", "id");
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>("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>("OrganizationOrganizationId")
.HasColumnType("char(36)");
b.Property<Guid>("PeriodId")
.HasColumnType("char(36)");
b.Property<string>("RequestNote")
.IsRequired()
.HasColumnType("text");
b.Property<string>("RequestStatus")
.IsRequired()
.HasMaxLength(50)
.HasColumnType("varchar(50)");
b.HasKey("Id");
b.HasIndex("OrganizationOrganizationId");
b.HasIndex("PeriodId");
b.ToTable("InsigniaRequests");
});
modelBuilder.Entity("BMA.EHR.Domain.Models.Insignias.InsigniaRequestProfile", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("char(36)")
.HasColumnOrder(0)
.HasComment("PrimaryKey")
.HasAnnotation("Relational:JsonPropertyName", "id");
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>("DocumentStatus")
.IsRequired()
.HasMaxLength(50)
.HasColumnType("varchar(50)");
b.Property<bool>("IsApprove")
.HasColumnType("tinyint(1)");
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<string>("MatchingConditions")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Note")
.IsRequired()
.HasColumnType("text");
b.Property<Guid>("ProfileId")
.HasColumnType("char(36)");
b.Property<string>("QualificationStatus")
.IsRequired()
.HasMaxLength(50)
.HasColumnType("varchar(50)");
b.Property<DateTime>("RequestDate")
.HasColumnType("datetime(6)");
b.Property<Guid>("RequestId")
.HasColumnType("char(36)");
b.Property<Guid>("RequestInsigniaId")
.HasColumnType("char(36)");
b.Property<decimal?>("Salary")
.HasColumnType("decimal(65,30)");
b.Property<string>("Special")
.IsRequired()
.HasMaxLength(50)
.HasColumnType("varchar(50)");
b.HasKey("Id");
b.HasIndex("ProfileId");
b.HasIndex("RequestId");
b.HasIndex("RequestInsigniaId");
b.ToTable("InsigniaRequestProfiles");
});
modelBuilder.Entity("BMA.EHR.Domain.Models.MetaData.BloodGroup", b =>
{
b.Property<Guid>("Id")
@ -9551,6 +9797,10 @@ namespace BMA.EHR.Infrastructure.Migrations
.HasColumnType("datetime(6)")
.HasComment("วันเกิด");
b.Property<bool?>("Draft")
.HasColumnType("tinyint(1)")
.HasComment("ข้อมูลตำแหน่ง Draft");
b.Property<string>("Email")
.HasMaxLength(200)
.HasColumnType("varchar(200)")
@ -9766,6 +10016,9 @@ namespace BMA.EHR.Infrastructure.Migrations
.HasColumnType("double")
.HasComment("คะแนนเต็มภาค ค");
b.Property<Guid?>("PositionCandidateId")
.HasColumnType("char(36)");
b.Property<Guid?>("PositionLevelId")
.HasColumnType("char(36)");
@ -9882,6 +10135,8 @@ namespace BMA.EHR.Infrastructure.Migrations
b.HasIndex("PlacementId");
b.HasIndex("PositionCandidateId");
b.HasIndex("PositionLevelId");
b.HasIndex("PositionLineId");
@ -10510,6 +10765,52 @@ namespace BMA.EHR.Infrastructure.Migrations
b.Navigation("ProfileTraining");
});
modelBuilder.Entity("BMA.EHR.Domain.Models.Insignias.InsigniaRequest", b =>
{
b.HasOne("BMA.EHR.Domain.Models.MetaData.OrganizationOrganization", "OrganizationOrganization")
.WithMany()
.HasForeignKey("OrganizationOrganizationId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("BMA.EHR.Domain.Models.Insignias.InsigniaPeriod", "Period")
.WithMany("InsigniaRequests")
.HasForeignKey("PeriodId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("OrganizationOrganization");
b.Navigation("Period");
});
modelBuilder.Entity("BMA.EHR.Domain.Models.Insignias.InsigniaRequestProfile", b =>
{
b.HasOne("BMA.EHR.Domain.Models.HR.Profile", "Profile")
.WithMany()
.HasForeignKey("ProfileId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("BMA.EHR.Domain.Models.Insignias.InsigniaRequest", "Request")
.WithMany("RequestProfiles")
.HasForeignKey("RequestId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("BMA.EHR.Domain.Models.MetaData.Insignia", "RequestInsignia")
.WithMany()
.HasForeignKey("RequestInsigniaId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Profile");
b.Navigation("Request");
b.Navigation("RequestInsignia");
});
modelBuilder.Entity("BMA.EHR.Domain.Models.MetaData.District", b =>
{
b.HasOne("BMA.EHR.Domain.Models.MetaData.Province", "Province")
@ -10956,6 +11257,10 @@ namespace BMA.EHR.Infrastructure.Migrations
.WithMany("PlacementProfiles")
.HasForeignKey("PlacementId");
b.HasOne("BMA.EHR.Domain.Models.MetaData.PositionPath", "PositionCandidate")
.WithMany()
.HasForeignKey("PositionCandidateId");
b.HasOne("BMA.EHR.Domain.Models.MetaData.PositionLevel", "PositionLevel")
.WithMany()
.HasForeignKey("PositionLevelId");
@ -11032,6 +11337,8 @@ namespace BMA.EHR.Infrastructure.Migrations
b.Navigation("Placement");
b.Navigation("PositionCandidate");
b.Navigation("PositionLevel");
b.Navigation("PositionLine");
@ -11211,6 +11518,16 @@ namespace BMA.EHR.Infrastructure.Migrations
b.Navigation("LimitTypeLeaves");
});
modelBuilder.Entity("BMA.EHR.Domain.Models.Insignias.InsigniaPeriod", b =>
{
b.Navigation("InsigniaRequests");
});
modelBuilder.Entity("BMA.EHR.Domain.Models.Insignias.InsigniaRequest", b =>
{
b.Navigation("RequestProfiles");
});
modelBuilder.Entity("BMA.EHR.Domain.Models.MetaData.District", b =>
{
b.Navigation("SubDistricts");

View file

@ -10,6 +10,7 @@ using BMA.EHR.Domain.Models.Placement;
using Microsoft.EntityFrameworkCore;
using BMA.EHR.Domain.Models.Commands.Core;
using BMA.EHR.Domain.Models.Commands;
using BMA.EHR.Domain.Models.Insignias;
namespace BMA.EHR.Infrastructure.Persistence
{
@ -281,6 +282,16 @@ namespace BMA.EHR.Infrastructure.Persistence
#endregion
#region " Insignia "
public DbSet<InsigniaPeriod> InsigniaPeriods { get; set; }
public DbSet<InsigniaRequest> InsigniaRequests { get; set; }
public DbSet<InsigniaRequestProfile> InsigniaRequestProfiles { get; set; }
#endregion
public ApplicationDBContext(DbContextOptions<ApplicationDBContext> options) : base(options)
{
}

View file

@ -0,0 +1,41 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<UserSecretsId>93677512-b64b-4a19-9e7d-dd283c7ec901</UserSecretsId>
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
<GenerateDocumentationFile>True</GenerateDocumentationFile>
<DockerfileContext>.</DockerfileContext>
<RootNamespace>BMA.EHR.Insignia.Service</RootNamespace>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="7.0.9" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="7.0.9" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Versioning" Version="5.1.0" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Versioning.ApiExplorer" Version="5.1.0" />
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="7.0.9" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="7.0.9">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.IdentityModel.Logging" Version="6.32.0" />
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.18.1" />
<PackageReference Include="runtime.osx.10.10-x64.CoreCompat.System.Drawing" Version="6.0.5.128" />
<PackageReference Include="Serilog.AspNetCore" Version="7.0.0" />
<PackageReference Include="Serilog.Sinks.Console" Version="4.1.0" />
<PackageReference Include="Sentry.AspNetCore" Version="3.33.1" />
<PackageReference Include="Serilog.Enrichers.Environment" Version="2.2.0" />
<PackageReference Include="Serilog.Exceptions" Version="8.4.0" />
<PackageReference Include="Serilog.Sinks.Debug" Version="2.0.0" />
<PackageReference Include="Serilog.Sinks.Elasticsearch" Version="9.0.3" />
<PackageReference Include="Swashbuckle.AspNetCore.Annotations" Version="6.5.0" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.5.0" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\BMA.EHR.Infrastructure\BMA.EHR.Infrastructure.csproj" />
</ItemGroup>
</Project>

View file

@ -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.Insignia.Service
{
public class ConfigureSwaggerOptions : IConfigureNamedOptions<SwaggerGenOptions>
{
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 Insignia 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;
}
}
}

View file

@ -0,0 +1,150 @@
using System.Security.Claims;
using BMA.EHR.Application.Repositories;
using BMA.EHR.Application.Requests;
using BMA.EHR.Domain.Common;
using BMA.EHR.Domain.Models.Insignias;
using BMA.EHR.Domain.Shared;
using BMA.EHR.Infrastructure.Persistence;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Swashbuckle.AspNetCore.Annotations;
namespace BMA.EHR.Insignia.Service.Controllers
{
[Route("api/v{version:apiVersion}/insignia/period")]
[ApiVersion("1.0")]
[ApiController]
[Produces("application/json")]
[Authorize]
[SwaggerTag("รอบเครื่องราช")]
public class InsigniaPeriodController : BaseController
{
private readonly ApplicationDBContext _context;
private readonly MinIOService _documentService;
private readonly IHttpContextAccessor _httpContextAccessor;
private readonly InsigniaPeriodsRepository _repository;
public InsigniaPeriodController(ApplicationDBContext context,
MinIOService documentService,
InsigniaPeriodsRepository repository,
IHttpContextAccessor httpContextAccessor)
{
_context = context;
_documentService = documentService;
_repository = repository;
_httpContextAccessor = httpContextAccessor;
}
#region " Properties "
private string? UserId => _httpContextAccessor?.HttpContext?.User?.FindFirst(ClaimTypes.NameIdentifier)?.Value;
private string? FullName => _httpContextAccessor?.HttpContext?.User?.FindFirst("name")?.Value;
#endregion
[HttpGet("{type}")]
public async Task<ActionResult<ResponseObject>> GetList(string type)
{
var data = _context.InsigniaPeriods.AsQueryable()
.Where(x => x.Type == type)
.OrderByDescending(x => x.Year)
.ThenByDescending(x => x.StartDate)
.Select(p => new
{
period_id = p.Id,
period_amount = p.Amount,
period_name = p.Name,
period_start = p.StartDate,
period_end = p.EndDate,
period_status = _repository.CalStatusByDate(p.StartDate, p.EndDate, p.Year.ToString()),
period_year = p.Year
})
.ToList();
return Success(data);
}
[HttpGet("{id:length(36)}")]
public async Task<ActionResult<ResponseObject>> GetById(Guid id)
{
var data = _context.InsigniaPeriods.AsQueryable()
.Where(x => x.Id == id)
.Select(p => new
{
period_id = p.Id,
period_amount = p.Amount,
period_name = p.Name,
period_start = p.StartDate,
period_end = p.EndDate,
period_status = _repository.CalStatusByDate(p.StartDate, p.EndDate, p.Year.ToString()),
period_year = p.Year,
docs = new List<dynamic>()
})
.FirstOrDefault();
return Success(data);
}
[HttpPost("{type}")]
public async Task<ActionResult<ResponseObject>> Post([FromBody] InsigniaPeriodRequest req, string type)
{
if (req == null)
return BadRequest();
var period = new InsigniaPeriod
{
Name = req.Name,
Year = req.Year,
StartDate = req.StartDate,
EndDate = req.EndDate,
Amount = req.Amount,
Type = type
};
_context.InsigniaPeriods.Add(period);
_context.SaveChanges();
return Success();
}
[HttpDelete("{id:length(36)}")]
public async Task<ActionResult<ResponseObject>> Delete(Guid id)
{
var deleted = _context.InsigniaPeriods.AsQueryable()
.FirstOrDefault(x => x.Id == id);
if (deleted == null)
return NotFound();
_context.InsigniaPeriods.Remove(deleted);
_context.SaveChanges();
return Success();
}
[HttpPut("{type}/{id:length(36)}")]
public async Task<ActionResult<ResponseObject>> Put([FromBody] InsigniaPeriodRequest req, Guid id, string type)
{
if (req == null)
return BadRequest();
var uppdated = _context.InsigniaPeriods.AsQueryable()
.FirstOrDefault(x => x.Id == id);
if (uppdated == null)
return NotFound();
uppdated.Name = req.Name;
uppdated.Year = req.Year;
uppdated.StartDate = req.StartDate;
uppdated.EndDate = req.EndDate;
uppdated.Amount = req.Amount;
uppdated.Type = type;
_context.SaveChanges();
return Success();
}
}
}

View file

@ -0,0 +1,213 @@
using System.Security.Claims;
using BMA.EHR.Application.Repositories;
using BMA.EHR.Application.Requests;
using BMA.EHR.Domain.Common;
using BMA.EHR.Domain.Models.Insignias;
using BMA.EHR.Domain.Shared;
using BMA.EHR.Infrastructure.Persistence;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Swashbuckle.AspNetCore.Annotations;
namespace BMA.EHR.Insignia.Service.Controllers
{
[Route("api/v{version:apiVersion}/insignia/receive")]
[ApiVersion("1.0")]
[ApiController]
[Produces("application/json")]
[Authorize]
[SwaggerTag("เครื่องราช")]
public class InsigniaReceiveController : BaseController
{
private readonly ApplicationDBContext _context;
private readonly MinIOService _documentService;
private readonly IHttpContextAccessor _httpContextAccessor;
private readonly InsigniaPeriodsRepository _repository;
public InsigniaReceiveController(ApplicationDBContext context,
MinIOService documentService,
InsigniaPeriodsRepository repository,
IHttpContextAccessor httpContextAccessor)
{
_context = context;
_documentService = documentService;
_repository = repository;
_httpContextAccessor = httpContextAccessor;
}
[HttpGet("{type}/{ocId:length(36)}")]
public async Task<ActionResult<ResponseObject>> GetInsigniaList(string type, Guid ocId)
{
var result = _repository.GetInsigniaRequest(type, ocId);
if (result == null)
{
return NotFound();
}
else
{
// var request = _context.InsigniaRequestProfiles
// .Include(x => x.Request)
// .ThenInclude(x => x.Period)
// .Include(x => x.RequestInsignia)
// .ThenInclude(x => x.InsigniaType)
// .Include(x => x.Profile)
// .ThenInclude(x => x.AcademicStanding)
// .Include(x => x.Profile)
// .ThenInclude(x => x.Position)
// .Include(x => x.Profile)
// .ThenInclude(x => x.Insignias)
// .ThenInclude(x => x.Insignia)
// .ThenInclude(x => x.InsigniaType)
// .Include(x => x.Profile)
// .ThenInclude(x => x.PositionNumber)
// .Where(x => x.Request.Period.Id == result.PeriodId)
// .Where(x => x.Request.RequestStatus == "st5p")
// .Where(x => x.IsApprove)
// .Select(p => new
// {
// Profile = p.Profile.Id,
// Name = $"{p.Profile.Prefix} {p.Profile.FirstName} {p.Profile.LastName}",
// Insignia = p.RequestInsignia,
// Type = p.RequestInsignia.InsigniaType,
// IsApprove = p.IsApprove,
// InsigniaId = p.RequestInsignia.Id,
// Year = p.Request.Period.Year,
// Special = p.Special,
// LastInsignia = p.Profile.Insignias.AsQueryable()
// .Include(x => x.Insignia)
// .Where(x => x.Insignia.Id == p.RequestInsignia.Id)
// .Where(x => x.Year == p.Request.Period.Year)
// .FirstOrDefault()
// })
// .ToList()
// .Select(r => new InsigniaReceiveResponse
// {
// Profile = r.Profile,
// Name = r.Name,
// Insignia = r.Insignia.Name,
// TypeId = r.Type == null ? null : r.Type.Id,
// TypeName = r.Type == null ? "" : r.Type.Description,
// IsApprove = r.IsApprove,
// InsigniaId = r.InsigniaId,
// InsigniaPage = r.LastInsignia == null ? "" : r.LastInsignia.Page,
// InsigniaNo = r.LastInsignia == null ? "" : r.LastInsignia.No,
// InsigniaIssue = r.LastInsignia == null ? "" : r.LastInsignia.Issue,
// InsigniaVolumeno = r.LastInsignia == null ? "" : r.LastInsignia.VolumeNo,
// InsigniaVolume = r.LastInsignia == null ? "" : r.LastInsignia.Volume,
// InsigniaSection = r.LastInsignia == null ? "" : r.LastInsignia.Section,
// InsigniaDatereceive = r.LastInsignia == null ? null : r.LastInsignia.DateReceive,
// InsigniaDateannounce = r.LastInsignia == null ? null : r.LastInsignia.DateAnnounce,
// Special = r.Special
// })
// .ToList()
// .GroupBy(r => new { r.TypeId, r.TypeName })
// .Select(r => new
// {
// TypeId = r.Key.TypeId,
// InsigniaIssue = r.Where(r => r.InsigniaIssue != "").FirstOrDefault() != null ? r.Where(r => r.InsigniaIssue != "").FirstOrDefault().InsigniaIssue : "",
// InsigniaVolumeno = r.Where(r => r.InsigniaIssue != "").FirstOrDefault() != null ? r.Where(r => r.InsigniaIssue != "").FirstOrDefault().InsigniaVolumeno : null,
// InsigniaVolume = r.Where(r => r.InsigniaIssue != "").FirstOrDefault() != null ? r.Where(r => r.InsigniaIssue != "").FirstOrDefault().InsigniaVolume : "",
// InsigniaSection = r.Where(r => r.InsigniaIssue != "").FirstOrDefault() != null ? r.Where(r => r.InsigniaIssue != "").FirstOrDefault().InsigniaSection : "",
// InsigniaDatereceive = r.Where(r => r.InsigniaIssue != "").FirstOrDefault() != null ? r.Where(r => r.InsigniaIssue != "").FirstOrDefault().InsigniaDatereceive : null,
// InsigniaDateannounce = r.Where(r => r.InsigniaIssue != "").FirstOrDefault() != null ? r.Where(r => r.InsigniaIssue != "").FirstOrDefault().InsigniaDateannounce : null,
// TypeName = r.Key.TypeName,
// Profile = r.Select(r => new
// {
// Profile = r.Profile,
// Name = r.Name,
// Insignia = r.Insignia,
// InsigniaId = r.InsigniaId,
// InsigniaPage = r.InsigniaPage,
// InsigniaNo = r.InsigniaNo,
// //Special = bool.Parse(r.Special)
// }).ToList(),
// Docs = new List<dynamic>()
// });
return Success();
// return Success(request);
}
}
[HttpPost("{type}")]
public async Task<ActionResult<ResponseObject>> SaveToProfile([FromBody] SaveToProfileRequest items, string type)
{
var item = new Kp7Item
{
InsigniaDatereceive = items.InsigniaDatereceive,
InsigniaLevel = items.InsigniaLevel,
InsigniaIssue = items.InsigniaIssue,
InsigniaVolumeno = items.InsigniaVolumeno,
InsigniaVolume = items.InsigniaVolume,
InsigniaSection = items.InsigniaSection,
InsigniaDateannounce = items.InsigniaDateannounce
};
if (items.Profile.Count() != 0)
{
// foreach (var i in items.Profile)
// {
// var profile = _context.Profiles.AsQueryable()
// .Include(x => x.Insignias)
// .ThenInclude(x => x.Insignia)
// .Where(x => x.Id == i.FkProfileId)
// .FirstOrDefault();
// if (profile != null)
// {
// var kp7 = profile.Insignias.AsQueryable()
// .Where(x => x.Insignia.Id == i.Kp7InsigniaId)
// .FirstOrDefault();
// if (kp7 != null)
// {
// // exit item update to database
// kp7.DateReceive = items.InsigniaDatereceive.Value;
// kp7.Level = items.InsigniaLevel;
// kp7.Issue = items.InsigniaIssue;
// kp7.VolumeNo = items.InsigniaVolumeno.Value.ToString();
// kp7.Volume = items.InsigniaVolume;
// kp7.Section = items.InsigniaSection;
// kp7.DateAnnounce = items.InsigniaDateannounce.Value;
// kp7.Page = i.InsigniaPage;
// kp7.No = i.InsigniaNo;
// }
// else
// {
// // insert new item to kp7
// var insignia_item = _context.Insignias.FirstOrDefault(x => x.Id == i.Kp7InsigniaId);
// var result = _repository.GetInsigniaRequest(type, items.OCId);
// var period = _context.InsigniaPeriods.FirstOrDefault(x => x.Id == result.PeriodId);
// kp7 = new Models.HR.ProfileInsignia
// {
// Order = profile.Insignias.ToList().Count + 1,
// Year = period.Year,
// Insignia = insignia_item,
// DateReceive = items.InsigniaDatereceive.Value,
// DateStamp = DateTime.Now,
// Level = items.InsigniaLevel,
// Issue = items.InsigniaIssue,
// VolumeNo = items.InsigniaVolumeno.Value.ToString(),
// Volume = items.InsigniaVolume,
// Section = items.InsigniaSection,
// DateAnnounce = items.InsigniaDateannounce.Value,
// Page = i.InsigniaPage,
// No = i.InsigniaNo,
// };
// profile.Insignias.Add(kp7);
// }
// }
// else
// return NotFound("Profile not found!!!");
// }
}
_context.SaveChanges();
return Success();
}
}
}

View file

@ -0,0 +1,509 @@
using System.Security.Claims;
using BMA.EHR.Application.Repositories;
using BMA.EHR.Application.Requests;
using BMA.EHR.Domain.Common;
using BMA.EHR.Domain.Models.Insignias;
using BMA.EHR.Domain.Shared;
using BMA.EHR.Infrastructure.Persistence;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
using Newtonsoft.Json;
using Swashbuckle.AspNetCore.Annotations;
namespace BMA.EHR.Insignia.Service.Controllers
{
[Route("api/v{version:apiVersion}/insignia/request")]
[ApiVersion("1.0")]
[ApiController]
[Produces("application/json")]
[Authorize]
[SwaggerTag("เครื่องราช")]
public class InsigniaRequestController : BaseController
{
private readonly ApplicationDBContext _context;
private readonly MinIOService _documentService;
private readonly IHttpContextAccessor _httpContextAccessor;
private readonly InsigniaPeriodsRepository _repository;
private readonly string Royal_Type = "Royal";
public InsigniaRequestController(ApplicationDBContext context,
MinIOService documentService,
InsigniaPeriodsRepository repository,
IHttpContextAccessor httpContextAccessor)
{
_context = context;
_documentService = documentService;
_repository = repository;
_httpContextAccessor = httpContextAccessor;
}
#region " Private "
private static string GetRequestlStatusText(string status)
{
switch (status.ToLower())
{
case "st1": return "จัดทำรายชื่อ";
case "st2": return "รอ ผอ. โรงเรียนรับรอง";
case "st3": return "รอเจ้าหน้าที่เขตตรวจสอบ";
case "st3p": return "รอนำเสนอผู้อำนวยการเขต";
case "st4": return "รอเสนอสำนักการศึกษา";
case "st5": return "รอเจ้าหน้าที่ สนศ. ตรวจสอบ";
case "st5p": return "เจ้าหน้าที่ สนศ. ตรวจสอบแล้ว";
case "pending": return "รอออกคำสั่ง";
case "finish": return "ออกคำสั่งแล้ว";
default: return "สถานะไม่ถูกต้อง";
}
}
#endregion
#region " ดึงเครื่องราชฯ ล่าสุดของครู (GetInsigniaLast) "
private InsigniaItem GetInsigniaLast(Guid? id)
{
var insignia = _context.Insignias.AsQueryable()
.Where(i => id != null ? i.Id == id : i.Name.Contains("ตริตาภรณ์มงกุฎไทย")).Select(i => new InsigniaItem
{
Id = i.Id,
Name = i.Name,
ShortName = i.ShortName,
Level = i.InsigniaType == null ? null : i.InsigniaType.Name,
LevelId = i.InsigniaType == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : i.InsigniaType.Id
}).FirstOrDefault();
return insignia;
}
#endregion
#region " จัดทำรายชื่อครูที่มีสิทธิในการยืนขอเครื่องราชฯ "
[HttpGet("old/{role}/{ocId:length(36)}")]
public async Task<ActionResult<ResponseObject>> GetInsignaiRequest(Guid ocId, string role)
{
var result = await _repository.GetInsigniaRequest(Royal_Type, ocId);
if (result != null)
{
Guid period = result.PeriodId;
string periodName = result.Name;
string requestStatus = result.RequestStatus;
var resend = new InsigniaResults
{
PeriodId = period,
Year = result.Year,
Name = periodName,
RequestStatus = requestStatus,
OrganizationName = result.OrganizationName,
Items = new List<InsigniaRequestItem>()
};
var candidate = _repository.GetInsigniaCandidate(period, ocId);
// ตรวจสอบว่ารายการอยู่ใน table insignia_request_new
if (requestStatus == null)
{
// บันทึกรายชื่อ
_repository.InsertCandidate(period, ocId, candidate);
}
if (role == "officer")
{
resend.Items = _repository.InsigniaHasProfile(period, ocId);
return Success(resend);
}
else
{
var passData = _context.InsigniaRequests.AsQueryable()
.Include(x => x.OrganizationOrganization)
.Include(x => x.RequestProfiles)
.Where(x => x.OrganizationOrganization.Id == ocId)
.Where(x => x.Period.Id == period)
.Select(ir => new
{
requstID = ir.Id,
requstStatus = ir.RequestStatus,
requstStatusName = GetRequestlStatusText(ir.RequestStatus),
fkInstituteId = -1,
fkDivisionId = ir.OrganizationOrganization.Id,
fkDivision = ir.OrganizationOrganization.Name,
fkInstitute = "",
fkPeriodId = ir.Period.Id,
insigniaRequestHasProfile = ir.RequestProfiles.AsQueryable()
.Include(x => x.Profile)
.ThenInclude(x => x.Position)
.Include(x => x.Profile)
// .ThenInclude(x => x.PositionNumber)
.Include(x => x.Profile)
// .ThenInclude(x => x.AcademicStanding)
.Include(x => x.RequestInsignia)
.ThenInclude(x => x.InsigniaType)
.Select(irp => new
{
request_id = irp.Request.Id,
isApprove = irp.IsApprove,
statusInstitute = irp.IsApprove.ToString(),
request_date = irp.RequestDate,
profileId = irp.Profile.Id,
// prefix = irp.Profile.Prefix,
firstname = irp.Profile.FirstName,
lastname = irp.Profile.LastName,
// posno = irp.Profile.PositionNumber.Id,
type = irp.Profile.ProfileType,
// position = irp.Profile.Position.Name,
// rank = irp.Profile.AcademicStanding.Name,
instituteName = "",
instituteId = -1,
// divisionName = irp.Profile.OrganizationOrganization.Name,
// divisionId = irp.Profile.OrganizationOrganization.Id,
lastInsigniaName = "",
requestInsigniaLevel = irp.RequestInsignia.InsigniaType == null ? null : irp.RequestInsignia.InsigniaType.Name,
requestInsigniaName = irp.RequestInsignia.Name,
requestQua = irp.QualificationStatus,
requestDoc = irp.DocumentStatus,
requestNote = irp.Note,
requestSalary = irp.Salary,
})
.Where(x => x.isApprove)
.OrderBy(y => y.profileId)
.ToList()
})
.ToList()
.FirstOrDefault();
var failData = _context.InsigniaRequests.AsQueryable()
.Include(x => x.OrganizationOrganization)
.Include(x => x.RequestProfiles)
.Where(x => x.OrganizationOrganization.Id == ocId)
.Where(x => x.Period.Id == period)
.Select(ir => new
{
requstID = ir.Id,
requstStatus = ir.RequestStatus,
requstStatusName = GetRequestlStatusText(ir.RequestStatus),
fkInstituteId = -1,
fkDivisionId = ir.OrganizationOrganization.Id,
fkDivision = ir.OrganizationOrganization.Name,
fkInstitute = "",
fkPeriodId = ir.Period.Id,
insigniaRequestHasProfile = ir.RequestProfiles.AsQueryable()
.Include(x => x.Profile)
.ThenInclude(x => x.Position)
.Include(x => x.Profile)
// .ThenInclude(x => x.PositionNumber)
.Include(x => x.Profile)
// .ThenInclude(x => x.AcademicStanding)
.Include(x => x.RequestInsignia)
.ThenInclude(x => x.InsigniaType)
.Select(irp => new
{
request_id = irp.Request.Id,
isApprove = irp.IsApprove,
statusInstitute = irp.IsApprove.ToString(),
request_date = irp.RequestDate,
profileId = irp.Profile.Id,
// prefix = irp.Profile.Prefix,
firstname = irp.Profile.FirstName,
lastname = irp.Profile.LastName,
// posno = irp.Profile.PositionNumber.Id,
type = irp.Profile.ProfileType,
// position = irp.Profile.Position.Name,
// rank = irp.Profile.AcademicStanding.Name,
instituteName = "",
instituteId = -1,
// divisionName = irp.Profile.OrganizationOrganization.Name,
// divisionId = irp.Profile.OrganizationOrganization.Id,
lastInsigniaName = "",
requestInsigniaLevel = irp.RequestInsignia.InsigniaType == null ? null : irp.RequestInsignia.InsigniaType.Name,
requestInsigniaName = irp.RequestInsignia.Name,
requestQua = irp.QualificationStatus,
requestDoc = irp.DocumentStatus,
requestNote = irp.Note,
requestSalary = irp.Salary,
})
.Where(x => !x.isApprove)
.OrderBy(y => y.profileId)
.ToList()
})
.ToList()
.FirstOrDefault();
var period_data = (from p in _context.InsigniaPeriods.AsQueryable()
where p.Id == period
select new
{
periodName = p.Name,
periodYear = p.Year,
}).FirstOrDefault();
return Success(new { passData = passData, failData = failData, period = period_data });
}
// select data to display
}
return Success();
}
[HttpGet("{role}/{ocId:length(36)}")]
public async Task<ActionResult<ResponseObject>> GetInsignaiRequestBkk(Guid ocId, string role)
{
var result = await _repository.GetInsigniaRequest(Royal_Type, ocId);
if (result != null)
{
Guid period = result.PeriodId;
string periodName = result.Name;
string requestStatus = result.RequestStatus;
var resend = new InsigniaResults
{
PeriodId = period,
Year = result.Year,
Name = periodName,
RequestStatus = requestStatus,
OrganizationName = result.OrganizationName,
Items = new List<InsigniaRequestItem>()
};
var candidate = _repository.GetInsigniaCandidateBKK(period, ocId);
// ตรวจสอบว่ารายการอยู่ใน table insignia_request_new
if (requestStatus == null)
{
// บันทึกรายชื่อ
_repository.InsertCandidate(period, ocId, candidate);
}
if (role == "officer")
{
resend.Items = _repository.InsigniaHasProfile(period, ocId);
return Success(resend);
}
else
{
var passData = _context.InsigniaRequests.AsQueryable()
.Include(x => x.OrganizationOrganization)
.Include(x => x.RequestProfiles)
.Where(x => x.OrganizationOrganization.Id == ocId)
.Where(x => x.Period.Id == period)
.Select(ir => new
{
requstID = ir.Id,
requstStatus = ir.RequestStatus,
requstStatusName = GetRequestlStatusText(ir.RequestStatus),
fkInstituteId = -1,
fkDivisionId = ir.OrganizationOrganization.Id,
fkDivision = ir.OrganizationOrganization.Name,
fkInstitute = "",
fkPeriodId = ir.Period.Id,
insigniaRequestHasProfile = ir.RequestProfiles.AsQueryable()
.Include(x => x.Profile)
.ThenInclude(x => x.Position)
.Include(x => x.Profile)
// .ThenInclude(x => x.PositionNumber)
.Include(x => x.Profile)
// .ThenInclude(x => x.AcademicStanding)
.Include(x => x.RequestInsignia)
.ThenInclude(x => x.InsigniaType)
.Select(irp => new
{
request_id = irp.Request.Id,
isApprove = irp.IsApprove,
statusInstitute = irp.IsApprove.ToString(),
request_date = irp.RequestDate,
profileId = irp.Profile.Id,
// prefix = irp.Profile.Prefix,
firstname = irp.Profile.FirstName,
lastname = irp.Profile.LastName,
// posno = irp.Profile.PositionNumber.Id,
type = irp.Profile.ProfileType,
// position = irp.Profile.Position.Name,
// rank = $"{irp.Profile.PositionType.Name}/{irp.Profile.PositionLevel.Name}",
instituteName = "",
instituteId = -1,
// divisionName = irp.Profile.OrganizationOrganization.Name,
// divisionId = irp.Profile.OrganizationOrganization.Id,
lastInsigniaName = "",
requestInsigniaLevel = irp.RequestInsignia.InsigniaType.Name,
requestInsigniaName = irp.RequestInsignia.Name,
requestQua = irp.QualificationStatus,
requestDoc = irp.DocumentStatus,
requestNote = irp.Note,
requestSalary = irp.Salary,
matchingConditions = JsonConvert.DeserializeObject<List<MatchingCondition>>(irp.MatchingConditions)
})
.Where(x => x.isApprove)
.OrderBy(y => y.profileId)
.ToList()
})
.ToList()
.FirstOrDefault();
var failData = _context.InsigniaRequests.AsQueryable()
.Include(x => x.OrganizationOrganization)
.Include(x => x.RequestProfiles)
.Where(x => x.OrganizationOrganization.Id == ocId)
.Where(x => x.Period.Id == period)
.Select(ir => new
{
requstID = ir.Id,
requstStatus = ir.RequestStatus,
requstStatusName = GetRequestlStatusText(ir.RequestStatus),
fkInstituteId = -1,
fkDivisionId = ir.OrganizationOrganization.Id,
fkDivision = ir.OrganizationOrganization.Name,
fkInstitute = "",
fkPeriodId = ir.Period.Id,
insigniaRequestHasProfile = ir.RequestProfiles.AsQueryable()
.Include(x => x.Profile)
.ThenInclude(x => x.Position)
.Include(x => x.Profile)
// .ThenInclude(x => x.PositionNumber)
.Include(x => x.Profile)
// .ThenInclude(x => x.AcademicStanding)
.Include(x => x.RequestInsignia)
.ThenInclude(x => x.InsigniaType)
.Select(irp => new
{
request_id = irp.Request.Id,
isApprove = irp.IsApprove,
statusInstitute = irp.IsApprove.ToString(),
request_date = irp.RequestDate,
profileId = irp.Profile.Id,
// prefix = irp.Profile.Prefix,
firstname = irp.Profile.FirstName,
lastname = irp.Profile.LastName,
// posno = irp.Profile.PositionNumber.Id,
type = irp.Profile.ProfileType,
// position = irp.Profile.Position.Name,
// rank = irp.Profile.AcademicStanding.Name,
instituteName = "",
instituteId = -1,
// divisionName = irp.Profile.OrganizationOrganization.Name,
// divisionId = irp.Profile.OrganizationOrganization.Id,
lastInsigniaName = "",
requestInsigniaLevel = irp.RequestInsignia.InsigniaType.Name,
requestInsigniaName = irp.RequestInsignia.Name,
requestQua = irp.QualificationStatus,
requestDoc = irp.DocumentStatus,
requestNote = irp.Note,
requestSalary = irp.Salary,
matchingConditions = JsonConvert.DeserializeObject<List<MatchingCondition>>(irp.MatchingConditions)
})
.Where(x => !x.isApprove)
.OrderBy(y => y.profileId)
.ToList()
})
.ToList()
.FirstOrDefault();
var period_data = (from p in _context.InsigniaPeriods.AsQueryable()
where p.Id == period
select new
{
periodName = p.Name,
periodYear = p.Year,
}).FirstOrDefault();
return Success(new { passData = passData, failData = failData, period = period_data });
}
// select data to display
}
return Success();
}
#endregion
#region " บันทึกหมายเหตุ "
[HttpPut("note/{profileId}")]
public async Task<ActionResult<ResponseObject>> SaveNote(Guid profileId, SaveRequsetNote items)
{
var id = await _repository.GetRequestId(items.PeriodId, items.OcId);
var note = _context.InsigniaRequestProfiles.AsQueryable()
.Where(d => d.Profile.Id == profileId && d.Request.Id == id).FirstOrDefault();
if (note != null)
note.Note = items.Note;
_context.SaveChanges();
return Success();
}
#endregion
#region " บันทึกรายชื่อครูในการขอยื่นเครื่องราชฯ เเต่ยังไม่ส่งไปยัง ผอ.โรงเรียน "
[HttpPut("approve/{ocId:length(36)}")]
public async Task<ActionResult<ResponseObject>> SaveRequestList(Guid ocId, InsigniaApproveRequest items)
{
var result = await _repository.GetInsigniaRequest(Royal_Type, ocId);
if (result != null)
await _repository.SaveAprove(result.PeriodId, ocId, items);
return Success();
}
#endregion
#region " เปลี่ยน status เป็น st2 รอ ผอ.สำนักรับรอง "
[HttpPost("status/officer/send/{ocId:length(36)}")]
public async Task<ActionResult<ResponseObject>> ChangeStatusToSt2(Guid ocId, InsigniaApproveRequest items)
{
var result = await _repository.GetInsigniaRequest(Royal_Type, ocId);
if (items != null)
{
_repository.SaveAprove(result.PeriodId, ocId, items);
}
var requestId = await _repository.GetRequestId(result.PeriodId, ocId);
var requestNew = await _context.InsigniaRequests.FirstOrDefaultAsync(i => i.Id == requestId);
if (requestNew != null)
{
requestNew.RequestStatus = "st2";
_context.SaveChanges();
return Success();
}
else
return Error(GlobalMessages.InvalidInsigniaRequest);
}
#endregion
#region " เปลี่ยน status สำหรับ ผอ.สำนัก "
[HttpPost("status/director/approve/{ocId:length(36)}")]
public async Task<ActionResult<ResponseObject>> ChangeStatusToSt5p(Guid ocId)
{
var result = await _repository.GetInsigniaRequest(Royal_Type, ocId);
if (result == null)
return Error(GlobalMessages.InvalidInsigniaRequest);
var requestId = await _repository.GetRequestId(result.PeriodId, ocId);
if (requestId == null)
return Error(GlobalMessages.InvalidInsigniaRequest);
var requestNew = await _context.InsigniaRequests.FirstOrDefaultAsync(i => i.Id == requestId);
if (requestNew != null)
{
requestNew.RequestStatus = "st5p";
_context.SaveChanges();
return Success();
}
else
return Error(GlobalMessages.InvalidInsigniaRequest);
}
[HttpPost("status/director/reject/{ocId:length(36)}")]
public async Task<ActionResult<ResponseObject>> ChangeStatusToSt1(Guid ocId)
{
var result = await _repository.GetInsigniaRequest(Royal_Type, ocId);
if (result == null)
return Error(GlobalMessages.InvalidInsigniaRequest);
var requestId = await _repository.GetRequestId(result.PeriodId, ocId);
if (requestId == null)
return Error(GlobalMessages.InvalidInsigniaRequest);
var requestNew = await _context.InsigniaRequests.FirstOrDefaultAsync(i => i.Id == requestId);
if (requestNew != null)
{
requestNew.RequestStatus = "st1";
_context.SaveChanges();
return Success();
}
else
return Error(GlobalMessages.InvalidInsigniaRequest);
}
#endregion
}
}

View file

@ -0,0 +1,27 @@
#See https://aka.ms/containerfastmode to understand how Visual Studio uses this Dockerfile to build your images for faster debugging.
FROM mcr.microsoft.com/dotnet/aspnet:7.0 AS base
WORKDIR /app
EXPOSE 80
EXPOSE 443
FROM mcr.microsoft.com/dotnet/sdk:7.0 AS build
WORKDIR /src
COPY ["BMA.EHR.Domain/BMA.EHR.Domain.csproj", "BMA.EHR.Domain/"]
COPY ["BMA.EHR.Application/BMA.EHR.Application.csproj", "BMA.EHR.Application/"]
COPY ["BMA.EHR.Infrastructure/BMA.EHR.Infrastructure.csproj", "BMA.EHR.Infrastructure/"]
COPY ["BMA.EHR.Insignia.Service/BMA.EHR.Insignia.Service.csproj", "BMA.EHR.Insignia.Service/"]
RUN dotnet restore "BMA.EHR.Insignia.Service/BMA.EHR.Insignia.Service.csproj"
COPY . .
WORKDIR "/src/BMA.EHR.Insignia.Service"
RUN dotnet build "BMA.EHR.Insignia.Service.csproj" -c Release -o /app/build
FROM build AS publish
RUN dotnet publish "BMA.EHR.Insignia.Service.csproj" -c Release -o /app/publish /p:UseAppHost=false
FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "BMA.EHR.Insignia.Service.dll"]

View file

@ -0,0 +1,161 @@
using BMA.EHR.Application;
using BMA.EHR.Domain.Middlewares;
using BMA.EHR.Infrastructure;
using BMA.EHR.Infrastructure.Persistence;
using BMA.EHR.Insignia.Service;
using Microsoft.AspNetCore.Authentication.JwtBearer;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.ApiExplorer;
using Microsoft.AspNetCore.Mvc.Versioning;
using Microsoft.EntityFrameworkCore;
using Microsoft.IdentityModel.Logging;
using Microsoft.IdentityModel.Tokens;
using Serilog;
using Serilog.Exceptions;
using Serilog.Sinks.Elasticsearch;
using System.Reflection;
using System.Text;
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();
// Add config CORS
builder.Services.AddCors(options => options.AddDefaultPolicy(builder =>
{
builder
.AllowAnyOrigin()
.AllowAnyMethod()
.AllowAnyHeader()
.SetIsOriginAllowedToAllowWildcardSubdomains();
}));
// Add services to the container.
builder.Services.AddApplication();
builder.Services.AddPersistence(builder.Configuration);
builder.Services.AddControllers(options =>
{
options.SuppressAsyncSuffixInActionNames = false;
})
.AddNewtonsoftJson(x => x.SerializerSettings.ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Ignore);
builder.Services.AddSwaggerGen();
builder.Services.ConfigureOptions<ConfigureSwaggerOptions>();
builder.Services.AddHealthChecks();
}
var app = builder.Build();
{
var apiVersionDescriptionProvider = app.Services.GetRequiredService<IApiVersionDescriptionProvider>();
if (app.Environment.IsDevelopment())
{
app.UseSwagger();
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();
app.UseMiddleware<ErrorHandlerMiddleware>();
// apply migrations
await using var scope = app.Services.CreateAsyncScope();
await using var db = scope.ServiceProvider.GetRequiredService<ApplicationDBContext>();
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()
.MinimumLevel.Error()
.WriteTo.Console()
.Enrich.WithExceptionDetails()
.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(".", "-")}"
};
}

View file

@ -0,0 +1,48 @@
{
"profiles": {
"http": {
"commandName": "Project",
"launchBrowser": true,
"launchUrl": "swagger",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
},
"dotnetRunMessages": true,
"applicationUrl": "http://localhost:5014"
},
"https": {
"commandName": "Project",
"launchBrowser": true,
"launchUrl": "swagger",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
},
"dotnetRunMessages": true,
"applicationUrl": "https://localhost:7270;http://localhost:5014"
},
"IIS Express": {
"commandName": "IISExpress",
"launchBrowser": true,
"launchUrl": "swagger",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"Docker": {
"commandName": "Docker",
"launchBrowser": true,
"launchUrl": "{Scheme}://{ServiceHost}:{ServicePort}/swagger",
"publishAllPorts": true,
"useSSL": true
}
},
"$schema": "https://json.schemastore.org/launchsettings.json",
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:11516",
"sslPort": 44362
}
}
}

View file

@ -0,0 +1,8 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
}
}

View file

@ -0,0 +1,35 @@
{
"Serilog": {
"MinimumLevel": {
"Default": "Information",
"Override": {
"Microsoft": "Information",
"System": "Warning"
}
}
},
"ElasticConfiguration": {
"Uri": "http://localhost:9200"
},
"AllowedHosts": "*",
"ConnectionStrings": {
//"DefaultConnection": "User Id=sys;Password=P@ssw0rd;DBA Privilege=SYSDBA;Data Source=localhost:1521/ORCLCDB",
"DefaultConnection": "server=192.168.1.9;user=root;password=adminVM123;port=3306;database=bma_ehr_demo;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": "https://s3.frappet.com/",
"AccessKey": "frappet",
"SecretKey": "P@ssw0rd",
"BucketName": "bma-recruit"
},
"Protocol": "HTTPS"
}

View file

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageSources>
<!--To inherit the global NuGet package sources remove the <clear/> line below -->
<clear />
<add key="nuget" value="https://api.nuget.org/v3/index.json" />
<add key="private_nuget" value="https://nuget.frappet.synology.me/v3/index.json" />
</packageSources>
</configuration>

View file

@ -0,0 +1,184 @@
<!--
~ Copyright 2016 Red Hat, Inc. and/or its affiliates
~ and other contributors as indicated by the @author tags.
~
~ Licensed under the Apache License, Version 2.0 (the "License");
~ you may not use this file except in compliance with the License.
~ You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing, software
~ distributed under the License is distributed on an "AS IS" BASIS,
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
~ See the License for the specific language governing permissions and
~ limitations under the License.
-->
<html>
<head>
<script src="./keycloak.js"></script>
</head>
<body>
<div>
<button onclick="keycloak.login()">Login</button>
<button onclick="keycloak.login({ action: 'UPDATE_PASSWORD' })">Update Password</button>
<button onclick="keycloak.logout()">Logout</button>
<button onclick="keycloak.register()">Register</button>
<button onclick="keycloak.accountManagement()">Account</button>
<button onclick="refreshToken(9999)">Refresh Token</button>
<button onclick="refreshToken(30)">Refresh Token (if <30s validity)</button>
<button onclick="loadProfile()">Get Profile</button>
<button onclick="updateProfile()">Update profile</button>
<button onclick="loadUserInfo()">Get User Info</button>
<button onclick="output(keycloak.tokenParsed)">Show Token</button>
<button onclick="output(keycloak.refreshTokenParsed)">Show Refresh Token</button>
<button onclick="output(keycloak.idTokenParsed)">Show ID Token</button>
<button onclick="showExpires()">Show Expires</button>
<button onclick="output(keycloak)">Show Details</button>
<button onclick="output(keycloak.createLoginUrl())">Show Login URL</button>
<button onclick="output(keycloak.createLogoutUrl())">Show Logout URL</button>
<button onclick="output(keycloak.createRegisterUrl())">Show Register URL</button>
<button onclick="output(keycloak.createAccountUrl())">Show Account URL</button>
</div>
<h2>Result</h2>
<pre style="background-color: #ddd; border: 1px solid #ccc; padding: 10px; word-wrap: break-word; white-space: pre-wrap;" id="output"></pre>
<h2>Events</h2>
<pre style="background-color: #ddd; border: 1px solid #ccc; padding: 10px; word-wrap: break-word; white-space: pre-wrap;" id="events"></pre>
<script>
function loadProfile() {
keycloak.loadUserProfile().success(function(profile) {
output(profile);
}).error(function() {
output('Failed to load profile');
});
}
function updateProfile() {
var url = keycloak.createAccountUrl().split('?')[0];
var req = new XMLHttpRequest();
req.open('POST', url, true);
req.setRequestHeader('Accept', 'application/json');
req.setRequestHeader('Content-Type', 'application/json');
req.setRequestHeader('Authorization', 'bearer ' + keycloak.token);
req.onreadystatechange = function () {
if (req.readyState == 4) {
if (req.status == 200) {
output('Success');
} else {
output('Failed');
}
}
}
req.send('{"email":"myemail@foo.bar","firstName":"test","lastName":"bar"}');
}
function loadUserInfo() {
keycloak.loadUserInfo().success(function(userInfo) {
output(userInfo);
}).error(function() {
output('Failed to load user info');
});
}
function refreshToken(minValidity) {
keycloak.updateToken(minValidity).then(function(refreshed) {
if (refreshed) {
output(keycloak.tokenParsed);
} else {
output('Token not refreshed, valid for ' + Math.round(keycloak.tokenParsed.exp + keycloak.timeSkew - new Date().getTime() / 1000) + ' seconds');
}
}).catch(function() {
output('Failed to refresh token');
});
}
function showExpires() {
if (!keycloak.tokenParsed) {
output("Not authenticated");
return;
}
var o = 'Token Expires:\t\t' + new Date((keycloak.tokenParsed.exp + keycloak.timeSkew) * 1000).toLocaleString() + '\n';
o += 'Token Expires in:\t' + Math.round(keycloak.tokenParsed.exp + keycloak.timeSkew - new Date().getTime() / 1000) + ' seconds\n';
if (keycloak.refreshTokenParsed) {
o += 'Refresh Token Expires:\t' + new Date((keycloak.refreshTokenParsed.exp + keycloak.timeSkew) * 1000).toLocaleString() + '\n';
o += 'Refresh Expires in:\t' + Math.round(keycloak.refreshTokenParsed.exp + keycloak.timeSkew - new Date().getTime() / 1000) + ' seconds';
}
output(o);
}
function output(data) {
if (typeof data === 'object') {
data = JSON.stringify(data, null, ' ');
}
document.getElementById('output').innerHTML = data;
}
function event(event) {
var e = document.getElementById('events').innerHTML;
document.getElementById('events').innerHTML = new Date().toLocaleString() + "\t" + event + "\n" + e;
}
var keycloak = Keycloak();
keycloak.onAuthSuccess = function () {
event('Auth Success');
};
keycloak.onAuthError = function (errorData) {
event("Auth Error: " + JSON.stringify(errorData) );
};
keycloak.onAuthRefreshSuccess = function () {
event('Auth Refresh Success');
};
keycloak.onAuthRefreshError = function () {
event('Auth Refresh Error');
};
keycloak.onAuthLogout = function () {
event('Auth Logout');
};
keycloak.onTokenExpired = function () {
event('Access token expired.');
};
keycloak.onActionUpdate = function (status) {
switch (status) {
case 'success':
event('Action completed successfully'); break;
case 'cancelled':
event('Action cancelled by user'); break;
case 'error':
event('Action failed'); break;
}
};
// Flow can be changed to 'implicit' or 'hybrid', but then client must enable implicit flow in admin console too
var initOptions = {
responseMode: 'fragment',
flow: 'standard'
};
keycloak.init(initOptions).then(function(authenticated) {
output('Init Success (' + (authenticated ? 'Authenticated' : 'Not Authenticated') + ')');
}).catch(function() {
output('Init Error');
});
</script>
</body>
</html>

File diff suppressed because one or more lines are too long

View file

@ -0,0 +1,7 @@
{
"realm": "bma-ehr",
"auth-server-url": "https://identity.frappet.com",
"ssl-required": "external",
"resource": "bma-ehr",
"public-client": true
}

View file

@ -343,5 +343,37 @@ namespace BMA.EHR.OrganizationEmployee.Service.Controllers
return Success();
}
[HttpGet("position/{profileId:length(36)}")]
public async Task<ActionResult<ResponseObject>> GetPositionEmployee(Guid profileId)
{
var profile = await _context.Profiles.FindAsync(profileId);
if (profile == null)
return Error(GlobalMessages.DataNotFound, 404);
var organizationEmployee = await _context.OrganizationEmployees
.Where(x => x.Profile == null || (x.Profile != null && x.Profile == profile))
.ToListAsync();
return Success(organizationEmployee);
}
[HttpPut("position/{profileId:length(36)}")]
public async Task<ActionResult<ResponseObject>> PutPositionEmployee([FromBody] PositionOrgEmployee req, Guid profileId)
{
var profile = await _context.Profiles.FindAsync(profileId);
if (profile == null)
return Error(GlobalMessages.DataNotFound, 404);
var organizationEmployee = await _context.OrganizationEmployees
.Include(x => x.Profile)
.FirstOrDefaultAsync(x => x.Id == req.OrganizationEmployeeId);
if (organizationEmployee == null)
return Error(GlobalMessages.OrganizationEmployeeNotFound, 404);
organizationEmployee.Profile = profile;
_context.SaveChanges();
return Success();
}
}
}

View file

@ -0,0 +1,10 @@
using BMA.EHR.Domain.Models.MetaData;
using Microsoft.EntityFrameworkCore;
namespace BMA.EHR.OrganizationEmployee.Service.Requests
{
public class PositionOrgEmployee
{
public Guid? OrganizationEmployeeId { get; set; }
}
}

View file

@ -106,6 +106,8 @@ namespace BMA.EHR.Placement.Service.Controllers
FullName = x.Prefix == null ? null : x.Prefix.Name + $"{x.Firstname} {x.Lastname}",
IdCard = x.CitizenId,
ProfilePhoto = x.Id,
PositionCandidate = x.PositionCandidate == null ? null : x.PositionCandidate.Name,
PositionCandidateId = x.PositionCandidate == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : x.PositionCandidate.Id,
OrganizationName = x.OrganizationPosition == null ? null : (x.OrganizationPosition.Organization == null ? null : (x.OrganizationPosition.Organization.OrganizationOrganization == null ? null : x.OrganizationPosition.Organization.OrganizationOrganization.Name)),////
OrganizationShortName = x.OrganizationPosition == null ? null : (x.OrganizationPosition.Organization == null ? null : (x.OrganizationPosition.Organization.OrganizationShortName == null ? null : x.OrganizationPosition.Organization.OrganizationShortName.Name)),////
PositionNumber = x.PositionNumber == null ? null : x.PositionNumber.Name,
@ -113,6 +115,7 @@ namespace BMA.EHR.Placement.Service.Controllers
ReportingDate = x.ReportingDate,
BmaOfficer = x.IsOfficer,
StatusId = x.PlacementStatus,
Draft = x.Draft,
Number = x.Number,
Deferment = x.IsRelief,
}).ToListAsync();
@ -126,6 +129,8 @@ namespace BMA.EHR.Placement.Service.Controllers
p.FullName,
p.IdCard,
p.ProfilePhoto,
p.PositionCandidate,
p.PositionCandidateId,
p.OrganizationName,
p.OrganizationShortName,
p.PositionNumber,
@ -133,6 +138,7 @@ namespace BMA.EHR.Placement.Service.Controllers
p.ReportingDate,
BmaOfficer = await _documentService.CheckBmaOfficer(p.IdCard),
p.StatusId,
p.Draft,
p.Number,
p.Deferment,
};
@ -158,6 +164,8 @@ namespace BMA.EHR.Placement.Service.Controllers
FullName = x.Prefix == null ? null : x.Prefix.Name + $"{x.Firstname} {x.Lastname}",
IdCard = x.CitizenId,
ProfilePhoto = x.Id,
PositionCandidate = x.PositionCandidate == null ? null : x.PositionCandidate.Name,
PositionCandidateId = x.PositionCandidate == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : x.PositionCandidate.Id,
OrganizationName = x.OrganizationPosition == null ? null : (x.OrganizationPosition.Organization == null ? null : (x.OrganizationPosition.Organization.OrganizationOrganization == null ? null : x.OrganizationPosition.Organization.OrganizationOrganization.Name)),////
OrganizationShortName = x.OrganizationPosition == null ? null : (x.OrganizationPosition.Organization == null ? null : (x.OrganizationPosition.Organization.OrganizationShortName == null ? null : x.OrganizationPosition.Organization.OrganizationShortName.Name)),////
PositionNumber = x.PositionNumber == null ? null : x.PositionNumber.Name,
@ -165,6 +173,7 @@ namespace BMA.EHR.Placement.Service.Controllers
ReportingDate = x.ReportingDate,
BmaOfficer = x.IsOfficer,
StatusId = x.PlacementStatus,
Draft = x.Draft,
Number = x.Number,
Deferment = x.IsRelief,
}).OrderBy(x => x.Number).ToListAsync();
@ -178,6 +187,8 @@ namespace BMA.EHR.Placement.Service.Controllers
p.FullName,
p.IdCard,
p.ProfilePhoto,
p.PositionCandidate,
p.PositionCandidateId,
p.OrganizationName,
p.OrganizationShortName,
p.PositionNumber,
@ -185,6 +196,7 @@ namespace BMA.EHR.Placement.Service.Controllers
p.ReportingDate,
BmaOfficer = await _documentService.CheckBmaOfficer(p.IdCard),
p.StatusId,
p.Draft,
p.Number,
p.Deferment,
};
@ -225,10 +237,13 @@ namespace BMA.EHR.Placement.Service.Controllers
Firstname = x.Firstname,
Lastname = x.Lastname,
Nationality = x.Nationality,
Draft = x.Draft,
Race = x.Race,
DateOfBirth = x.DateOfBirth,
Age = x.DateOfBirth == null ? null : x.DateOfBirth.Value.CalculateAgeStrV2(0, 0),
Telephone = x.Telephone,
PositionCandidate = x.PositionCandidate == null ? null : x.PositionCandidate.Name,
PositionCandidateId = x.PositionCandidate == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : x.PositionCandidate.Id,
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,
@ -330,11 +345,14 @@ namespace BMA.EHR.Placement.Service.Controllers
data.FullName,
data.Firstname,
data.Lastname,
data.Draft,
data.Nationality,
data.Race,
data.DateOfBirth,
data.Age,
data.Telephone,
data.PositionCandidate,
data.PositionCandidateId,
data.Gender,
data.GenderId,
data.Relationship,
@ -585,6 +603,7 @@ namespace BMA.EHR.Placement.Service.Controllers
return Error(GlobalMessages.PositionTypeNotFound, 404);
person.PositionType = save;
}
person.Draft = false;
person.Amount = req.SalaryAmount;
person.MouthSalaryAmount = req.MouthSalaryAmount;
person.PositionSalaryAmount = req.PositionSalaryAmount;
@ -896,6 +915,7 @@ namespace BMA.EHR.Placement.Service.Controllers
DurationYear = req.DurationYear,
Other = req.Other,
FundName = req.FundName,
IsDate = req.IsDate,
FinishDate = req.FinishDate,
StartDate = req.StartDate,
EndDate = req.EndDate,
@ -941,6 +961,7 @@ namespace BMA.EHR.Placement.Service.Controllers
education.DurationYear = req.DurationYear;
education.Other = req.Other;
education.FundName = req.FundName;
education.IsDate = req.IsDate;
education.FinishDate = req.FinishDate;
education.StartDate = req.StartDate;
education.EndDate = req.EndDate;
@ -974,5 +995,25 @@ namespace BMA.EHR.Placement.Service.Controllers
return Success(position);
}
[HttpPut("position/{placementId:length(36)}")]
public async Task<ActionResult<ResponseObject>> UpdatePositionDraft([FromBody] List<Guid> items, Guid placementId)
{
var placement = await _context.Placements
.FirstOrDefaultAsync(x => x.Id == placementId);
if (placement == null)
return Error(GlobalMessages.DataNotFound, 404);
foreach (var item in items)
{
var profile = await _context.PlacementProfiles
.FirstOrDefaultAsync(x => x.Id == item);
if (profile != null)
profile.Draft = true;
}
_context.SaveChanges();
return Success();
}
}
}

View file

@ -19,6 +19,7 @@ namespace BMA.EHR.Placement.Service.Requests
public int DurationYear { get; set; }
public string? Other { get; set; }
public string? FundName { get; set; }
public bool? IsDate { get; set; }
public DateTime? FinishDate { get; set; }
public DateTime? StartDate { get; set; }
public DateTime? EndDate { get; set; }

View file

@ -21,7 +21,9 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BMA.EHR.OrganizationEmploye
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BMA.EHR.Report.Service", "BMA.EHR.Report.Service\BMA.EHR.Report.Service.csproj", "{AC4B2602-C543-4165-85D7-F6F92F553D80}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BMA.EHR.Command.Service", "BMA.EHR.Command.Service\BMA.EHR.Command.Service.csproj", "{E4E905EE-61DF-4451-B063-5C86BC7574CE}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BMA.EHR.Command.Service", "BMA.EHR.Command.Service\BMA.EHR.Command.Service.csproj", "{E4E905EE-61DF-4451-B063-5C86BC7574CE}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BMA.EHR.Insignia.Service", "BMA.EHR.Insignia.Service\BMA.EHR.Insignia.Service.csproj", "{04B37ACD-65CF-44ED-BC40-B5E7A71C374B}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@ -61,6 +63,10 @@ Global
{E4E905EE-61DF-4451-B063-5C86BC7574CE}.Debug|Any CPU.Build.0 = Debug|Any CPU
{E4E905EE-61DF-4451-B063-5C86BC7574CE}.Release|Any CPU.ActiveCfg = Release|Any CPU
{E4E905EE-61DF-4451-B063-5C86BC7574CE}.Release|Any CPU.Build.0 = Release|Any CPU
{04B37ACD-65CF-44ED-BC40-B5E7A71C374B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{04B37ACD-65CF-44ED-BC40-B5E7A71C374B}.Debug|Any CPU.Build.0 = Debug|Any CPU
{04B37ACD-65CF-44ED-BC40-B5E7A71C374B}.Release|Any CPU.ActiveCfg = Release|Any CPU
{04B37ACD-65CF-44ED-BC40-B5E7A71C374B}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
@ -75,6 +81,7 @@ Global
{A54AA069-8B0E-4784-953B-5DA9F9C8285E} = {FA618F0C-1AF5-49AB-AE13-C020B403B64F}
{AC4B2602-C543-4165-85D7-F6F92F553D80} = {FA618F0C-1AF5-49AB-AE13-C020B403B64F}
{E4E905EE-61DF-4451-B063-5C86BC7574CE} = {FA618F0C-1AF5-49AB-AE13-C020B403B64F}
{04B37ACD-65CF-44ED-BC40-B5E7A71C374B} = {FA618F0C-1AF5-49AB-AE13-C020B403B64F}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {3111A492-1818-4438-B718-75199D8E779A}