fix : Add RevisionId For Insignia Period
Some checks failed
release-dev / release-dev (push) Failing after 13s
Some checks failed
release-dev / release-dev (push) Failing after 13s
This commit is contained in:
parent
722a1e33a8
commit
689c425acb
10 changed files with 18272 additions and 63 deletions
|
|
@ -527,11 +527,11 @@ namespace BMA.EHR.Application.Repositories
|
|||
}
|
||||
}
|
||||
|
||||
public async Task<List<GetActiveRootDto>> GetActiveRootAsync(string? accessToken)
|
||||
public async Task<List<GetActiveRootDto>> GetActiveRootAsync(string? accessToken,Guid? revisionId)
|
||||
{
|
||||
try
|
||||
{
|
||||
var apiPath = $"{_configuration["API"]}/org/active/root";
|
||||
var apiPath = $"{_configuration["API"]}/org/active/root/{revisionId}";
|
||||
var apiKey = _configuration["API_KEY"];
|
||||
|
||||
var apiResult = await GetExternalAPIAsync(apiPath, accessToken ?? "", apiKey);
|
||||
|
|
@ -550,6 +550,30 @@ namespace BMA.EHR.Application.Repositories
|
|||
}
|
||||
}
|
||||
|
||||
public async Task<Guid?> GetLastRevision(string? accessToken)
|
||||
{
|
||||
try
|
||||
{
|
||||
var apiPath = $"{_configuration["API"]}/org/active/root/latest";
|
||||
var apiKey = _configuration["API_KEY"];
|
||||
|
||||
var apiResult = await GetExternalAPIAsync(apiPath, accessToken ?? "", apiKey);
|
||||
if (apiResult != null)
|
||||
{
|
||||
var raw = JsonConvert.DeserializeObject<GetLastRevisionDto>(apiResult);
|
||||
if (raw != null)
|
||||
return raw.Result;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
catch
|
||||
{
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
public async Task PostProfileInsigniaAsync(PostProfileInsigniaDto body, string? accessToken)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -0,0 +1,12 @@
|
|||
namespace BMA.EHR.Application.Responses.Organizations;
|
||||
|
||||
public class GetLastRevisionDto
|
||||
{
|
||||
|
||||
public string Message { get; set; } = string.Empty;
|
||||
|
||||
public int Status { get; set; } = -1;
|
||||
|
||||
public Guid Result { get; set; } = new();
|
||||
|
||||
}
|
||||
|
|
@ -29,5 +29,7 @@ namespace BMA.EHR.Domain.Models.Insignias
|
|||
[Comment("สถานะการ Freez ข้อมูล")]
|
||||
public bool IsLock { get; set; } = false;
|
||||
public virtual List<InsigniaRequest> InsigniaRequests { get; set; }
|
||||
|
||||
public Guid? RevisionId { get; set; }
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,8 @@
|
|||
using BMA.EHR.Application.Repositories;
|
||||
using BMA.EHR.Domain.Models.Insignias;
|
||||
using BMA.EHR.Domain.Shared;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
|
|
@ -85,7 +88,13 @@ namespace BMA.EHR.Infrastructure.MessageQueue
|
|||
var userRepo = scope.ServiceProvider.GetRequiredService<UserProfileRepository>();
|
||||
var insigniaRepo = scope.ServiceProvider.GetRequiredService<InsigniaPeriodsRepository>();
|
||||
|
||||
var organizations = await userRepo.GetActiveRootAsync(AccessToken);
|
||||
var selectPeriod = await _insigniaPeriodsRepository.GetByIdAsync(periodId);
|
||||
if (selectPeriod == null)
|
||||
{
|
||||
throw new Exception(GlobalMessages.InsigniaPeriodNotFound);
|
||||
}
|
||||
|
||||
var organizations = await userRepo.GetActiveRootAsync(AccessToken, selectPeriod.RevisionId);
|
||||
|
||||
foreach (var organization in organizations)
|
||||
{
|
||||
|
|
|
|||
18114
BMA.EHR.Infrastructure/Migrations/20240830060027_Add RevisionId to Insignia Period.Designer.cs
generated
Normal file
18114
BMA.EHR.Infrastructure/Migrations/20240830060027_Add RevisionId to Insignia Period.Designer.cs
generated
Normal file
File diff suppressed because it is too large
Load diff
|
|
@ -0,0 +1,30 @@
|
|||
using System;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace BMA.EHR.Infrastructure.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class AddRevisionIdtoInsigniaPeriod : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.AddColumn<Guid>(
|
||||
name: "RevisionId",
|
||||
table: "InsigniaPeriods",
|
||||
type: "char(36)",
|
||||
nullable: true,
|
||||
collation: "ascii_general_ci");
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropColumn(
|
||||
name: "RevisionId",
|
||||
table: "InsigniaPeriods");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -6262,6 +6262,9 @@ namespace BMA.EHR.Infrastructure.Migrations
|
|||
b.Property<Guid?>("ReliefDocId")
|
||||
.HasColumnType("char(36)");
|
||||
|
||||
b.Property<Guid?>("RevisionId")
|
||||
.HasColumnType("char(36)");
|
||||
|
||||
b.Property<int>("Round")
|
||||
.HasColumnType("int")
|
||||
.HasComment("ราบการยื่นขอ");
|
||||
|
|
|
|||
|
|
@ -26,18 +26,21 @@ namespace BMA.EHR.Insignia.Service.Controllers
|
|||
private readonly IHttpContextAccessor _httpContextAccessor;
|
||||
private readonly InsigniaPeriodsRepository _repository;
|
||||
private readonly NotificationRepository _repositoryNoti;
|
||||
private readonly UserProfileRepository _userProfileRepository;
|
||||
|
||||
public InsigniaPeriodController(ApplicationDBContext context,
|
||||
MinIOService documentService,
|
||||
InsigniaPeriodsRepository repository,
|
||||
NotificationRepository repositoryNoti,
|
||||
IHttpContextAccessor httpContextAccessor)
|
||||
IHttpContextAccessor httpContextAccessor,
|
||||
UserProfileRepository userProfileRepository)
|
||||
{
|
||||
_context = context;
|
||||
_documentService = documentService;
|
||||
_repository = repository;
|
||||
_repositoryNoti = repositoryNoti;
|
||||
_httpContextAccessor = httpContextAccessor;
|
||||
_userProfileRepository = userProfileRepository;
|
||||
}
|
||||
|
||||
#region " Properties "
|
||||
|
|
@ -46,6 +49,8 @@ namespace BMA.EHR.Insignia.Service.Controllers
|
|||
|
||||
private string? FullName => _httpContextAccessor?.HttpContext?.User?.FindFirst("name")?.Value;
|
||||
|
||||
private string? AccessToken => _httpContextAccessor?.HttpContext?.Request.Headers["Authorization"];
|
||||
|
||||
#endregion
|
||||
|
||||
/// <summary>
|
||||
|
|
@ -165,6 +170,8 @@ namespace BMA.EHR.Insignia.Service.Controllers
|
|||
[HttpPost()]
|
||||
public async Task<ActionResult<ResponseObject>> Post([FromForm] InsigniaPeriodRequest req)
|
||||
{
|
||||
var revisionId = await _userProfileRepository.GetLastRevision(AccessToken);
|
||||
|
||||
var insigniaPeriod = await _context.InsigniaPeriods.AsQueryable()
|
||||
.Where(x => x.Round == req.Round && x.Year == req.Year)
|
||||
.FirstOrDefaultAsync();
|
||||
|
|
@ -186,6 +193,8 @@ namespace BMA.EHR.Insignia.Service.Controllers
|
|||
LastUpdateFullName = FullName ?? "System Administrator",
|
||||
LastUpdateUserId = UserId ?? "",
|
||||
LastUpdatedAt = DateTime.Now,
|
||||
|
||||
RevisionId = revisionId ?? Guid.Empty
|
||||
};
|
||||
await _context.InsigniaPeriods.AddAsync(period);
|
||||
await _context.SaveChangesAsync();
|
||||
|
|
|
|||
|
|
@ -558,7 +558,13 @@ namespace BMA.EHR.Insignia.Service.Controllers
|
|||
|
||||
// TODO: original code use this in production
|
||||
|
||||
var organizations = await _userProfileRepository.GetActiveRootAsync(AccessToken);
|
||||
var selectPeriod = _context.InsigniaPeriods.AsNoTracking().Where(x => x.Id == insigniaPeriodId).FirstOrDefault();
|
||||
if (selectPeriod == null)
|
||||
{
|
||||
throw new Exception(GlobalMessages.InsigniaPeriodNotFound);
|
||||
}
|
||||
|
||||
var organizations = await _userProfileRepository.GetActiveRootAsync(AccessToken, selectPeriod.RevisionId);
|
||||
|
||||
foreach (var organization in organizations)
|
||||
{
|
||||
|
|
@ -976,7 +982,7 @@ namespace BMA.EHR.Insignia.Service.Controllers
|
|||
.ToListAsync();
|
||||
|
||||
|
||||
var organizations = await _userProfileRepository.GetActiveRootAsync(AccessToken);
|
||||
var organizations = await _userProfileRepository.GetActiveRootAsync(AccessToken, insigniaPeriod.RevisionId);
|
||||
|
||||
var orgAllCount = organizations
|
||||
.Where(x => !orgIdSend.Contains(x.Id))
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@
|
|||
//"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;"
|
||||
//"DefaultConnection": "server=192.168.1.80;user=root;password=adminVM123;port=3306;database=bma_ehr_demo;Convert Zero Datetime=True;Allow User Variables=true;Pooling=True;",
|
||||
"DefaultConnection": "server=192.168.1.81;user=root;password=adminVM123;port=4063;database=bma_ehr;Convert Zero Datetime=True;Allow User Variables=true;Pooling=True;",
|
||||
"DefaultConnection": "server=192.168.1.80;user=root;password=adminVM123;port=3306;database=bma_ehr_demo;Convert Zero Datetime=True;Allow User Variables=true;Pooling=True;",
|
||||
"ExamConnection": "server=192.168.1.80;user=root;password=adminVM123;port=3306;database=bma_ehr_exam_demo;Convert Zero Datetime=True;Allow User Variables=true;Pooling=True;",
|
||||
"LeaveConnection": "server=192.168.1.80;user=root;password=adminVM123;port=3306;database=bma_ehr_leave_demo;Convert Zero Datetime=True;Allow User Variables=true;Pooling=True;",
|
||||
"DisciplineConnection": "server=192.168.1.80;user=root;password=adminVM123;port=3306;database=bma_ehr_discipline_demo;Convert Zero Datetime=True;Allow User Variables=true;Pooling=True;"
|
||||
|
|
@ -45,7 +45,7 @@
|
|||
"API": "https://bma-ehr.frappet.synology.me/api/v1/probation"
|
||||
},
|
||||
"API": "https://bma-ehr.frappet.synology.me/api/v1",
|
||||
"RabbitMQ" :{
|
||||
"RabbitMQ": {
|
||||
"URL": "localhost",
|
||||
"UserName": "frappet",
|
||||
"Password": "FPTadmin2357"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue