Merge branch 'develop' into work

# Conflicts:
#	BMA.EHR.Application/ApplicationServicesRegistration.cs
This commit is contained in:
Kittapath 2023-07-20 20:20:28 +07:00
commit 25274562c8
110 changed files with 58830 additions and 117 deletions

View file

@ -14,6 +14,8 @@ namespace BMA.EHR.Application
services.AddTransient<OrganizationEmployeeRepository>();
services.AddTransient<MessageQueueRepository>();
services.AddTransient<PlacementCommandRepository>();
services.AddTransient<CommandTypeRepository>();
services.AddTransient<CommandStatusRepository>();
services.AddTransient<InsigniaPeriodsRepository>();
return services;

View file

@ -0,0 +1,27 @@
using BMA.EHR.Application.Common.Interfaces;
using BMA.EHR.Domain.Models.Commands.Core;
using Microsoft.AspNetCore.Http;
namespace BMA.EHR.Application.Repositories.Commands
{
public class CommandStatusRepository : GenericRepository<Guid, CommandStatus>
{
#region " Fields "
private readonly IApplicationDBContext _dbContext;
private readonly IHttpContextAccessor _httpContextAccessor;
#endregion
#region " Constructor and Destuctor "
public CommandStatusRepository(IApplicationDBContext dbContext,
IHttpContextAccessor httpContextAccessor) : base(dbContext, httpContextAccessor)
{
_dbContext = dbContext;
_httpContextAccessor = httpContextAccessor;
}
#endregion
}
}

View file

@ -0,0 +1,27 @@
using BMA.EHR.Application.Common.Interfaces;
using BMA.EHR.Domain.Models.Commands.Core;
using Microsoft.AspNetCore.Http;
namespace BMA.EHR.Application.Repositories.Commands
{
public class CommandTypeRepository : GenericRepository<Guid, CommandType>
{
#region " Fields "
private readonly IApplicationDBContext _dbContext;
private readonly IHttpContextAccessor _httpContextAccessor;
#endregion
#region " Constructor and Destuctor "
public CommandTypeRepository(IApplicationDBContext dbContext,
IHttpContextAccessor httpContextAccessor) : base(dbContext, httpContextAccessor)
{
_dbContext = dbContext;
_httpContextAccessor = httpContextAccessor;
}
#endregion
}
}

View file

@ -1,10 +1,10 @@
using BMA.EHR.Application.Common.Interfaces;
using BMA.EHR.Domain.Models.Commands;
using BMA.EHR.Domain.Models.Commands.Core;
using Microsoft.AspNetCore.Http;
namespace BMA.EHR.Application.Repositories.Commands
{
public class PlacementCommandRepository : GenericRepository<Guid, PlacementCommand>
public class PlacementCommandRepository : GenericRepository<Guid, Command>
{
#region " Fields "

View file

@ -40,7 +40,9 @@
</ItemGroup>
<ItemGroup>
<Folder Include="Controllers\" />
<None Update="SeedCommand.xlsx">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>
</Project>

View file

@ -0,0 +1,240 @@
using BMA.EHR.Application.Repositories;
using BMA.EHR.Application.Repositories.Commands;
using BMA.EHR.Domain.Common;
using BMA.EHR.Domain.Extensions;
using BMA.EHR.Domain.Shared;
using BMA.EHR.Infrastructure.Persistence;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Swashbuckle.AspNetCore.Annotations;
using System.Security.Claims;
namespace BMA.EHR.Command.Service.Controllers
{
[Route("api/v{version:apiVersion}/order")]
[ApiVersion("1.0")]
[ApiController]
[Produces("application/json")]
[Authorize]
[SwaggerTag("API ระบบออกคำสั่ง")]
public class OrderController : BaseController
{
#region " Fields "
private readonly PlacementCommandRepository _repository;
private readonly PlacementRepository _placementRepository;
private readonly ApplicationDBContext _context;
private readonly MinIOService _documentService;
private readonly IHttpContextAccessor _httpContextAccessor;
#endregion
#region " Constuctor and Destructor "
public OrderController(PlacementCommandRepository repository,
PlacementRepository placementRepository,
ApplicationDBContext context,
MinIOService documentService,
IHttpContextAccessor httpContextAccessor)
{
_repository = repository;
_context = context;
_documentService = documentService;
_httpContextAccessor = httpContextAccessor;
_placementRepository = placementRepository;
}
#endregion
#region " Properties "
private string? UserId => _httpContextAccessor?.HttpContext?.User?.FindFirst(ClaimTypes.NameIdentifier)?.Value;
private string? FullName => _httpContextAccessor?.HttpContext?.User?.FindFirst("name")?.Value;
private bool? PlacementAdmin => _httpContextAccessor?.HttpContext?.User?.IsInRole("placement1");
#endregion
#region " Methods "
/// <summary>
/// แสดงปีเป็นปีพุทธศักราช โดยดึงจากข้อมูลที่มีในระบบ
/// </summary>
/// <returns></returns>
/// <response code="200">เมื่อทำการอ่านข้อมูลจาก Relational Database สำเร็จ</response>
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
[HttpGet("fiscal-year")]
[ProducesResponseType(StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
public async Task<ActionResult<ResponseObject>> GetFiscal()
{
var data = await _repository.GetAllAsync();
if (data != null)
{
var _data = data.GroupBy(x => x.CommandYear).Select(x => new
{
Id = x.FirstOrDefault().CommandYear,
Name = x.FirstOrDefault().CommandYear + 543,
}).ToList();
return Success(_data);
}
return Success(data);
}
/// <summary>
/// PM7-19 : หน้าจอรายการออกคำสั่ง
/// </summary>
/// <returns></returns>
/// <response code="200">เมื่อทำการอ่านข้อมูลจาก Relational Database สำเร็จ</response>
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
[HttpGet]
[ProducesResponseType(StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
public async Task<ActionResult<ResponseObject>> GetAllAsync()
{
try
{
var data = (await _repository.GetAllAsync())
.Select(d => new
{
OrderName = d.CommandSubject,
OrderNo = d.CommandNo,
FiscalYear = d.CommandYear,
OrderDate = d.CommandAffectDate,
OrderByOrganization = d.IssuerOrganizationName,
OrderBy = d.AuthorizedUserFullName,
OrderStatusValue = d.CommandStatusId,
OrderStatusName = d.CommandStatus.Name,
OrderTypeValue = d.CommandTypeId,
OrderTypeName = d.CommandType.Name
}).ToList();
return Success(data);
}
catch
{
throw;
}
}
/// <summary>
/// PM7-20 : ลบรายการคำสั่ง
/// </summary>
/// <param name="orderId">Record Id ของคำสั่ง</param>
/// <returns></returns>
/// <response code="200">เมื่อทำการอ่านข้อมูลจาก Relational Database สำเร็จ</response>
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
[HttpDelete("{orderId}")]
[ProducesResponseType(StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
public async Task<ActionResult<ResponseObject>> DeleteAsync(Guid orderId)
{
try
{
var data = await _repository.GetByIdAsync(orderId);
if (data == null)
throw new Exception(GlobalMessages.DataNotFound);
await _repository.DeleteAsync(data!);
return Success(data);
}
catch
{
throw;
}
}
/// <summary>
/// PM7-21 : รายละเอียดการออกคำสั่ง
/// </summary>
/// <param name="orderId">Record Id ของคำสั่ง</param>
/// <returns></returns>
/// <response code="200">เมื่อทำการอ่านข้อมูลจาก Relational Database สำเร็จ</response>
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
[HttpGet("{orderId}")]
[ProducesResponseType(StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
public async Task<ActionResult<ResponseObject>> GetByIdAsync(Guid orderId)
{
try
{
var data = await _repository.GetByIdAsync(orderId);
if (data == null)
throw new Exception(GlobalMessages.DataNotFound);
var result = new
{
orderId = orderId,
orderTypeValue = data.CommandTypeId,
orderTitle = data.CommandSubject,
orderNo = data.CommandNo,
orderYear = data.CommandYear,
orderDate = data.CommandAffectDate,
orderBy = data.IssuerOrganizationId,
signatoryBy = data.AuthorizedUserFullName,
signatoryPosition = data.AuthorizedPosition,
examRound = data.ExamRoundId,
registerPosition = "",
conclusionRegisterNo = data.ConclusionRegisterNo,
conclusionRegisterDate = data.ConclusionRegisterDate,
conclusionResultNo = data.ConclusionResultNo,
conclusionResultDate = data.ConclusionResultDate,
};
return Success(result);
}
catch
{
throw;
}
}
/// <summary>
/// PM7-24 : dropdown รอบการสอบ หน้ารายละเอียดการออกคำสั่ง
/// </summary>
/// <returns></returns>
/// <response code="200">เมื่อทำการอ่านข้อมูลจาก Relational Database สำเร็จ</response>
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
[HttpGet("detail/exam-round")]
[ProducesResponseType(StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
public async Task<ActionResult<ResponseObject>> GetExamRoundAsync()
{
try
{
var data = (await _placementRepository.GetAllAsync())
.Select(x => new
{
examRoundValue = x.Id,
examRoundName = $"{x.Name} ครั้งที่ {x.Round}/{x.Year.ToThaiYear()}"
})
.ToList();
return Success(data);
}
catch
{
throw;
}
}
#endregion
}
}

View file

@ -126,6 +126,9 @@ var app = builder.Build();
await using var db = scope.ServiceProvider.GetRequiredService<ApplicationDBContext>();
await db.Database.MigrateAsync();
// seed default data
await CommandDataSeeder.SeedData(app);
app.Run();
}

Binary file not shown.

View file

@ -14,7 +14,7 @@
"AllowedHosts": "*",
"ConnectionStrings": {
//"DefaultConnection": "User Id=sys;Password=P@ssw0rd;DBA Privilege=SYSDBA;Data Source=localhost:1521/ORCLCDB",
"DefaultConnection": "server=127.0.0.1;user=root;password=P@ssw0rd;port=3308;database=bma_ehr_demo;Convert Zero Datetime=True;Allow User Variables=true;Pooling=True;"
"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",

View file

@ -9,7 +9,7 @@ using System.Threading.Tasks;
namespace BMA.EHR.Domain.Models.Commands.Core
{
public abstract class Command : EntityBase
public class Command : EntityBase
{
[MaxLength(10), Comment("เลขที่คำสั่ง")]
public string CommandNo { get; set; } = string.Empty;
@ -33,12 +33,46 @@ namespace BMA.EHR.Domain.Models.Commands.Core
public CommandStatus CommandStatus { get; set; }
[Required, Comment("รหัสอ้างอิงผู้มีอำนาจลงนาม")]
[Comment("รหัสอ้างอิงผู้มีอำนาจลงนาม")]
public Guid AuthorizedUserId { get; set; } = Guid.Empty;
[Required, Comment("ชื่อผู้มีอำนาจลงนาม")]
[Comment("ชื่อผู้มีอำนาจลงนาม")]
public string AuthorizedUserFullName { get; set; } = string.Empty;
[Comment("ตำแหน่งผู้มีอำนาจลงนาม")]
public string AuthorizedPosition { get; set; } = string.Empty;
[Comment("วันที่คำสั่งมีผล")]
public DateTime? CommandAffectDate { get; set; }
[Comment("วันที่ออกคำสั่ง")]
public DateTime? CommandExcecuteDate { get; set; }
[Required, MaxLength(500), Comment("คำสั่งเรื่อง")]
public string CommandSubject { get; set; } = string.Empty;
public virtual List<CommandDocument> Documents { get; set; } = new();
#region " For Placement Command "
[Required, Comment("อ้างอิงรอบการสอบ")]
public Guid ExamRoundId { get; set; }
[Required, Comment("ตำแหน่งที่บรรจุ")]
public string PositionName { get; set; } = string.Empty;
[Required, Comment("มติ กก. ครั้งที่ (เรื่อง รับสมัครสอบฯ)")]
public string ConclusionRegisterNo { get; set; } = string.Empty;
[Required, Comment("ลงวันที่ (เรื่อง รับสมัครสอบฯ)")]
public DateTime ConclusionRegisterDate { get; set; } = DateTime.Now;
[Required, Comment("มติ กก. ครั้งที่ (เรื่อง ผลการสอบแข่งขัน)")]
public string ConclusionResultNo { get; set; } = string.Empty;
[Required, Comment("ลงวันที่ (เรื่อง ผลการสอบแข่งขัน)")]
public DateTime ConclusionResultDate { get; set; } = DateTime.Now;
#endregion
}
}

View file

@ -8,5 +8,8 @@ namespace BMA.EHR.Domain.Models.Commands.Core
{
[Required, MaxLength(100), Comment("สถานะของคำสั่ง")]
public string Name { get; set; } = string.Empty;
[Required, Comment("ลำดับการทำงาน")]
public int Sequence { get; set; } = 0;
}
}

View file

@ -1,32 +0,0 @@
using BMA.EHR.Domain.Models.Commands.Core;
using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BMA.EHR.Domain.Models.Commands
{
public class PlacementCommand : Command
{
[Required, Comment("อ้างอิงรอบการสอบ")]
public Guid ExamRoundId { get; set; }
[Required, Comment("ตำแหน่งที่บรรจุ")]
public string PositionName { get; set; } = string.Empty;
[Required, Comment("มติ กก. ครั้งที่ (เรื่อง รับสมัครสอบฯ)")]
public string ConclusionRegisterNo { get; set; } = string.Empty;
[Required, Comment("ลงวันที่ (เรื่อง รับสมัครสอบฯ)")]
public DateTime ConclusionRegisterDate { get; set; } = DateTime.Now;
[Required, Comment("มติ กก. ครั้งที่ (เรื่อง ผลการสอบแข่งขัน)")]
public string ConclusionResultNo { get; set; } = string.Empty;
[Required, Comment("ลงวันที่ (เรื่อง ผลการสอบแข่งขัน)")]
public DateTime ConclusionResultDate { get; set; } = DateTime.Now;
}
}

View file

@ -1,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
@ -7,6 +7,7 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="EPPlus" Version="6.2.7" />
<PackageReference Include="Microsoft.AspNetCore.Hosting.Abstractions" Version="2.2.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="7.0.9">
<PrivateAssets>all</PrivateAssets>
@ -28,4 +29,10 @@
<ProjectReference Include="..\BMA.EHR.Application\BMA.EHR.Application.csproj" />
</ItemGroup>
<ItemGroup>
<None Update="SeedCommand.xlsx">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>
</Project>

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,314 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace BMA.EHR.Infrastructure.Migrations
{
/// <inheritdoc />
public partial class ChangeCommandTable : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_Command_CommandStatuses_CommandStatusId",
table: "Command");
migrationBuilder.DropForeignKey(
name: "FK_Command_CommandTypes_CommandTypeId",
table: "Command");
migrationBuilder.DropForeignKey(
name: "FK_CommandDocuments_Command_CommandId",
table: "CommandDocuments");
migrationBuilder.DropPrimaryKey(
name: "PK_Command",
table: "Command");
migrationBuilder.DropColumn(
name: "Discriminator",
table: "Command");
migrationBuilder.RenameTable(
name: "Command",
newName: "Commands");
migrationBuilder.RenameIndex(
name: "IX_Command_CommandTypeId",
table: "Commands",
newName: "IX_Commands_CommandTypeId");
migrationBuilder.RenameIndex(
name: "IX_Command_CommandStatusId",
table: "Commands",
newName: "IX_Commands_CommandStatusId");
migrationBuilder.UpdateData(
table: "Commands",
keyColumn: "PositionName",
keyValue: null,
column: "PositionName",
value: "");
migrationBuilder.AlterColumn<string>(
name: "PositionName",
table: "Commands",
type: "longtext",
nullable: false,
comment: "ตำแหน่งที่บรรจุ",
oldClrType: typeof(string),
oldType: "longtext",
oldNullable: true,
oldComment: "ตำแหน่งที่บรรจุ")
.Annotation("MySql:CharSet", "utf8mb4")
.OldAnnotation("MySql:CharSet", "utf8mb4");
migrationBuilder.AlterColumn<Guid>(
name: "ExamRoundId",
table: "Commands",
type: "char(36)",
nullable: false,
defaultValue: new Guid("00000000-0000-0000-0000-000000000000"),
comment: "อ้างอิงรอบการสอบ",
collation: "ascii_general_ci",
oldClrType: typeof(Guid),
oldType: "char(36)",
oldNullable: true,
oldComment: "อ้างอิงรอบการสอบ")
.OldAnnotation("Relational:Collation", "ascii_general_ci");
migrationBuilder.UpdateData(
table: "Commands",
keyColumn: "ConclusionResultNo",
keyValue: null,
column: "ConclusionResultNo",
value: "");
migrationBuilder.AlterColumn<string>(
name: "ConclusionResultNo",
table: "Commands",
type: "longtext",
nullable: false,
comment: "มติ กก. ครั้งที่ (เรื่อง ผลการสอบแข่งขัน)",
oldClrType: typeof(string),
oldType: "longtext",
oldNullable: true,
oldComment: "มติ กก. ครั้งที่ (เรื่อง ผลการสอบแข่งขัน)")
.Annotation("MySql:CharSet", "utf8mb4")
.OldAnnotation("MySql:CharSet", "utf8mb4");
migrationBuilder.AlterColumn<DateTime>(
name: "ConclusionResultDate",
table: "Commands",
type: "datetime(6)",
nullable: false,
defaultValue: new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
comment: "ลงวันที่ (เรื่อง ผลการสอบแข่งขัน)",
oldClrType: typeof(DateTime),
oldType: "datetime(6)",
oldNullable: true,
oldComment: "ลงวันที่ (เรื่อง ผลการสอบแข่งขัน)");
migrationBuilder.UpdateData(
table: "Commands",
keyColumn: "ConclusionRegisterNo",
keyValue: null,
column: "ConclusionRegisterNo",
value: "");
migrationBuilder.AlterColumn<string>(
name: "ConclusionRegisterNo",
table: "Commands",
type: "longtext",
nullable: false,
comment: "มติ กก. ครั้งที่ (เรื่อง รับสมัครสอบฯ)",
oldClrType: typeof(string),
oldType: "longtext",
oldNullable: true,
oldComment: "มติ กก. ครั้งที่ (เรื่อง รับสมัครสอบฯ)")
.Annotation("MySql:CharSet", "utf8mb4")
.OldAnnotation("MySql:CharSet", "utf8mb4");
migrationBuilder.AlterColumn<DateTime>(
name: "ConclusionRegisterDate",
table: "Commands",
type: "datetime(6)",
nullable: false,
defaultValue: new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
comment: "ลงวันที่ (เรื่อง รับสมัครสอบฯ)",
oldClrType: typeof(DateTime),
oldType: "datetime(6)",
oldNullable: true,
oldComment: "ลงวันที่ (เรื่อง รับสมัครสอบฯ)");
migrationBuilder.AddPrimaryKey(
name: "PK_Commands",
table: "Commands",
column: "Id");
migrationBuilder.AddForeignKey(
name: "FK_CommandDocuments_Commands_CommandId",
table: "CommandDocuments",
column: "CommandId",
principalTable: "Commands",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
migrationBuilder.AddForeignKey(
name: "FK_Commands_CommandStatuses_CommandStatusId",
table: "Commands",
column: "CommandStatusId",
principalTable: "CommandStatuses",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
migrationBuilder.AddForeignKey(
name: "FK_Commands_CommandTypes_CommandTypeId",
table: "Commands",
column: "CommandTypeId",
principalTable: "CommandTypes",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_CommandDocuments_Commands_CommandId",
table: "CommandDocuments");
migrationBuilder.DropForeignKey(
name: "FK_Commands_CommandStatuses_CommandStatusId",
table: "Commands");
migrationBuilder.DropForeignKey(
name: "FK_Commands_CommandTypes_CommandTypeId",
table: "Commands");
migrationBuilder.DropPrimaryKey(
name: "PK_Commands",
table: "Commands");
migrationBuilder.RenameTable(
name: "Commands",
newName: "Command");
migrationBuilder.RenameIndex(
name: "IX_Commands_CommandTypeId",
table: "Command",
newName: "IX_Command_CommandTypeId");
migrationBuilder.RenameIndex(
name: "IX_Commands_CommandStatusId",
table: "Command",
newName: "IX_Command_CommandStatusId");
migrationBuilder.AlterColumn<string>(
name: "PositionName",
table: "Command",
type: "longtext",
nullable: true,
comment: "ตำแหน่งที่บรรจุ",
oldClrType: typeof(string),
oldType: "longtext",
oldComment: "ตำแหน่งที่บรรจุ")
.Annotation("MySql:CharSet", "utf8mb4")
.OldAnnotation("MySql:CharSet", "utf8mb4");
migrationBuilder.AlterColumn<Guid>(
name: "ExamRoundId",
table: "Command",
type: "char(36)",
nullable: true,
comment: "อ้างอิงรอบการสอบ",
collation: "ascii_general_ci",
oldClrType: typeof(Guid),
oldType: "char(36)",
oldComment: "อ้างอิงรอบการสอบ")
.OldAnnotation("Relational:Collation", "ascii_general_ci");
migrationBuilder.AlterColumn<string>(
name: "ConclusionResultNo",
table: "Command",
type: "longtext",
nullable: true,
comment: "มติ กก. ครั้งที่ (เรื่อง ผลการสอบแข่งขัน)",
oldClrType: typeof(string),
oldType: "longtext",
oldComment: "มติ กก. ครั้งที่ (เรื่อง ผลการสอบแข่งขัน)")
.Annotation("MySql:CharSet", "utf8mb4")
.OldAnnotation("MySql:CharSet", "utf8mb4");
migrationBuilder.AlterColumn<DateTime>(
name: "ConclusionResultDate",
table: "Command",
type: "datetime(6)",
nullable: true,
comment: "ลงวันที่ (เรื่อง ผลการสอบแข่งขัน)",
oldClrType: typeof(DateTime),
oldType: "datetime(6)",
oldComment: "ลงวันที่ (เรื่อง ผลการสอบแข่งขัน)");
migrationBuilder.AlterColumn<string>(
name: "ConclusionRegisterNo",
table: "Command",
type: "longtext",
nullable: true,
comment: "มติ กก. ครั้งที่ (เรื่อง รับสมัครสอบฯ)",
oldClrType: typeof(string),
oldType: "longtext",
oldComment: "มติ กก. ครั้งที่ (เรื่อง รับสมัครสอบฯ)")
.Annotation("MySql:CharSet", "utf8mb4")
.OldAnnotation("MySql:CharSet", "utf8mb4");
migrationBuilder.AlterColumn<DateTime>(
name: "ConclusionRegisterDate",
table: "Command",
type: "datetime(6)",
nullable: true,
comment: "ลงวันที่ (เรื่อง รับสมัครสอบฯ)",
oldClrType: typeof(DateTime),
oldType: "datetime(6)",
oldComment: "ลงวันที่ (เรื่อง รับสมัครสอบฯ)");
migrationBuilder.AddColumn<string>(
name: "Discriminator",
table: "Command",
type: "longtext",
nullable: false)
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.AddPrimaryKey(
name: "PK_Command",
table: "Command",
column: "Id");
migrationBuilder.AddForeignKey(
name: "FK_Command_CommandStatuses_CommandStatusId",
table: "Command",
column: "CommandStatusId",
principalTable: "CommandStatuses",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
migrationBuilder.AddForeignKey(
name: "FK_Command_CommandTypes_CommandTypeId",
table: "Command",
column: "CommandTypeId",
principalTable: "CommandTypes",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
migrationBuilder.AddForeignKey(
name: "FK_CommandDocuments_Command_CommandId",
table: "CommandDocuments",
column: "CommandId",
principalTable: "Command",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
}
}
}

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,55 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace BMA.EHR.Infrastructure.Migrations
{
/// <inheritdoc />
public partial class addfieldtoCommandTable : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<DateTime>(
name: "CommandAffectDate",
table: "Commands",
type: "datetime(6)",
nullable: true,
comment: "วันที่คำสั่งมีผล");
migrationBuilder.AddColumn<DateTime>(
name: "CommandExcecuteDate",
table: "Commands",
type: "datetime(6)",
nullable: true,
comment: "วันที่ออกคำสั่ง");
migrationBuilder.AddColumn<string>(
name: "CommandSubject",
table: "Commands",
type: "varchar(500)",
maxLength: 500,
nullable: false,
defaultValue: "",
comment: "คำสั่งเรื่อง")
.Annotation("MySql:CharSet", "utf8mb4");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "CommandAffectDate",
table: "Commands");
migrationBuilder.DropColumn(
name: "CommandExcecuteDate",
table: "Commands");
migrationBuilder.DropColumn(
name: "CommandSubject",
table: "Commands");
}
}
}

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,30 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace BMA.EHR.Infrastructure.Migrations
{
/// <inheritdoc />
public partial class addSequencetoCommandTypeTable : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<int>(
name: "Sequence",
table: "CommandTypes",
type: "int",
nullable: false,
defaultValue: 0,
comment: "ลำดับการทำงาน");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "Sequence",
table: "CommandTypes");
}
}
}

View file

@ -0,0 +1,42 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace BMA.EHR.Infrastructure.Migrations
{
/// <inheritdoc />
public partial class RemoveSequencefromCommandTypeTable : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "Sequence",
table: "CommandTypes");
migrationBuilder.AddColumn<int>(
name: "Sequence",
table: "CommandStatuses",
type: "int",
nullable: false,
defaultValue: 0,
comment: "ลำดับการทำงาน");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "Sequence",
table: "CommandStatuses");
migrationBuilder.AddColumn<int>(
name: "Sequence",
table: "CommandTypes",
type: "int",
nullable: false,
defaultValue: 0,
comment: "ลำดับการทำงาน");
}
}
}

View file

@ -0,0 +1,30 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace BMA.EHR.Infrastructure.Migrations
{
/// <inheritdoc />
public partial class AddAuthorizedPositiontoCommandTable : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<string>(
name: "AuthorizedPosition",
table: "Commands",
type: "longtext",
nullable: false,
comment: "ตำแหน่งผู้มีอำนาจลงนาม")
.Annotation("MySql:CharSet", "utf8mb4");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "AuthorizedPosition",
table: "Commands");
}
}
}

View file

@ -28,6 +28,11 @@ namespace BMA.EHR.Infrastructure.Migrations
.HasComment("PrimaryKey")
.HasAnnotation("Relational:JsonPropertyName", "id");
b.Property<string>("AuthorizedPosition")
.IsRequired()
.HasColumnType("longtext")
.HasComment("ตำแหน่งผู้มีอำนาจลงนาม");
b.Property<string>("AuthorizedUserFullName")
.IsRequired()
.HasColumnType("longtext")
@ -37,6 +42,14 @@ namespace BMA.EHR.Infrastructure.Migrations
.HasColumnType("char(36)")
.HasComment("รหัสอ้างอิงผู้มีอำนาจลงนาม");
b.Property<DateTime?>("CommandAffectDate")
.HasColumnType("datetime(6)")
.HasComment("วันที่คำสั่งมีผล");
b.Property<DateTime?>("CommandExcecuteDate")
.HasColumnType("datetime(6)")
.HasComment("วันที่ออกคำสั่ง");
b.Property<string>("CommandNo")
.IsRequired()
.HasMaxLength(10)
@ -47,6 +60,12 @@ namespace BMA.EHR.Infrastructure.Migrations
.HasColumnType("char(36)")
.HasComment("รหัสอ้างอิงสถานะคำสั่ง");
b.Property<string>("CommandSubject")
.IsRequired()
.HasMaxLength(500)
.HasColumnType("varchar(500)")
.HasComment("คำสั่งเรื่อง");
b.Property<Guid>("CommandTypeId")
.HasColumnType("char(36)")
.HasComment("รหัสอ้างอิงประเภทคำสั่ง");
@ -57,6 +76,24 @@ namespace BMA.EHR.Infrastructure.Migrations
.HasColumnType("varchar(4)")
.HasComment("ปีที่ออกคำสั่ง");
b.Property<DateTime>("ConclusionRegisterDate")
.HasColumnType("datetime(6)")
.HasComment("ลงวันที่ (เรื่อง รับสมัครสอบฯ)");
b.Property<string>("ConclusionRegisterNo")
.IsRequired()
.HasColumnType("longtext")
.HasComment("มติ กก. ครั้งที่ (เรื่อง รับสมัครสอบฯ)");
b.Property<DateTime>("ConclusionResultDate")
.HasColumnType("datetime(6)")
.HasComment("ลงวันที่ (เรื่อง ผลการสอบแข่งขัน)");
b.Property<string>("ConclusionResultNo")
.IsRequired()
.HasColumnType("longtext")
.HasComment("มติ กก. ครั้งที่ (เรื่อง ผลการสอบแข่งขัน)");
b.Property<DateTime>("CreatedAt")
.HasColumnType("datetime(6)")
.HasColumnOrder(100)
@ -76,9 +113,9 @@ namespace BMA.EHR.Infrastructure.Migrations
.HasColumnOrder(101)
.HasComment("User Id ที่สร้างข้อมูล");
b.Property<string>("Discriminator")
.IsRequired()
.HasColumnType("longtext");
b.Property<Guid>("ExamRoundId")
.HasColumnType("char(36)")
.HasComment("อ้างอิงรอบการสอบ");
b.Property<Guid>("IssuerOrganizationId")
.HasColumnType("char(36)")
@ -108,17 +145,18 @@ namespace BMA.EHR.Infrastructure.Migrations
.HasColumnOrder(102)
.HasComment("แก้ไขข้อมูลล่าสุดเมื่อ");
b.Property<string>("PositionName")
.IsRequired()
.HasColumnType("longtext")
.HasComment("ตำแหน่งที่บรรจุ");
b.HasKey("Id");
b.HasIndex("CommandStatusId");
b.HasIndex("CommandTypeId");
b.ToTable("Command");
b.HasDiscriminator<string>("Discriminator").HasValue("Command");
b.UseTphMappingStrategy();
b.ToTable("Commands");
});
modelBuilder.Entity("BMA.EHR.Domain.Models.Commands.Core.CommandDocument", b =>
@ -241,6 +279,10 @@ namespace BMA.EHR.Infrastructure.Migrations
.HasColumnType("varchar(100)")
.HasComment("สถานะของคำสั่ง");
b.Property<int>("Sequence")
.HasColumnType("int")
.HasComment("ลำดับการทำงาน");
b.HasKey("Id");
b.ToTable("CommandStatuses");
@ -10227,40 +10269,6 @@ namespace BMA.EHR.Infrastructure.Migrations
b.ToTable("PlacementTypes");
});
modelBuilder.Entity("BMA.EHR.Domain.Models.Commands.PlacementCommand", b =>
{
b.HasBaseType("BMA.EHR.Domain.Models.Commands.Core.Command");
b.Property<DateTime>("ConclusionRegisterDate")
.HasColumnType("datetime(6)")
.HasComment("ลงวันที่ (เรื่อง รับสมัครสอบฯ)");
b.Property<string>("ConclusionRegisterNo")
.IsRequired()
.HasColumnType("longtext")
.HasComment("มติ กก. ครั้งที่ (เรื่อง รับสมัครสอบฯ)");
b.Property<DateTime>("ConclusionResultDate")
.HasColumnType("datetime(6)")
.HasComment("ลงวันที่ (เรื่อง ผลการสอบแข่งขัน)");
b.Property<string>("ConclusionResultNo")
.IsRequired()
.HasColumnType("longtext")
.HasComment("มติ กก. ครั้งที่ (เรื่อง ผลการสอบแข่งขัน)");
b.Property<Guid>("ExamRoundId")
.HasColumnType("char(36)")
.HasComment("อ้างอิงรอบการสอบ");
b.Property<string>("PositionName")
.IsRequired()
.HasColumnType("longtext")
.HasComment("ตำแหน่งที่บรรจุ");
b.HasDiscriminator().HasValue("PlacementCommand");
});
modelBuilder.Entity("BMA.EHR.Domain.Models.Commands.Core.Command", b =>
{
b.HasOne("BMA.EHR.Domain.Models.Commands.Core.CommandStatus", "CommandStatus")

View file

@ -272,7 +272,7 @@ namespace BMA.EHR.Infrastructure.Persistence
public DbSet<DeploymentChannel> DeploymentChannels { get; set; }
public DbSet<PlacementCommand> PlacementCommands { get; set; }
public DbSet<Command> Commands { get; set; }
#endregion

View file

@ -0,0 +1,48 @@
using BMA.EHR.Application.Repositories.Commands;
using BMA.EHR.Domain.Models.Commands.Core;
using BMA.EHR.Domain.Models.MetaData;
using Microsoft.AspNetCore.Builder;
using Microsoft.Extensions.DependencyInjection;
using OfficeOpenXml;
namespace BMA.EHR.Infrastructure.Persistence
{
public static class CommandDataSeeder
{
public static async Task SeedData(WebApplication app)
{
using var scope = app.Services.CreateScope();
var service = scope.ServiceProvider.GetRequiredService<CommandStatusRepository>();
if ((await service.GetAllAsync()).Count() == 0)
{
// read excels into object
var excelFile = "SeedCommand.xlsx";
using (var excel = new ExcelPackage(new FileInfo(excelFile)))
{
var workSheet = excel.Workbook.Worksheets.FirstOrDefault(x => x.Name.ToLower() == "commandstatus");
var totalRows = workSheet?.Dimension.Rows;
int row = 2;
while (row <= totalRows)
{
var cell1 = workSheet?.Cells[row, 1]?.GetValue<string>();
if (cell1 == "" || cell1 == null) break;
var inserted = new CommandStatus
{
Id = Guid.Parse(workSheet?.Cells[row, 1]?.GetValue<string>()!),
Name = workSheet?.Cells[row, 2]?.GetValue<string>()!,
Sequence = (int)workSheet?.Cells[row, 3]?.GetValue<int>()!
};
await service.AddAsync(inserted);
row++;
}
}
}
}
}
}

View file

@ -1,35 +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=127.0.0.1;user=root;password=P@ssw0rd;port=3308;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"
}
"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"
}

Some files were not shown because too many files have changed in this diff Show more