add field และ เพิ่ม call ProfileLeave API

This commit is contained in:
Suphonchai Phoonsawat 2025-05-02 20:19:01 +07:00
parent 4382e779d7
commit 5ba93feb52
8 changed files with 1695 additions and 0 deletions

View file

@ -1,5 +1,6 @@
using BMA.EHR.Application.Common.Interfaces;
using BMA.EHR.Application.Responses.Insignias;
using BMA.EHR.Application.Responses.Leaves;
using BMA.EHR.Application.Responses.Organizations;
using BMA.EHR.Application.Responses.Profiles;
using BMA.EHR.Domain.Models.HR;
@ -182,6 +183,29 @@ namespace BMA.EHR.Application.Repositories
}
}
public async Task<GetProfileLeaveByKeycloakDto?> GetProfileLeaveByKeycloakIdAsync(Guid keycloakId, string? accessToken)
{
try
{
var apiPath = $"{_configuration["API"]}/org/dotnet/profile-leave/keycloak/{keycloakId}";
var apiKey = _configuration["API_KEY"];
var apiResult = await GetExternalAPIAsync(apiPath, accessToken ?? "", apiKey);
if (apiResult != null)
{
var raw = JsonConvert.DeserializeObject<GetProfileLeaveByKeycloakResultDto>(apiResult);
if (raw != null)
return raw.Result;
}
return null;
}
catch
{
throw;
}
}
public async Task<GetProfileByKeycloakIdDto?> GetProfileByProfileIdAsync(Guid profileId, string? accessToken)
{
try

View file

@ -0,0 +1,46 @@
namespace BMA.EHR.Application.Responses.Leaves
{
public class GetProfileLeaveByKeycloakDto
{
public DateTime BirthDate { get; set; }
public DateTime RetireDate { get; set; }
public string GovAge { get; set; }
public string Age { get; set; }
public DateTime DateAppoint { get; set; }
public int Amount { get; set; }
public string? TelephoneNumber { get; set; }
public string PositionName { get; set; }
public string PosLevel { get; set; }
public string PosType { get; set; }
public string CurrentAddress { get; set; }
public string Oc { get; set; }
public string Root { get; set; }
public string Child1 { get; set; }
public string? Child2 { get; set; }
public string? Child3 { get; set; }
public string? Child4 { get; set; }
public List<ProfileLeavePosition> Positions { get; set; }
public List<ProfileLeaveEducation> Educations { get; set; }
}
public class ProfileLeavePosition
{
public string? PositionName { get; set; }
public DateTime Date { get; set; }
public string? PositionType { get; set; }
public string? PositionLevel { get; set; }
public string? OrgRoot { get; set; }
public string? OrgChild1 { get; set; }
public string? OrgChild2 { get; set; }
public string? OrgChild3 { get; set; }
public string? OrgChild4 { get; set; }
}
public class ProfileLeaveEducation
{
public string EducationLevel { get; set; }
public string Institute { get; set; }
public string? Country { get; set; }
public DateTime? FinishDate { get; set; }
}
}

View file

@ -0,0 +1,11 @@
namespace BMA.EHR.Application.Responses.Leaves
{
public class GetProfileLeaveByKeycloakResultDto
{
public string Message { get; set; } = string.Empty;
public int Status { get; set; } = -1;
public GetProfileLeaveByKeycloakDto? Result { get; set; }
}
}

View file

@ -200,5 +200,15 @@ namespace BMA.EHR.Domain.Models.Leave.Requests
public List<LeaveRequestApprover> Approvers { get; set; } = new();
public Guid? RootDnaId { get; set; } = Guid.Empty;
public Guid? Child1DnaId { get; set; } = Guid.Empty;
public Guid? Child2DnaId { get; set; } = Guid.Empty;
public Guid? Child3DnaId { get; set; } = Guid.Empty;
public Guid? Child4DnaId { get; set; } = Guid.Empty;
}
}

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,74 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace BMA.EHR.Infrastructure.Migrations.LeaveDb
{
/// <inheritdoc />
public partial class AddDnaIKdtoLeaveRequest : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<Guid>(
name: "Child1DnaId",
table: "LeaveRequests",
type: "char(36)",
nullable: true,
collation: "ascii_general_ci");
migrationBuilder.AddColumn<Guid>(
name: "Child2DnaId",
table: "LeaveRequests",
type: "char(36)",
nullable: true,
collation: "ascii_general_ci");
migrationBuilder.AddColumn<Guid>(
name: "Child3DnaId",
table: "LeaveRequests",
type: "char(36)",
nullable: true,
collation: "ascii_general_ci");
migrationBuilder.AddColumn<Guid>(
name: "Child4DnaId",
table: "LeaveRequests",
type: "char(36)",
nullable: true,
collation: "ascii_general_ci");
migrationBuilder.AddColumn<Guid>(
name: "RootDnaId",
table: "LeaveRequests",
type: "char(36)",
nullable: true,
collation: "ascii_general_ci");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "Child1DnaId",
table: "LeaveRequests");
migrationBuilder.DropColumn(
name: "Child2DnaId",
table: "LeaveRequests");
migrationBuilder.DropColumn(
name: "Child3DnaId",
table: "LeaveRequests");
migrationBuilder.DropColumn(
name: "Child4DnaId",
table: "LeaveRequests");
migrationBuilder.DropColumn(
name: "RootDnaId",
table: "LeaveRequests");
}
}
}

View file

@ -309,24 +309,36 @@ namespace BMA.EHR.Infrastructure.Migrations.LeaveDb
b.Property<string>("Child1")
.HasColumnType("longtext");
b.Property<Guid?>("Child1DnaId")
.HasColumnType("char(36)");
b.Property<Guid?>("Child1Id")
.HasColumnType("char(36)");
b.Property<string>("Child2")
.HasColumnType("longtext");
b.Property<Guid?>("Child2DnaId")
.HasColumnType("char(36)");
b.Property<Guid?>("Child2Id")
.HasColumnType("char(36)");
b.Property<string>("Child3")
.HasColumnType("longtext");
b.Property<Guid?>("Child3DnaId")
.HasColumnType("char(36)");
b.Property<Guid?>("Child3Id")
.HasColumnType("char(36)");
b.Property<string>("Child4")
.HasColumnType("longtext");
b.Property<Guid?>("Child4DnaId")
.HasColumnType("char(36)");
b.Property<Guid?>("Child4Id")
.HasColumnType("char(36)");
@ -572,6 +584,9 @@ namespace BMA.EHR.Infrastructure.Migrations.LeaveDb
b.Property<string>("Root")
.HasColumnType("longtext");
b.Property<Guid?>("RootDnaId")
.HasColumnType("char(36)");
b.Property<Guid?>("RootId")
.HasColumnType("char(36)");

View file

@ -270,6 +270,12 @@ namespace BMA.EHR.Leave.Service.Controllers
Amount = profile.Amount,
BirthDate = profile.BirthDate,
DateAppoint = profile.DateAppoint,
RootDnaId = profile.RootDnaId,
Child1DnaId = profile.Child1DnaId,
Child2DnaId = profile.Child2DnaId,
Child3DnaId = profile.Child3DnaId,
Child4DnaId = profile.Child4DnaId,
};
// get leave last