add authname

This commit is contained in:
kittapath-Jool 2025-09-15 16:02:57 +07:00
parent 579d82a9df
commit c1fcb04421
7 changed files with 3225 additions and 26 deletions

View file

@ -493,6 +493,23 @@ namespace BMA.EHR.Recurit.Exam.Service.Controllers
LastUpdateUserId = UserId ?? "",
LastUpdateFullName = FullName ?? "System Administrator",
};
var apiUrl = $"{_configuration["API"]}/org/find/head/officer";
using (var client = new HttpClient())
{
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
var _req = new HttpRequestMessage(HttpMethod.Get, apiUrl);
var _res = await client.SendAsync(_req);
var _result = await _res.Content.ReadAsStringAsync();
if (_res.IsSuccessStatusCode)
{
var org = JsonConvert.DeserializeObject<dynamic>(_result);
periodExam.AuthName = org.result.name == null ? "" : org.result.name;
periodExam.AuthPosition = org.result.position == null ? "" : org.result.position;
}
}
await _context.PeriodExams.AddAsync(periodExam);
await _context.SaveChangesAsync();
@ -1594,22 +1611,6 @@ namespace BMA.EHR.Recurit.Exam.Service.Controllers
// ใช้ dictionary lookup แทน query DB ทีละรอบ
if (!string.IsNullOrEmpty(r.ExamId) && recruitsDict.TryGetValue(r.ExamId, out var recruit))
{
// var apiUrl = $"{_configuration["API"]}/org/find/head/officer";
// using (var client = new HttpClient())
// {
// client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
// client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
// var _req = new HttpRequestMessage(HttpMethod.Get, apiUrl);
// var _res = await client.SendAsync(_req);
// var _result = await _res.Content.ReadAsStringAsync();
// if (_res.IsSuccessStatusCode)
// {
// var org = JsonConvert.DeserializeObject<dynamic>(_result);
// recruit.AuthName = org.result.name == null ? "" : org.result.name;
// recruit.AuthPosition = org.result.position == null ? "" : org.result.position;
// }
// }
r.CitizenId = workSheet?.Cells[row, 3]?.GetValue<string>();
// ภาคความรู้ความสามารถที่ใช้เฉพาะตำแหน่ง

View file

@ -101,8 +101,8 @@ namespace BMA.EHR.Recurit.Exam.Service.Controllers
FullName = $"{p.Prefix}{p.FirstName} {p.LastName}",
ExamResult = sr == null ? "" : sr.ExamStatus,
EndDate = p.PeriodExam.RegisterEndDate == null ? null : p.PeriodExam.RegisterEndDate.Value.ToThaiFullDate3(),
AuthName = "นายณัฐพงศ์ ดิษยบุตร",
AuthPosition = "หัวหน้าสำนักงาน ก.ก."
AuthName = p.PeriodExam.AuthName,
AuthPosition = p.PeriodExam.AuthPosition,
})
.FirstOrDefaultAsync();

View file

@ -1007,12 +1007,6 @@ namespace BMA.EHR.Recurit.Exam.Service.Data.Migrations
b.Property<DateTime>("ApplyDate")
.HasColumnType("datetime(6)");
b.Property<string>("AuthName")
.HasColumnType("longtext");
b.Property<string>("AuthPosition")
.HasColumnType("longtext");
b.Property<DateTime>("CitizenCardExpireDate")
.HasColumnType("datetime(6)");
@ -2229,6 +2223,12 @@ namespace BMA.EHR.Recurit.Exam.Service.Data.Migrations
.HasColumnOrder(6)
.HasComment("วันเริ่มประกาศ");
b.Property<string>("AuthName")
.HasColumnType("longtext");
b.Property<string>("AuthPosition")
.HasColumnType("longtext");
b.Property<string>("Category")
.HasColumnType("longtext")
.HasComment("สำนัก");

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,62 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace BMA.EHR.Recurit.Exam.Service.Migrations
{
/// <inheritdoc />
public partial class update_table_period_add_authname : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "AuthName",
table: "Disables");
migrationBuilder.DropColumn(
name: "AuthPosition",
table: "Disables");
migrationBuilder.AddColumn<string>(
name: "AuthName",
table: "PeriodExams",
type: "longtext",
nullable: true)
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.AddColumn<string>(
name: "AuthPosition",
table: "PeriodExams",
type: "longtext",
nullable: true)
.Annotation("MySql:CharSet", "utf8mb4");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "AuthName",
table: "PeriodExams");
migrationBuilder.DropColumn(
name: "AuthPosition",
table: "PeriodExams");
migrationBuilder.AddColumn<string>(
name: "AuthName",
table: "Disables",
type: "longtext",
nullable: true)
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.AddColumn<string>(
name: "AuthPosition",
table: "Disables",
type: "longtext",
nullable: true)
.Annotation("MySql:CharSet", "utf8mb4");
}
}
}

View file

@ -80,8 +80,8 @@ namespace BMA.EHR.Recurit.Exam.Service.Models.Disables
public string? PositionName { get; set; }//
public string? PositionType { get; set; }
public string? PositionLevel { get; set; }
public string? AuthName { get; set; }
public string? AuthPosition { get; set; }
// public string? AuthName { get; set; }
// public string? AuthPosition { get; set; }
[Comment("บัญชีสอบ")]
public string? HddPosition { get; set; } = string.Empty;

View file

@ -100,6 +100,8 @@ namespace BMA.EHR.Recurit.Exam.Service.Models
[Comment("Ref No1")]
public string? RefNo1 { get; set; }
public string? AuthName { get; set; }
public string? AuthPosition { get; set; }
[Comment("รายชื่อคนสม้ครในรอบ")]
public List<Candidate> Candidate { get; set; } = new List<Candidate>();