retire add approve
This commit is contained in:
parent
8ce58201e9
commit
2b8713cbe0
19 changed files with 22944 additions and 43 deletions
556
BMA.EHR.Application/Repositories/RetirementEmployeeRepository.cs
Normal file
556
BMA.EHR.Application/Repositories/RetirementEmployeeRepository.cs
Normal file
|
|
@ -0,0 +1,556 @@
|
|||
using BMA.EHR.Application.Common.Interfaces;
|
||||
using BMA.EHR.Application.Repositories.MessageQueue;
|
||||
using BMA.EHR.Domain.Models.Notifications;
|
||||
using BMA.EHR.Domain.Models.Retirement;
|
||||
using BMA.EHR.Domain.Shared;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Newtonsoft.Json;
|
||||
using System.Net.Http.Headers;
|
||||
using System.Net.Http.Json;
|
||||
using System.Security.Claims;
|
||||
using System.Text;
|
||||
|
||||
namespace BMA.EHR.Application.Repositories
|
||||
{
|
||||
public class RetirementEmployeeRepository : GenericRepository<Guid, RetirementPeriod>
|
||||
{
|
||||
private readonly IApplicationDBContext _dbContext;
|
||||
private readonly IHttpContextAccessor _httpContextAccessor;
|
||||
private readonly NotificationRepository _repositoryNoti;
|
||||
private readonly IConfiguration _configuration;
|
||||
private readonly string URL = string.Empty;
|
||||
public RetirementEmployeeRepository(IApplicationDBContext dbContext,
|
||||
NotificationRepository repositoryNoti,
|
||||
IHttpContextAccessor httpContextAccessor,
|
||||
UserProfileRepository userProfileRepository,
|
||||
IConfiguration configuration) : base(dbContext, httpContextAccessor)
|
||||
{
|
||||
_dbContext = dbContext;
|
||||
_httpContextAccessor = httpContextAccessor;
|
||||
_repositoryNoti = repositoryNoti;
|
||||
_configuration = configuration;
|
||||
URL = _configuration["MAIN_PAGE"];
|
||||
}
|
||||
|
||||
#region " Properties "
|
||||
private string? UserId => _httpContextAccessor?.HttpContext?.User?.FindFirst(ClaimTypes.NameIdentifier)?.Value;
|
||||
private string? FullName => _httpContextAccessor?.HttpContext?.User?.FindFirst("name")?.Value;
|
||||
private string? token => _httpContextAccessor?.HttpContext?.Request.Headers["Authorization"];
|
||||
|
||||
#endregion
|
||||
|
||||
//ปลดออก
|
||||
public async Task NotifyDischarge()
|
||||
{
|
||||
var cronjobNotis = await _dbContext.Set<RetirementDischarge>()
|
||||
.Include(x => x.Profile)
|
||||
.ThenInclude(x => x.Prefix)
|
||||
.Where(x => x.Date != null && x.Date.Value.Date == DateTime.Now.Date)
|
||||
.AsQueryable()
|
||||
.ToListAsync();
|
||||
foreach (var cronjobNoti in cronjobNotis)
|
||||
{
|
||||
cronjobNoti.Profile.IsLeave = true;
|
||||
cronjobNoti.Profile.LeaveReason = "DISCHARGE";
|
||||
cronjobNoti.Profile.LeaveDate = DateTime.Now;
|
||||
}
|
||||
await _dbContext.SaveChangesAsync();
|
||||
}
|
||||
|
||||
//ไล่ออก
|
||||
public async Task NotifyExpulsion()
|
||||
{
|
||||
var cronjobNotis = await _dbContext.Set<RetirementExpulsion>()
|
||||
.Include(x => x.Profile)
|
||||
.ThenInclude(x => x.Prefix)
|
||||
.Where(x => x.Date != null && x.Date.Value.Date == DateTime.Now.Date)
|
||||
.AsQueryable()
|
||||
.ToListAsync();
|
||||
foreach (var cronjobNoti in cronjobNotis)
|
||||
{
|
||||
cronjobNoti.Profile.IsLeave = true;
|
||||
cronjobNoti.Profile.LeaveReason = "DISMISS";
|
||||
cronjobNoti.Profile.LeaveDate = DateTime.Now;
|
||||
}
|
||||
await _dbContext.SaveChangesAsync();
|
||||
}
|
||||
|
||||
//ให้ออก
|
||||
public async Task NotifyOut()
|
||||
{
|
||||
var cronjobNotis = await _dbContext.Set<RetirementOut>()
|
||||
//.Include(x => x.Profile)
|
||||
//.ThenInclude(x => x.Prefix)
|
||||
.Where(x => x.Date != null && x.Date.Value.Date == DateTime.Now.Date)
|
||||
.AsQueryable()
|
||||
.ToListAsync();
|
||||
await _dbContext.SaveChangesAsync();
|
||||
}
|
||||
|
||||
//เกษียณอายุราชการ
|
||||
//public async Task ExecuteRetirement()
|
||||
//{
|
||||
// var retirePeriodOfficer = await _dbContext.Set<RetirementPeriod>()
|
||||
// .Include(x => x.RetirementRawProfiles.Where(y => y.Remove != "REMOVE"))
|
||||
// .Where(x => x.Year == DateTime.Now.Year)
|
||||
// .Where(x => x.Type.Trim().ToUpper().Contains("OFFICER"))
|
||||
// .FirstOrDefaultAsync();
|
||||
|
||||
// if (retirePeriodOfficer == null)
|
||||
// return;
|
||||
|
||||
// var body = new
|
||||
// {
|
||||
// data = retirePeriodOfficer.RetirementRawProfiles
|
||||
// .Select(x => new
|
||||
// {
|
||||
// profileId = x.profileId
|
||||
// })
|
||||
// .ToList()
|
||||
// };
|
||||
|
||||
// //ข้าราชการ
|
||||
// //var apiUrl = $"{_configuration["API"]}/org/unauthorize/retirement";
|
||||
// using (var client = new HttpClient())
|
||||
// {
|
||||
// client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
|
||||
// client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
|
||||
|
||||
// var jsonBody = JsonConvert.SerializeObject(body);
|
||||
// var content = new StringContent(jsonBody, Encoding.UTF8, "application/json");
|
||||
|
||||
// var _req = new HttpRequestMessage(HttpMethod.Patch, apiUrl)
|
||||
// {
|
||||
// Content = content
|
||||
// };
|
||||
// var response = await client.SendAsync(_req);
|
||||
// var responseContent = await response.Content.ReadAsStringAsync();
|
||||
// if (!response.IsSuccessStatusCode)
|
||||
// {
|
||||
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
|
||||
public void TestMethod()
|
||||
{
|
||||
return;
|
||||
}
|
||||
public async Task<RetirementResignEmployee?> GetByIdAsync(Guid id)
|
||||
{
|
||||
try
|
||||
{
|
||||
var data = await _dbContext.Set<RetirementResignEmployee>().AsQueryable()
|
||||
.AsNoTracking()
|
||||
.Include(x => x.Approvers)
|
||||
.FirstOrDefaultAsync(x => x.Id == id);
|
||||
|
||||
return data;
|
||||
}
|
||||
catch
|
||||
{
|
||||
throw;
|
||||
}
|
||||
|
||||
}
|
||||
public async Task<RetirementResignEmployee?> GetByIdWithTrackingAsync(Guid id)
|
||||
{
|
||||
var data = await _dbContext.Set<RetirementResignEmployee>().AsQueryable()
|
||||
//.AsNoTracking()
|
||||
.Include(x => x.Approvers)
|
||||
.FirstOrDefaultAsync(x => x.Id == id);
|
||||
|
||||
return data;
|
||||
}
|
||||
public async Task OfficerApproveRetirementResignEmployee(Guid id)
|
||||
{
|
||||
var rawData = await GetByIdAsync(id);
|
||||
if (rawData == null)
|
||||
{
|
||||
throw new Exception(GlobalMessages.DataNotFound);
|
||||
}
|
||||
|
||||
rawData.Status = "PENDING";
|
||||
rawData.ApproveStep = "st2";
|
||||
|
||||
await _dbContext.SaveChangesAsync();
|
||||
|
||||
// TODO: Send notification to 1st Commander
|
||||
var firstCommander = rawData.Approvers
|
||||
.Where(x => x.ApproveType!.ToUpper() == "COMMANDER")
|
||||
.OrderBy(x => x.Seq)
|
||||
.FirstOrDefault();
|
||||
// Send Notification
|
||||
var noti1 = new Notification
|
||||
{
|
||||
Body = $"การขอลาออกของคุณ {rawData.firstName} {rawData.lastName} รอรับการอนุมัติจากคุณ",
|
||||
ReceiverUserId = firstCommander!.ProfileId,
|
||||
Type = "",
|
||||
Payload = $"{URL}/retirement/resign-employee-detail/{id}",
|
||||
};
|
||||
_dbContext.Set<Notification>().Add(noti1);
|
||||
await _dbContext.SaveChangesAsync();
|
||||
}
|
||||
|
||||
public async Task CommanderApproveRetirementResignEmployee(Guid id, string reason)
|
||||
{
|
||||
// Get UserId from token
|
||||
var userId = UserId == null ? Guid.Empty : Guid.Parse(UserId);
|
||||
|
||||
|
||||
var rawData = await GetByIdWithTrackingAsync(id);
|
||||
if (rawData == null)
|
||||
{
|
||||
throw new Exception(GlobalMessages.DataNotFound);
|
||||
}
|
||||
|
||||
if (rawData.ApproveStep != "st2")
|
||||
{
|
||||
throw new Exception("คำขอนี้ยังไม่ได้อยู่ในขั้นตอนที่สามารถอนุมัติได้ ไม่สามารถทำรายการได้");
|
||||
}
|
||||
|
||||
// check commander approve
|
||||
//var approvers = await _dbContext.Set<RetirementResignEmployeeApprover>()
|
||||
// //.AsNoTracking()
|
||||
// .Include(x => x.RetirementResignEmployee)
|
||||
// .Where(x => x.RetirementResignEmployee.Id == id && x.ApproveType == "COMMANDER")
|
||||
// .OrderBy(x => x.Seq)
|
||||
// .ToListAsync();
|
||||
|
||||
var approvers = rawData.Approvers.Where(x => x.ApproveType!.ToUpper() == "COMMANDER").OrderBy(x => x.Seq).ToList();
|
||||
|
||||
var approver = approvers.FirstOrDefault(x => x.KeycloakId == userId);
|
||||
if (approver == null)
|
||||
{
|
||||
throw new Exception("คุณไม่มีสิทธิ์อนุมัติการลาออกในขั้นตอนนี้");
|
||||
}
|
||||
|
||||
// check prev approver มี action แล้วหรือไม่?
|
||||
var prevApprover = approvers.FirstOrDefault(x => x.Seq == approver.Seq - 1);
|
||||
|
||||
if (prevApprover != null)
|
||||
{
|
||||
if (prevApprover.ApproveStatus == "PENDING")
|
||||
{
|
||||
throw new Exception("ไม่สามารถทำการอนุมัติได้ เนื่องจากยังอยู่ระหว่างการพิจารณาโดยผู้บังคับบัญชารายก่อนหน้า");
|
||||
}
|
||||
}
|
||||
|
||||
var maxSeq = approvers.Max(x => x.Seq);
|
||||
|
||||
//var data = await _dbContext.Set<RetirementResignEmployeeApprover>()
|
||||
// .AsNoTracking()
|
||||
// .Include(x => x.RetirementResignEmployee)
|
||||
// .Where(x => x.RetirementResignEmployee.Id == id && x.KeycloakId == userId && x.ApproveType == "COMMANDER")
|
||||
// .FirstOrDefaultAsync();
|
||||
|
||||
//if(data != null)
|
||||
//{
|
||||
// data.ApproveStatus = "APPROVE";
|
||||
// data.Comment = reason;
|
||||
|
||||
// data.LastUpdatedAt = DateTime.Now;
|
||||
// data.LastUpdateUserId = userId.ToString("D");
|
||||
// data.LastUpdateFullName = FullName ?? "";
|
||||
|
||||
// await _dbContext.SaveChangesAsync();
|
||||
//}
|
||||
|
||||
approver.ApproveStatus = "APPROVE";
|
||||
approver.Comment = reason;
|
||||
|
||||
//await _dbContext.SaveChangesAsync();
|
||||
|
||||
if (approver.Seq != maxSeq)
|
||||
{
|
||||
rawData.Status = "PENDING";
|
||||
await _dbContext.SaveChangesAsync();
|
||||
|
||||
var nextApprover = approvers.FirstOrDefault(x => x.Seq == approver.Seq + 1);
|
||||
|
||||
// Send Noti
|
||||
var noti = new Notification
|
||||
{
|
||||
Body = $"การขอลาออกของคุณ {rawData.firstName} {rawData.lastName} รอรับการอนุมัติจากคุณ",
|
||||
ReceiverUserId = nextApprover!.ProfileId,
|
||||
Type = "",
|
||||
Payload = $"{URL}/retirement/resign-employee-detail/{id}",
|
||||
};
|
||||
_dbContext.Set<Notification>().Add(noti);
|
||||
await _dbContext.SaveChangesAsync();
|
||||
}
|
||||
else
|
||||
{
|
||||
rawData.Status = "PENDING";
|
||||
// rawData.LeaveComment = reason;
|
||||
rawData.ApproveStep = "st3";
|
||||
|
||||
await _dbContext.SaveChangesAsync();
|
||||
|
||||
// TODO: Send notification to 1st Approver
|
||||
var firstCommander = rawData.Approvers
|
||||
.Where(x => x.ApproveType!.ToUpper() == "APPROVER")
|
||||
.OrderBy(x => x.Seq)
|
||||
.FirstOrDefault();
|
||||
|
||||
// Send Notification
|
||||
var noti1 = new Notification
|
||||
{
|
||||
Body = $"การขอลาออกของคุณ {rawData.firstName} {rawData.lastName} รอรับการอนุมัติจากคุณ",
|
||||
ReceiverUserId = firstCommander!.ProfileId,
|
||||
Type = "",
|
||||
Payload = $"{URL}/retirement/resign-employee-detail/{id}",
|
||||
};
|
||||
_dbContext.Set<Notification>().Add(noti1);
|
||||
await _dbContext.SaveChangesAsync();
|
||||
}
|
||||
}
|
||||
|
||||
public async Task CommanderRejectRetirementResignEmployee(Guid id, string reason)
|
||||
{
|
||||
// Get UserId from token
|
||||
var userId = UserId == null ? Guid.Empty : Guid.Parse(UserId);
|
||||
|
||||
|
||||
var rawData = await GetByIdWithTrackingAsync(id);
|
||||
if (rawData == null)
|
||||
{
|
||||
throw new Exception(GlobalMessages.DataNotFound);
|
||||
}
|
||||
|
||||
if (rawData.ApproveStep != "st2")
|
||||
{
|
||||
throw new Exception("คำขอนี้ยังไม่ได้อยู่ในขั้นตอนที่สามารถอนุมัติได้ ไม่สามารถทำรายการได้");
|
||||
}
|
||||
|
||||
// check commander approve
|
||||
var approvers = rawData.Approvers.Where(x => x.ApproveType!.ToUpper() == "COMMANDER").OrderBy(x => x.Seq).ToList();
|
||||
|
||||
var approver = approvers.FirstOrDefault(x => x.KeycloakId == userId);
|
||||
if (approver == null)
|
||||
{
|
||||
throw new Exception("คุณไม่มีสิทธิ์อนุมัติการลาออกในขั้นตอนนี้");
|
||||
}
|
||||
|
||||
// check prev approver มี action แล้วหรือไม่?
|
||||
var prevApprover = approvers.FirstOrDefault(x => x.Seq == approver.Seq - 1);
|
||||
|
||||
if (prevApprover != null)
|
||||
{
|
||||
if (prevApprover.ApproveStatus == "PENDING")
|
||||
{
|
||||
throw new Exception("ไม่สามารถทำการอนุมัติได้ เนื่องจากยังอยู่ระหว่างการพิจารณาโดยผู้บังคับบัญชารายก่อนหน้า");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
var maxSeq = approvers.Max(x => x.Seq);
|
||||
|
||||
approver.ApproveStatus = "REJECT";
|
||||
approver.Comment = reason;
|
||||
|
||||
if (approver.Seq != maxSeq)
|
||||
{
|
||||
|
||||
|
||||
var nextApprover = approvers.FirstOrDefault(x => x.Seq == approver.Seq + 1);
|
||||
// Send Noti
|
||||
var noti = new Notification
|
||||
{
|
||||
Body = $"การขอลาออกของคุณ {rawData.firstName} {rawData.lastName} รอรับการอนุมัติจากคุณ",
|
||||
ReceiverUserId = nextApprover!.ProfileId,
|
||||
Type = "",
|
||||
Payload = $"{URL}/retirement/resign-employee-detail/{id}",
|
||||
};
|
||||
_dbContext.Set<Notification>().Add(noti);
|
||||
await _dbContext.SaveChangesAsync();
|
||||
|
||||
rawData.Status = "PENDING";
|
||||
await _dbContext.SaveChangesAsync();
|
||||
}
|
||||
else
|
||||
{
|
||||
rawData.Status = "PENDING";
|
||||
// rawData.LeaveComment = reason;
|
||||
rawData.ApproveStep = "st3";
|
||||
|
||||
await _dbContext.SaveChangesAsync();
|
||||
|
||||
// TODO: Send notification to 1st Approver
|
||||
var firstCommander = rawData.Approvers
|
||||
.Where(x => x.ApproveType!.ToUpper() == "APPROVER")
|
||||
.OrderBy(x => x.Seq)
|
||||
.FirstOrDefault();
|
||||
// Send Notification
|
||||
var noti1 = new Notification
|
||||
{
|
||||
Body = $"การขอลาออกของคุณ {rawData.firstName} {rawData.lastName} รอรับการอนุมัติจากคุณ",
|
||||
ReceiverUserId = firstCommander!.ProfileId,
|
||||
Type = "",
|
||||
Payload = $"{URL}/retirement/resign-employee-detail/{id}",
|
||||
};
|
||||
_dbContext.Set<Notification>().Add(noti1);
|
||||
await _dbContext.SaveChangesAsync();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public async Task ApproveRetirementResignEmployee(Guid id, string reason)
|
||||
{
|
||||
// Get UserId from token
|
||||
var userId = UserId == null ? Guid.Empty : Guid.Parse(UserId);
|
||||
|
||||
var rawData = await GetByIdWithTrackingAsync(id);
|
||||
if (rawData == null)
|
||||
{
|
||||
throw new Exception(GlobalMessages.DataNotFound);
|
||||
}
|
||||
|
||||
if (rawData.ApproveStep != "st3")
|
||||
{
|
||||
throw new Exception("คำขอนี้ยังไม่ได้อยู่ในขั้นตอนที่สามารถอนุมัติได้ ไม่สามารถทำรายการได้");
|
||||
}
|
||||
|
||||
// check commander approve
|
||||
var approvers = rawData.Approvers.Where(x => x.ApproveType!.ToUpper() == "APPROVER").OrderBy(x => x.Seq).ToList();
|
||||
|
||||
var approver = approvers.FirstOrDefault(x => x.KeycloakId == userId);
|
||||
if (approver == null)
|
||||
{
|
||||
throw new Exception("คุณไม่มีสิทธิ์อนุมัติการลาออกในขั้นตอนนี้");
|
||||
}
|
||||
|
||||
// check prev approver มี action แล้วหรือไม่?
|
||||
var prevApprover = approvers.FirstOrDefault(x => x.Seq == approver.Seq - 1);
|
||||
|
||||
if (prevApprover != null)
|
||||
{
|
||||
if (prevApprover.ApproveStatus == "PENDING")
|
||||
{
|
||||
throw new Exception("ไม่สามารถทำการอนุมัติได้ เนื่องจากยังอยู่ระหว่างการพิจารณาโดยผู้บังคับบัญชารายก่อนหน้า");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
var maxSeq = approvers.Max(x => x.Seq);
|
||||
|
||||
approver.ApproveStatus = "APPROVE";
|
||||
approver.Comment = reason;
|
||||
|
||||
if (approver.Seq != maxSeq)
|
||||
{
|
||||
var nextApprover = approvers.FirstOrDefault(x => x.Seq == approver.Seq + 1);
|
||||
// Send Noti
|
||||
var noti1 = new Notification
|
||||
{
|
||||
Body = $"การขอลาออกของคุณ {rawData.firstName} {rawData.lastName} รอรับการอนุมัติจากคุณ",
|
||||
ReceiverUserId = nextApprover!.ProfileId,
|
||||
Type = "",
|
||||
Payload = "",
|
||||
};
|
||||
_dbContext.Set<Notification>().Add(noti1);
|
||||
await _dbContext.SaveChangesAsync();
|
||||
|
||||
await _dbContext.SaveChangesAsync();
|
||||
}
|
||||
else
|
||||
{
|
||||
rawData.Status = "APPROVE";
|
||||
// rawData.LeaveDirectorComment = reason;
|
||||
rawData.ApproveStep = "st4";
|
||||
|
||||
await _dbContext.SaveChangesAsync();
|
||||
|
||||
// Send Noti
|
||||
var noti = new Notification
|
||||
{
|
||||
Body = $"การขอลาออกของคุณได้รับการอนุมัติ",
|
||||
ReceiverUserId = Guid.Parse(rawData.profileId),
|
||||
Type = "",
|
||||
Payload = "",
|
||||
};
|
||||
_dbContext.Set<Notification>().Add(noti);
|
||||
await _dbContext.SaveChangesAsync();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public async Task RejectRetirementResignEmployee(Guid id, string reason)
|
||||
{
|
||||
// Get UserId from token
|
||||
var userId = UserId == null ? Guid.Empty : Guid.Parse(UserId);
|
||||
|
||||
var rawData = await GetByIdWithTrackingAsync(id);
|
||||
if (rawData == null)
|
||||
{
|
||||
throw new Exception(GlobalMessages.DataNotFound);
|
||||
}
|
||||
|
||||
if (rawData.ApproveStep != "st3")
|
||||
{
|
||||
throw new Exception("คำขอนี้ยังไม่ได้อยู่ในขั้นตอนที่สามารถอนุมัติได้ ไม่สามารถทำรายการได้");
|
||||
}
|
||||
|
||||
// check commander approve
|
||||
var approvers = rawData.Approvers.Where(x => x.ApproveType!.ToUpper() == "APPROVER").OrderBy(x => x.Seq).ToList();
|
||||
|
||||
var approver = approvers.FirstOrDefault(x => x.KeycloakId == userId);
|
||||
if (approver == null)
|
||||
{
|
||||
throw new Exception("คุณไม่มีสิทธิ์อนุมัติการลาออกในขั้นตอนนี้");
|
||||
}
|
||||
|
||||
// check prev approver มี action แล้วหรือไม่?
|
||||
var prevApprover = approvers.FirstOrDefault(x => x.Seq == approver.Seq - 1);
|
||||
|
||||
if (prevApprover != null)
|
||||
{
|
||||
if (prevApprover.ApproveStatus == "PENDING")
|
||||
{
|
||||
throw new Exception("ไม่สามารถทำการอนุมัติได้ เนื่องจากยังอยู่ระหว่างการพิจารณาโดยผู้บังคับบัญชารายก่อนหน้า");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
var maxSeq = approvers.Max(x => x.Seq);
|
||||
|
||||
approver.ApproveStatus = "REJECT";
|
||||
approver.Comment = reason;
|
||||
|
||||
if (approver.Seq != maxSeq)
|
||||
{
|
||||
var nextApprover = approvers.FirstOrDefault(x => x.Seq == approver.Seq + 1);
|
||||
// Send Noti
|
||||
var noti1 = new Notification
|
||||
{
|
||||
Body = $"การขอลาออกของคุณ {rawData.firstName} {rawData.lastName} รอรับการอนุมัติจากคุณ",
|
||||
ReceiverUserId = nextApprover!.ProfileId,
|
||||
Type = "",
|
||||
Payload = "",
|
||||
};
|
||||
_dbContext.Set<Notification>().Add(noti1);
|
||||
await _dbContext.SaveChangesAsync();
|
||||
}
|
||||
else
|
||||
{
|
||||
rawData.Status = "REJECT";
|
||||
// rawData.LeaveDirectorComment = reason;
|
||||
rawData.ApproveStep = "st5";
|
||||
|
||||
// Send Noti
|
||||
var noti = new Notification
|
||||
{
|
||||
Body = $"การขอลาออกของคุณไม่ได้รับการอนุมัติ \r\nเนื่องจาก{reason}",
|
||||
ReceiverUserId = Guid.Parse(rawData.profileId),
|
||||
Type = "",
|
||||
Payload = "",
|
||||
};
|
||||
_dbContext.Set<Notification>().Add(noti);
|
||||
await _dbContext.SaveChangesAsync();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -1,11 +1,14 @@
|
|||
using BMA.EHR.Application.Common.Interfaces;
|
||||
using BMA.EHR.Application.Repositories.MessageQueue;
|
||||
using BMA.EHR.Domain.Models.Notifications;
|
||||
using BMA.EHR.Domain.Models.Retirement;
|
||||
using BMA.EHR.Domain.Shared;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Newtonsoft.Json;
|
||||
using System.Net.Http.Headers;
|
||||
using System.Net.Http.Json;
|
||||
using System.Security.Claims;
|
||||
using System.Text;
|
||||
|
||||
|
|
@ -17,15 +20,18 @@ namespace BMA.EHR.Application.Repositories
|
|||
private readonly IHttpContextAccessor _httpContextAccessor;
|
||||
private readonly NotificationRepository _repositoryNoti;
|
||||
private readonly IConfiguration _configuration;
|
||||
private readonly string URL = string.Empty;
|
||||
public RetirementRepository(IApplicationDBContext dbContext,
|
||||
NotificationRepository repositoryNoti,
|
||||
IHttpContextAccessor httpContextAccessor,
|
||||
UserProfileRepository userProfileRepository,
|
||||
IConfiguration configuration) : base(dbContext, httpContextAccessor)
|
||||
{
|
||||
_dbContext = dbContext;
|
||||
_httpContextAccessor = httpContextAccessor;
|
||||
_repositoryNoti = repositoryNoti;
|
||||
_configuration = configuration;
|
||||
URL = _configuration["MAIN_PAGE"];
|
||||
}
|
||||
|
||||
#region " Properties "
|
||||
|
|
@ -132,5 +138,422 @@ namespace BMA.EHR.Application.Repositories
|
|||
{
|
||||
return;
|
||||
}
|
||||
public async Task<RetirementResign?> GetByIdAsync(Guid id)
|
||||
{
|
||||
try
|
||||
{
|
||||
var data = await _dbContext.Set<RetirementResign>().AsQueryable()
|
||||
.AsNoTracking()
|
||||
.Include(x => x.Approvers)
|
||||
.FirstOrDefaultAsync(x => x.Id == id);
|
||||
|
||||
return data;
|
||||
}
|
||||
catch
|
||||
{
|
||||
throw;
|
||||
}
|
||||
|
||||
}
|
||||
public async Task<RetirementResign?> GetByIdWithTrackingAsync(Guid id)
|
||||
{
|
||||
var data = await _dbContext.Set<RetirementResign>().AsQueryable()
|
||||
//.AsNoTracking()
|
||||
.Include(x => x.Approvers)
|
||||
.FirstOrDefaultAsync(x => x.Id == id);
|
||||
|
||||
return data;
|
||||
}
|
||||
public async Task OfficerApproveRetirementResign(Guid id)
|
||||
{
|
||||
var rawData = await GetByIdAsync(id);
|
||||
if (rawData == null)
|
||||
{
|
||||
throw new Exception(GlobalMessages.DataNotFound);
|
||||
}
|
||||
|
||||
rawData.Status = "PENDING";
|
||||
rawData.ApproveStep = "st2";
|
||||
|
||||
await _dbContext.SaveChangesAsync();
|
||||
|
||||
// TODO: Send notification to 1st Commander
|
||||
var firstCommander = rawData.Approvers
|
||||
.Where(x => x.ApproveType!.ToUpper() == "COMMANDER")
|
||||
.OrderBy(x => x.Seq)
|
||||
.FirstOrDefault();
|
||||
// Send Notification
|
||||
var noti1 = new Notification
|
||||
{
|
||||
Body = $"การขอลาออกของคุณ {rawData.firstName} {rawData.lastName} รอรับการอนุมัติจากคุณ",
|
||||
ReceiverUserId = firstCommander!.ProfileId,
|
||||
Type = "",
|
||||
Payload = $"{URL}/retirement/resign-detail/{id}",
|
||||
};
|
||||
_dbContext.Set<Notification>().Add(noti1);
|
||||
await _dbContext.SaveChangesAsync();
|
||||
}
|
||||
|
||||
public async Task CommanderApproveRetirementResign(Guid id, string reason)
|
||||
{
|
||||
// Get UserId from token
|
||||
var userId = UserId == null ? Guid.Empty : Guid.Parse(UserId);
|
||||
|
||||
|
||||
var rawData = await GetByIdWithTrackingAsync(id);
|
||||
if (rawData == null)
|
||||
{
|
||||
throw new Exception(GlobalMessages.DataNotFound);
|
||||
}
|
||||
|
||||
if (rawData.ApproveStep != "st2")
|
||||
{
|
||||
throw new Exception("คำขอนี้ยังไม่ได้อยู่ในขั้นตอนที่สามารถอนุมัติได้ ไม่สามารถทำรายการได้");
|
||||
}
|
||||
|
||||
// check commander approve
|
||||
//var approvers = await _dbContext.Set<RetirementResignApprover>()
|
||||
// //.AsNoTracking()
|
||||
// .Include(x => x.RetirementResign)
|
||||
// .Where(x => x.RetirementResign.Id == id && x.ApproveType == "COMMANDER")
|
||||
// .OrderBy(x => x.Seq)
|
||||
// .ToListAsync();
|
||||
|
||||
var approvers = rawData.Approvers.Where(x => x.ApproveType!.ToUpper() == "COMMANDER").OrderBy(x => x.Seq).ToList();
|
||||
|
||||
var approver = approvers.FirstOrDefault(x => x.KeycloakId == userId);
|
||||
if (approver == null)
|
||||
{
|
||||
throw new Exception("คุณไม่มีสิทธิ์อนุมัติการลาออกในขั้นตอนนี้");
|
||||
}
|
||||
|
||||
// check prev approver มี action แล้วหรือไม่?
|
||||
var prevApprover = approvers.FirstOrDefault(x => x.Seq == approver.Seq - 1);
|
||||
|
||||
if (prevApprover != null)
|
||||
{
|
||||
if (prevApprover.ApproveStatus == "PENDING")
|
||||
{
|
||||
throw new Exception("ไม่สามารถทำการอนุมัติได้ เนื่องจากยังอยู่ระหว่างการพิจารณาโดยผู้บังคับบัญชารายก่อนหน้า");
|
||||
}
|
||||
}
|
||||
|
||||
var maxSeq = approvers.Max(x => x.Seq);
|
||||
|
||||
//var data = await _dbContext.Set<RetirementResignApprover>()
|
||||
// .AsNoTracking()
|
||||
// .Include(x => x.RetirementResign)
|
||||
// .Where(x => x.RetirementResign.Id == id && x.KeycloakId == userId && x.ApproveType == "COMMANDER")
|
||||
// .FirstOrDefaultAsync();
|
||||
|
||||
//if(data != null)
|
||||
//{
|
||||
// data.ApproveStatus = "APPROVE";
|
||||
// data.Comment = reason;
|
||||
|
||||
// data.LastUpdatedAt = DateTime.Now;
|
||||
// data.LastUpdateUserId = userId.ToString("D");
|
||||
// data.LastUpdateFullName = FullName ?? "";
|
||||
|
||||
// await _dbContext.SaveChangesAsync();
|
||||
//}
|
||||
|
||||
approver.ApproveStatus = "APPROVE";
|
||||
approver.Comment = reason;
|
||||
|
||||
//await _dbContext.SaveChangesAsync();
|
||||
|
||||
if (approver.Seq != maxSeq)
|
||||
{
|
||||
rawData.Status = "PENDING";
|
||||
await _dbContext.SaveChangesAsync();
|
||||
|
||||
var nextApprover = approvers.FirstOrDefault(x => x.Seq == approver.Seq + 1);
|
||||
|
||||
// Send Noti
|
||||
var noti = new Notification
|
||||
{
|
||||
Body = $"การขอลาออกของคุณ {rawData.firstName} {rawData.lastName} รอรับการอนุมัติจากคุณ",
|
||||
ReceiverUserId = nextApprover!.ProfileId,
|
||||
Type = "",
|
||||
Payload = $"{URL}/retirement/resign-detail/{id}",
|
||||
};
|
||||
_dbContext.Set<Notification>().Add(noti);
|
||||
await _dbContext.SaveChangesAsync();
|
||||
}
|
||||
else
|
||||
{
|
||||
rawData.Status = "PENDING";
|
||||
// rawData.LeaveComment = reason;
|
||||
rawData.ApproveStep = "st3";
|
||||
|
||||
await _dbContext.SaveChangesAsync();
|
||||
|
||||
// TODO: Send notification to 1st Approver
|
||||
var firstCommander = rawData.Approvers
|
||||
.Where(x => x.ApproveType!.ToUpper() == "APPROVER")
|
||||
.OrderBy(x => x.Seq)
|
||||
.FirstOrDefault();
|
||||
|
||||
// Send Notification
|
||||
var noti1 = new Notification
|
||||
{
|
||||
Body = $"การขอลาออกของคุณ {rawData.firstName} {rawData.lastName} รอรับการอนุมัติจากคุณ",
|
||||
ReceiverUserId = firstCommander!.ProfileId,
|
||||
Type = "",
|
||||
Payload = $"{URL}/retirement/resign-detail/{id}",
|
||||
};
|
||||
_dbContext.Set<Notification>().Add(noti1);
|
||||
await _dbContext.SaveChangesAsync();
|
||||
}
|
||||
}
|
||||
|
||||
public async Task CommanderRejectRetirementResign(Guid id, string reason)
|
||||
{
|
||||
// Get UserId from token
|
||||
var userId = UserId == null ? Guid.Empty : Guid.Parse(UserId);
|
||||
|
||||
|
||||
var rawData = await GetByIdWithTrackingAsync(id);
|
||||
if (rawData == null)
|
||||
{
|
||||
throw new Exception(GlobalMessages.DataNotFound);
|
||||
}
|
||||
|
||||
if (rawData.ApproveStep != "st2")
|
||||
{
|
||||
throw new Exception("คำขอนี้ยังไม่ได้อยู่ในขั้นตอนที่สามารถอนุมัติได้ ไม่สามารถทำรายการได้");
|
||||
}
|
||||
|
||||
// check commander approve
|
||||
var approvers = rawData.Approvers.Where(x => x.ApproveType!.ToUpper() == "COMMANDER").OrderBy(x => x.Seq).ToList();
|
||||
|
||||
var approver = approvers.FirstOrDefault(x => x.KeycloakId == userId);
|
||||
if (approver == null)
|
||||
{
|
||||
throw new Exception("คุณไม่มีสิทธิ์อนุมัติการลาออกในขั้นตอนนี้");
|
||||
}
|
||||
|
||||
// check prev approver มี action แล้วหรือไม่?
|
||||
var prevApprover = approvers.FirstOrDefault(x => x.Seq == approver.Seq - 1);
|
||||
|
||||
if (prevApprover != null)
|
||||
{
|
||||
if (prevApprover.ApproveStatus == "PENDING")
|
||||
{
|
||||
throw new Exception("ไม่สามารถทำการอนุมัติได้ เนื่องจากยังอยู่ระหว่างการพิจารณาโดยผู้บังคับบัญชารายก่อนหน้า");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
var maxSeq = approvers.Max(x => x.Seq);
|
||||
|
||||
approver.ApproveStatus = "REJECT";
|
||||
approver.Comment = reason;
|
||||
|
||||
if (approver.Seq != maxSeq)
|
||||
{
|
||||
|
||||
|
||||
var nextApprover = approvers.FirstOrDefault(x => x.Seq == approver.Seq + 1);
|
||||
// Send Noti
|
||||
var noti = new Notification
|
||||
{
|
||||
Body = $"การขอลาออกของคุณ {rawData.firstName} {rawData.lastName} รอรับการอนุมัติจากคุณ",
|
||||
ReceiverUserId = nextApprover!.ProfileId,
|
||||
Type = "",
|
||||
Payload = $"{URL}/retirement/resign-detail/{id}",
|
||||
};
|
||||
_dbContext.Set<Notification>().Add(noti);
|
||||
await _dbContext.SaveChangesAsync();
|
||||
|
||||
rawData.Status = "PENDING";
|
||||
await _dbContext.SaveChangesAsync();
|
||||
}
|
||||
else
|
||||
{
|
||||
rawData.Status = "PENDING";
|
||||
// rawData.LeaveComment = reason;
|
||||
rawData.ApproveStep = "st3";
|
||||
|
||||
await _dbContext.SaveChangesAsync();
|
||||
|
||||
// TODO: Send notification to 1st Approver
|
||||
var firstCommander = rawData.Approvers
|
||||
.Where(x => x.ApproveType!.ToUpper() == "APPROVER")
|
||||
.OrderBy(x => x.Seq)
|
||||
.FirstOrDefault();
|
||||
// Send Notification
|
||||
var noti1 = new Notification
|
||||
{
|
||||
Body = $"การขอลาออกของคุณ {rawData.firstName} {rawData.lastName} รอรับการอนุมัติจากคุณ",
|
||||
ReceiverUserId = firstCommander!.ProfileId,
|
||||
Type = "",
|
||||
Payload = $"{URL}/retirement/resign-detail/{id}",
|
||||
};
|
||||
_dbContext.Set<Notification>().Add(noti1);
|
||||
await _dbContext.SaveChangesAsync();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public async Task ApproveRetirementResign(Guid id, string reason)
|
||||
{
|
||||
// Get UserId from token
|
||||
var userId = UserId == null ? Guid.Empty : Guid.Parse(UserId);
|
||||
|
||||
var rawData = await GetByIdWithTrackingAsync(id);
|
||||
if (rawData == null)
|
||||
{
|
||||
throw new Exception(GlobalMessages.DataNotFound);
|
||||
}
|
||||
|
||||
if (rawData.ApproveStep != "st3")
|
||||
{
|
||||
throw new Exception("คำขอนี้ยังไม่ได้อยู่ในขั้นตอนที่สามารถอนุมัติได้ ไม่สามารถทำรายการได้");
|
||||
}
|
||||
|
||||
// check commander approve
|
||||
var approvers = rawData.Approvers.Where(x => x.ApproveType!.ToUpper() == "APPROVER").OrderBy(x => x.Seq).ToList();
|
||||
|
||||
var approver = approvers.FirstOrDefault(x => x.KeycloakId == userId);
|
||||
if (approver == null)
|
||||
{
|
||||
throw new Exception("คุณไม่มีสิทธิ์อนุมัติการลาออกในขั้นตอนนี้");
|
||||
}
|
||||
|
||||
// check prev approver มี action แล้วหรือไม่?
|
||||
var prevApprover = approvers.FirstOrDefault(x => x.Seq == approver.Seq - 1);
|
||||
|
||||
if (prevApprover != null)
|
||||
{
|
||||
if (prevApprover.ApproveStatus == "PENDING")
|
||||
{
|
||||
throw new Exception("ไม่สามารถทำการอนุมัติได้ เนื่องจากยังอยู่ระหว่างการพิจารณาโดยผู้บังคับบัญชารายก่อนหน้า");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
var maxSeq = approvers.Max(x => x.Seq);
|
||||
|
||||
approver.ApproveStatus = "APPROVE";
|
||||
approver.Comment = reason;
|
||||
|
||||
if (approver.Seq != maxSeq)
|
||||
{
|
||||
var nextApprover = approvers.FirstOrDefault(x => x.Seq == approver.Seq + 1);
|
||||
// Send Noti
|
||||
var noti1 = new Notification
|
||||
{
|
||||
Body = $"การขอลาออกของคุณ {rawData.firstName} {rawData.lastName} รอรับการอนุมัติจากคุณ",
|
||||
ReceiverUserId = nextApprover!.ProfileId,
|
||||
Type = "",
|
||||
Payload = "",
|
||||
};
|
||||
_dbContext.Set<Notification>().Add(noti1);
|
||||
await _dbContext.SaveChangesAsync();
|
||||
|
||||
await _dbContext.SaveChangesAsync();
|
||||
}
|
||||
else
|
||||
{
|
||||
rawData.Status = "APPROVE";
|
||||
// rawData.LeaveDirectorComment = reason;
|
||||
rawData.ApproveStep = "st4";
|
||||
|
||||
await _dbContext.SaveChangesAsync();
|
||||
|
||||
if (rawData.profileId != null)
|
||||
{
|
||||
// Send Noti
|
||||
var noti = new Notification
|
||||
{
|
||||
Body = $"การขอลาออกของคุณได้รับการอนุมัติ",
|
||||
ReceiverUserId = Guid.Parse(rawData.profileId),
|
||||
Type = "",
|
||||
Payload = "",
|
||||
};
|
||||
_dbContext.Set<Notification>().Add(noti);
|
||||
}
|
||||
await _dbContext.SaveChangesAsync();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public async Task RejectRetirementResign(Guid id, string reason)
|
||||
{
|
||||
// Get UserId from token
|
||||
var userId = UserId == null ? Guid.Empty : Guid.Parse(UserId);
|
||||
|
||||
var rawData = await GetByIdWithTrackingAsync(id);
|
||||
if (rawData == null)
|
||||
{
|
||||
throw new Exception(GlobalMessages.DataNotFound);
|
||||
}
|
||||
|
||||
if (rawData.ApproveStep != "st3")
|
||||
{
|
||||
throw new Exception("คำขอนี้ยังไม่ได้อยู่ในขั้นตอนที่สามารถอนุมัติได้ ไม่สามารถทำรายการได้");
|
||||
}
|
||||
|
||||
// check commander approve
|
||||
var approvers = rawData.Approvers.Where(x => x.ApproveType!.ToUpper() == "APPROVER").OrderBy(x => x.Seq).ToList();
|
||||
|
||||
var approver = approvers.FirstOrDefault(x => x.KeycloakId == userId);
|
||||
if (approver == null)
|
||||
{
|
||||
throw new Exception("คุณไม่มีสิทธิ์อนุมัติการลาออกในขั้นตอนนี้");
|
||||
}
|
||||
|
||||
// check prev approver มี action แล้วหรือไม่?
|
||||
var prevApprover = approvers.FirstOrDefault(x => x.Seq == approver.Seq - 1);
|
||||
|
||||
if (prevApprover != null)
|
||||
{
|
||||
if (prevApprover.ApproveStatus == "PENDING")
|
||||
{
|
||||
throw new Exception("ไม่สามารถทำการอนุมัติได้ เนื่องจากยังอยู่ระหว่างการพิจารณาโดยผู้บังคับบัญชารายก่อนหน้า");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
var maxSeq = approvers.Max(x => x.Seq);
|
||||
|
||||
approver.ApproveStatus = "REJECT";
|
||||
approver.Comment = reason;
|
||||
|
||||
if (approver.Seq != maxSeq)
|
||||
{
|
||||
var nextApprover = approvers.FirstOrDefault(x => x.Seq == approver.Seq + 1);
|
||||
// Send Noti
|
||||
var noti1 = new Notification
|
||||
{
|
||||
Body = $"การขอลาออกของคุณ {rawData.firstName} {rawData.lastName} รอรับการอนุมัติจากคุณ",
|
||||
ReceiverUserId = nextApprover!.ProfileId,
|
||||
Type = "",
|
||||
Payload = "",
|
||||
};
|
||||
_dbContext.Set<Notification>().Add(noti1);
|
||||
await _dbContext.SaveChangesAsync();
|
||||
}
|
||||
else
|
||||
{
|
||||
rawData.Status = "REJECT";
|
||||
// rawData.LeaveDirectorComment = reason;
|
||||
rawData.ApproveStep = "st5";
|
||||
|
||||
// Send Noti
|
||||
var noti = new Notification
|
||||
{
|
||||
Body = $"การขอลาออกของคุณไม่ได้รับการอนุมัติ \r\nเนื่องจาก{reason}",
|
||||
ReceiverUserId = Guid.Parse(rawData.profileId),
|
||||
Type = "",
|
||||
Payload = "",
|
||||
};
|
||||
_dbContext.Set<Notification>().Add(noti);
|
||||
await _dbContext.SaveChangesAsync();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -151,7 +151,12 @@ namespace BMA.EHR.Domain.Models.Retirement
|
|||
[Comment("ชื่อระดับตำแหน่ง old")]
|
||||
public string? posLevelNameOld { get; set; }
|
||||
|
||||
[Comment("step การอนุมัติ st1 = จทน.อนุมัตื,st2 = ผู้บังคับบัญชา อนุมัติ ")]
|
||||
public string? ApproveStep { get; set; } = string.Empty;
|
||||
|
||||
|
||||
|
||||
public List<RetirementResignApprover> Approvers { get; set; } = new();
|
||||
public virtual List<RetirementResignDoc> RetirementResignDocs { get; set; } = new List<RetirementResignDoc>();
|
||||
public virtual List<RetirementResignDebtDoc> RetirementResignDebtDocs { get; set; } = new List<RetirementResignDebtDoc>();
|
||||
public virtual List<RetirementResignCancel> RetirementResignCancels { get; set; } = new List<RetirementResignCancel>();
|
||||
|
|
|
|||
29
BMA.EHR.Domain/Models/Retirement/RetirementResignApprover.cs
Normal file
29
BMA.EHR.Domain/Models/Retirement/RetirementResignApprover.cs
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
using BMA.EHR.Domain.Models.Base;
|
||||
namespace BMA.EHR.Domain.Models.Retirement
|
||||
|
||||
{
|
||||
public class RetirementResignApprover : EntityBase
|
||||
{
|
||||
public RetirementResign RetirementResign { get; set; }
|
||||
|
||||
public int Seq { get; set; } = 0;
|
||||
|
||||
public string Prefix { get; set; } = string.Empty;
|
||||
|
||||
public string FirstName { get; set; } = string.Empty;
|
||||
|
||||
public string LastName { get; set; } = string.Empty;
|
||||
|
||||
public string PositionName { get; set; } = string.Empty;
|
||||
|
||||
public Guid ProfileId { get; set; } = Guid.Empty;
|
||||
|
||||
public Guid KeycloakId { get; set; } = Guid.Empty;
|
||||
|
||||
public string ApproveStatus { get; set; } = string.Empty;
|
||||
|
||||
public string Comment { get; set; } = string.Empty;
|
||||
|
||||
public string? ApproveType { get; set; } = string.Empty; // ผู้บังคับบัญชา = commander, ผู้มีอำนาจอนุมัติ = Approver
|
||||
}
|
||||
}
|
||||
|
|
@ -132,5 +132,6 @@ namespace BMA.EHR.Domain.Models.Retirement
|
|||
public string? posLevelNameOld { get; set; }
|
||||
[Required, Comment("อ้างอิงรับย้าย")]
|
||||
public virtual RetirementResign RetirementResign { get; set; }
|
||||
public List<RetirementResignCancelApprover> Approvers { get; set; } = new();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,29 @@
|
|||
using BMA.EHR.Domain.Models.Base;
|
||||
namespace BMA.EHR.Domain.Models.Retirement
|
||||
|
||||
{
|
||||
public class RetirementResignCancelApprover : EntityBase
|
||||
{
|
||||
public RetirementResignCancel RetirementResignCancel { get; set; }
|
||||
|
||||
public int Seq { get; set; } = 0;
|
||||
|
||||
public string Prefix { get; set; } = string.Empty;
|
||||
|
||||
public string FirstName { get; set; } = string.Empty;
|
||||
|
||||
public string LastName { get; set; } = string.Empty;
|
||||
|
||||
public string PositionName { get; set; } = string.Empty;
|
||||
|
||||
public Guid ProfileId { get; set; } = Guid.Empty;
|
||||
|
||||
public Guid KeycloakId { get; set; } = Guid.Empty;
|
||||
|
||||
public string ApproveStatus { get; set; } = string.Empty;
|
||||
|
||||
public string Comment { get; set; } = string.Empty;
|
||||
|
||||
public string? ApproveType { get; set; } = string.Empty; // ผู้บังคับบัญชา = commander, ผู้มีอำนาจอนุมัติ = Approver
|
||||
}
|
||||
}
|
||||
|
|
@ -149,7 +149,11 @@ namespace BMA.EHR.Domain.Models.Retirement
|
|||
[Comment("ชื่อระดับตำแหน่ง old")]
|
||||
public string? posLevelNameOld { get; set; }
|
||||
|
||||
[Comment("step การอนุมัติ st1 = จทน.อนุมัตื,st2 = ผู้บังคับบัญชา อนุมัติ ")]
|
||||
public string? ApproveStep { get; set; } = string.Empty;
|
||||
|
||||
|
||||
public List<RetirementResignEmployeeApprover> Approvers { get; set; } = new();
|
||||
public virtual List<RetirementResignEmployeeDoc> RetirementResignEmployeeDocs { get; set; } = new List<RetirementResignEmployeeDoc>();
|
||||
public virtual List<RetirementResignEmployeeDebtDoc> RetirementResignEmployeeDebtDocs { get; set; } = new List<RetirementResignEmployeeDebtDoc>();
|
||||
public virtual List<RetirementResignEmployeeCancel> RetirementResignEmployeeCancels { get; set; } = new List<RetirementResignEmployeeCancel>();
|
||||
|
|
|
|||
|
|
@ -0,0 +1,29 @@
|
|||
using BMA.EHR.Domain.Models.Base;
|
||||
namespace BMA.EHR.Domain.Models.Retirement
|
||||
|
||||
{
|
||||
public class RetirementResignEmployeeApprover : EntityBase
|
||||
{
|
||||
public RetirementResignEmployee RetirementResignEmployee { get; set; }
|
||||
|
||||
public int Seq { get; set; } = 0;
|
||||
|
||||
public string Prefix { get; set; } = string.Empty;
|
||||
|
||||
public string FirstName { get; set; } = string.Empty;
|
||||
|
||||
public string LastName { get; set; } = string.Empty;
|
||||
|
||||
public string PositionName { get; set; } = string.Empty;
|
||||
|
||||
public Guid ProfileId { get; set; } = Guid.Empty;
|
||||
|
||||
public Guid KeycloakId { get; set; } = Guid.Empty;
|
||||
|
||||
public string ApproveStatus { get; set; } = string.Empty;
|
||||
|
||||
public string Comment { get; set; } = string.Empty;
|
||||
|
||||
public string? ApproveType { get; set; } = string.Empty; // ผู้บังคับบัญชา = commander, ผู้มีอำนาจอนุมัติ = Approver
|
||||
}
|
||||
}
|
||||
|
|
@ -130,5 +130,6 @@ namespace BMA.EHR.Domain.Models.Retirement
|
|||
public string? posLevelNameOld { get; set; }
|
||||
[Required, Comment("อ้างอิงรับย้าย")]
|
||||
public virtual RetirementResignEmployee RetirementResignEmployee { get; set; }
|
||||
public List<RetirementResignEmployeeCancelApprover> Approvers { get; set; } = new();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,29 @@
|
|||
using BMA.EHR.Domain.Models.Base;
|
||||
namespace BMA.EHR.Domain.Models.Retirement
|
||||
|
||||
{
|
||||
public class RetirementResignEmployeeCancelApprover : EntityBase
|
||||
{
|
||||
public RetirementResignEmployeeCancel RetirementResignEmployeeCancel { get; set; }
|
||||
|
||||
public int Seq { get; set; } = 0;
|
||||
|
||||
public string Prefix { get; set; } = string.Empty;
|
||||
|
||||
public string FirstName { get; set; } = string.Empty;
|
||||
|
||||
public string LastName { get; set; } = string.Empty;
|
||||
|
||||
public string PositionName { get; set; } = string.Empty;
|
||||
|
||||
public Guid ProfileId { get; set; } = Guid.Empty;
|
||||
|
||||
public Guid KeycloakId { get; set; } = Guid.Empty;
|
||||
|
||||
public string ApproveStatus { get; set; } = string.Empty;
|
||||
|
||||
public string Comment { get; set; } = string.Empty;
|
||||
|
||||
public string? ApproveType { get; set; } = string.Empty; // ผู้บังคับบัญชา = commander, ผู้มีอำนาจอนุมัติ = Approver
|
||||
}
|
||||
}
|
||||
20595
BMA.EHR.Infrastructure/Migrations/20250507065811_update_table_retirement_add_approver.Designer.cs
generated
Normal file
20595
BMA.EHR.Infrastructure/Migrations/20250507065811_update_table_retirement_add_approver.Designer.cs
generated
Normal file
File diff suppressed because it is too large
Load diff
|
|
@ -0,0 +1,259 @@
|
|||
using System;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace BMA.EHR.Infrastructure.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class update_table_retirement_add_approver : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.AddColumn<string>(
|
||||
name: "ApproveStep",
|
||||
table: "RetirementResigns",
|
||||
type: "longtext",
|
||||
nullable: true,
|
||||
comment: "step การอนุมัติ st1 = จทน.อนุมัตื,st2 = ผู้บังคับบัญชา อนุมัติ ")
|
||||
.Annotation("MySql:CharSet", "utf8mb4");
|
||||
|
||||
migrationBuilder.AddColumn<string>(
|
||||
name: "ApproveStep",
|
||||
table: "RetirementResignEmployees",
|
||||
type: "longtext",
|
||||
nullable: true,
|
||||
comment: "step การอนุมัติ st1 = จทน.อนุมัตื,st2 = ผู้บังคับบัญชา อนุมัติ ")
|
||||
.Annotation("MySql:CharSet", "utf8mb4");
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "RetirementResignApprovers",
|
||||
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"),
|
||||
RetirementResignId = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
|
||||
Seq = table.Column<int>(type: "int", nullable: false),
|
||||
Prefix = table.Column<string>(type: "longtext", nullable: false)
|
||||
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||
FirstName = table.Column<string>(type: "longtext", nullable: false)
|
||||
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||
LastName = table.Column<string>(type: "longtext", nullable: false)
|
||||
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||
PositionName = table.Column<string>(type: "longtext", nullable: false)
|
||||
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||
ProfileId = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
|
||||
KeycloakId = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
|
||||
ApproveStatus = table.Column<string>(type: "longtext", nullable: false)
|
||||
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||
Comment = table.Column<string>(type: "longtext", nullable: false)
|
||||
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||
ApproveType = table.Column<string>(type: "longtext", nullable: true)
|
||||
.Annotation("MySql:CharSet", "utf8mb4")
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_RetirementResignApprovers", x => x.Id);
|
||||
table.ForeignKey(
|
||||
name: "FK_RetirementResignApprovers_RetirementResigns_RetirementResign~",
|
||||
column: x => x.RetirementResignId,
|
||||
principalTable: "RetirementResigns",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
})
|
||||
.Annotation("MySql:CharSet", "utf8mb4");
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "RetirementResignCancelApprovers",
|
||||
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"),
|
||||
RetirementResignCancelId = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
|
||||
Seq = table.Column<int>(type: "int", nullable: false),
|
||||
Prefix = table.Column<string>(type: "longtext", nullable: false)
|
||||
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||
FirstName = table.Column<string>(type: "longtext", nullable: false)
|
||||
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||
LastName = table.Column<string>(type: "longtext", nullable: false)
|
||||
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||
PositionName = table.Column<string>(type: "longtext", nullable: false)
|
||||
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||
ProfileId = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
|
||||
KeycloakId = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
|
||||
ApproveStatus = table.Column<string>(type: "longtext", nullable: false)
|
||||
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||
Comment = table.Column<string>(type: "longtext", nullable: false)
|
||||
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||
ApproveType = table.Column<string>(type: "longtext", nullable: true)
|
||||
.Annotation("MySql:CharSet", "utf8mb4")
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_RetirementResignCancelApprovers", x => x.Id);
|
||||
table.ForeignKey(
|
||||
name: "FK_RetirementResignCancelApprovers_RetirementResignCancels_Reti~",
|
||||
column: x => x.RetirementResignCancelId,
|
||||
principalTable: "RetirementResignCancels",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
})
|
||||
.Annotation("MySql:CharSet", "utf8mb4");
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "RetirementResignEmployeeApprovers",
|
||||
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"),
|
||||
RetirementResignEmployeeId = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
|
||||
Seq = table.Column<int>(type: "int", nullable: false),
|
||||
Prefix = table.Column<string>(type: "longtext", nullable: false)
|
||||
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||
FirstName = table.Column<string>(type: "longtext", nullable: false)
|
||||
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||
LastName = table.Column<string>(type: "longtext", nullable: false)
|
||||
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||
PositionName = table.Column<string>(type: "longtext", nullable: false)
|
||||
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||
ProfileId = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
|
||||
KeycloakId = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
|
||||
ApproveStatus = table.Column<string>(type: "longtext", nullable: false)
|
||||
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||
Comment = table.Column<string>(type: "longtext", nullable: false)
|
||||
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||
ApproveType = table.Column<string>(type: "longtext", nullable: true)
|
||||
.Annotation("MySql:CharSet", "utf8mb4")
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_RetirementResignEmployeeApprovers", x => x.Id);
|
||||
table.ForeignKey(
|
||||
name: "FK_RetirementResignEmployeeApprovers_RetirementResignEmployees_~",
|
||||
column: x => x.RetirementResignEmployeeId,
|
||||
principalTable: "RetirementResignEmployees",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
})
|
||||
.Annotation("MySql:CharSet", "utf8mb4");
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "RetirementResignEmployeeCancelApprovers",
|
||||
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"),
|
||||
RetirementResignEmployeeCancelId = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
|
||||
Seq = table.Column<int>(type: "int", nullable: false),
|
||||
Prefix = table.Column<string>(type: "longtext", nullable: false)
|
||||
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||
FirstName = table.Column<string>(type: "longtext", nullable: false)
|
||||
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||
LastName = table.Column<string>(type: "longtext", nullable: false)
|
||||
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||
PositionName = table.Column<string>(type: "longtext", nullable: false)
|
||||
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||
ProfileId = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
|
||||
KeycloakId = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
|
||||
ApproveStatus = table.Column<string>(type: "longtext", nullable: false)
|
||||
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||
Comment = table.Column<string>(type: "longtext", nullable: false)
|
||||
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||
ApproveType = table.Column<string>(type: "longtext", nullable: true)
|
||||
.Annotation("MySql:CharSet", "utf8mb4")
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_RetirementResignEmployeeCancelApprovers", x => x.Id);
|
||||
table.ForeignKey(
|
||||
name: "FK_RetirementResignEmployeeCancelApprovers_RetirementResignEmpl~",
|
||||
column: x => x.RetirementResignEmployeeCancelId,
|
||||
principalTable: "RetirementResignEmployeeCancels",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
})
|
||||
.Annotation("MySql:CharSet", "utf8mb4");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_RetirementResignApprovers_RetirementResignId",
|
||||
table: "RetirementResignApprovers",
|
||||
column: "RetirementResignId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_RetirementResignCancelApprovers_RetirementResignCancelId",
|
||||
table: "RetirementResignCancelApprovers",
|
||||
column: "RetirementResignCancelId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_RetirementResignEmployeeApprovers_RetirementResignEmployeeId",
|
||||
table: "RetirementResignEmployeeApprovers",
|
||||
column: "RetirementResignEmployeeId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_RetirementResignEmployeeCancelApprovers_RetirementResignEmpl~",
|
||||
table: "RetirementResignEmployeeCancelApprovers",
|
||||
column: "RetirementResignEmployeeCancelId");
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropTable(
|
||||
name: "RetirementResignApprovers");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "RetirementResignCancelApprovers");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "RetirementResignEmployeeApprovers");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "RetirementResignEmployeeCancelApprovers");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "ApproveStep",
|
||||
table: "RetirementResigns");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "ApproveStep",
|
||||
table: "RetirementResignEmployees");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -16764,6 +16764,10 @@ namespace BMA.EHR.Infrastructure.Migrations
|
|||
.HasColumnType("longtext")
|
||||
.HasComment("เหตุผลอนุมัติ");
|
||||
|
||||
b.Property<string>("ApproveStep")
|
||||
.HasColumnType("longtext")
|
||||
.HasComment("step การอนุมัติ st1 = จทน.อนุมัตื,st2 = ผู้บังคับบัญชา อนุมัติ ");
|
||||
|
||||
b.Property<string>("CancelReason")
|
||||
.HasColumnType("longtext")
|
||||
.HasComment("เหตุผลยกเลิก");
|
||||
|
|
@ -17059,6 +17063,99 @@ namespace BMA.EHR.Infrastructure.Migrations
|
|||
b.ToTable("RetirementResigns");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BMA.EHR.Domain.Models.Retirement.RetirementResignApprover", b =>
|
||||
{
|
||||
b.Property<Guid>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("char(36)")
|
||||
.HasColumnOrder(0)
|
||||
.HasComment("PrimaryKey")
|
||||
.HasAnnotation("Relational:JsonPropertyName", "id");
|
||||
|
||||
b.Property<string>("ApproveStatus")
|
||||
.IsRequired()
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.Property<string>("ApproveType")
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.Property<string>("Comment")
|
||||
.IsRequired()
|
||||
.HasColumnType("longtext");
|
||||
|
||||
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>("FirstName")
|
||||
.IsRequired()
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.Property<Guid>("KeycloakId")
|
||||
.HasColumnType("char(36)");
|
||||
|
||||
b.Property<string>("LastName")
|
||||
.IsRequired()
|
||||
.HasColumnType("longtext");
|
||||
|
||||
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>("PositionName")
|
||||
.IsRequired()
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.Property<string>("Prefix")
|
||||
.IsRequired()
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.Property<Guid>("ProfileId")
|
||||
.HasColumnType("char(36)");
|
||||
|
||||
b.Property<Guid>("RetirementResignId")
|
||||
.HasColumnType("char(36)");
|
||||
|
||||
b.Property<int>("Seq")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("RetirementResignId");
|
||||
|
||||
b.ToTable("RetirementResignApprovers");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BMA.EHR.Domain.Models.Retirement.RetirementResignCancel", b =>
|
||||
{
|
||||
b.Property<Guid>("Id")
|
||||
|
|
@ -17352,6 +17449,99 @@ namespace BMA.EHR.Infrastructure.Migrations
|
|||
b.ToTable("RetirementResignCancels");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BMA.EHR.Domain.Models.Retirement.RetirementResignCancelApprover", b =>
|
||||
{
|
||||
b.Property<Guid>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("char(36)")
|
||||
.HasColumnOrder(0)
|
||||
.HasComment("PrimaryKey")
|
||||
.HasAnnotation("Relational:JsonPropertyName", "id");
|
||||
|
||||
b.Property<string>("ApproveStatus")
|
||||
.IsRequired()
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.Property<string>("ApproveType")
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.Property<string>("Comment")
|
||||
.IsRequired()
|
||||
.HasColumnType("longtext");
|
||||
|
||||
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>("FirstName")
|
||||
.IsRequired()
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.Property<Guid>("KeycloakId")
|
||||
.HasColumnType("char(36)");
|
||||
|
||||
b.Property<string>("LastName")
|
||||
.IsRequired()
|
||||
.HasColumnType("longtext");
|
||||
|
||||
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>("PositionName")
|
||||
.IsRequired()
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.Property<string>("Prefix")
|
||||
.IsRequired()
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.Property<Guid>("ProfileId")
|
||||
.HasColumnType("char(36)");
|
||||
|
||||
b.Property<Guid>("RetirementResignCancelId")
|
||||
.HasColumnType("char(36)");
|
||||
|
||||
b.Property<int>("Seq")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("RetirementResignCancelId");
|
||||
|
||||
b.ToTable("RetirementResignCancelApprovers");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BMA.EHR.Domain.Models.Retirement.RetirementResignDebtDoc", b =>
|
||||
{
|
||||
b.Property<Guid>("Id")
|
||||
|
|
@ -17497,6 +17687,10 @@ namespace BMA.EHR.Infrastructure.Migrations
|
|||
.HasColumnType("longtext")
|
||||
.HasComment("เหตุผลอนุมัติ");
|
||||
|
||||
b.Property<string>("ApproveStep")
|
||||
.HasColumnType("longtext")
|
||||
.HasComment("step การอนุมัติ st1 = จทน.อนุมัตื,st2 = ผู้บังคับบัญชา อนุมัติ ");
|
||||
|
||||
b.Property<string>("CancelReason")
|
||||
.HasColumnType("longtext")
|
||||
.HasComment("เหตุผลยกเลิก");
|
||||
|
|
@ -17788,6 +17982,99 @@ namespace BMA.EHR.Infrastructure.Migrations
|
|||
b.ToTable("RetirementResignEmployees");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BMA.EHR.Domain.Models.Retirement.RetirementResignEmployeeApprover", b =>
|
||||
{
|
||||
b.Property<Guid>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("char(36)")
|
||||
.HasColumnOrder(0)
|
||||
.HasComment("PrimaryKey")
|
||||
.HasAnnotation("Relational:JsonPropertyName", "id");
|
||||
|
||||
b.Property<string>("ApproveStatus")
|
||||
.IsRequired()
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.Property<string>("ApproveType")
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.Property<string>("Comment")
|
||||
.IsRequired()
|
||||
.HasColumnType("longtext");
|
||||
|
||||
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>("FirstName")
|
||||
.IsRequired()
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.Property<Guid>("KeycloakId")
|
||||
.HasColumnType("char(36)");
|
||||
|
||||
b.Property<string>("LastName")
|
||||
.IsRequired()
|
||||
.HasColumnType("longtext");
|
||||
|
||||
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>("PositionName")
|
||||
.IsRequired()
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.Property<string>("Prefix")
|
||||
.IsRequired()
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.Property<Guid>("ProfileId")
|
||||
.HasColumnType("char(36)");
|
||||
|
||||
b.Property<Guid>("RetirementResignEmployeeId")
|
||||
.HasColumnType("char(36)");
|
||||
|
||||
b.Property<int>("Seq")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("RetirementResignEmployeeId");
|
||||
|
||||
b.ToTable("RetirementResignEmployeeApprovers");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BMA.EHR.Domain.Models.Retirement.RetirementResignEmployeeCancel", b =>
|
||||
{
|
||||
b.Property<Guid>("Id")
|
||||
|
|
@ -18077,6 +18364,99 @@ namespace BMA.EHR.Infrastructure.Migrations
|
|||
b.ToTable("RetirementResignEmployeeCancels");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BMA.EHR.Domain.Models.Retirement.RetirementResignEmployeeCancelApprover", b =>
|
||||
{
|
||||
b.Property<Guid>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("char(36)")
|
||||
.HasColumnOrder(0)
|
||||
.HasComment("PrimaryKey")
|
||||
.HasAnnotation("Relational:JsonPropertyName", "id");
|
||||
|
||||
b.Property<string>("ApproveStatus")
|
||||
.IsRequired()
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.Property<string>("ApproveType")
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.Property<string>("Comment")
|
||||
.IsRequired()
|
||||
.HasColumnType("longtext");
|
||||
|
||||
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>("FirstName")
|
||||
.IsRequired()
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.Property<Guid>("KeycloakId")
|
||||
.HasColumnType("char(36)");
|
||||
|
||||
b.Property<string>("LastName")
|
||||
.IsRequired()
|
||||
.HasColumnType("longtext");
|
||||
|
||||
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>("PositionName")
|
||||
.IsRequired()
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.Property<string>("Prefix")
|
||||
.IsRequired()
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.Property<Guid>("ProfileId")
|
||||
.HasColumnType("char(36)");
|
||||
|
||||
b.Property<Guid>("RetirementResignEmployeeCancelId")
|
||||
.HasColumnType("char(36)");
|
||||
|
||||
b.Property<int>("Seq")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("RetirementResignEmployeeCancelId");
|
||||
|
||||
b.ToTable("RetirementResignEmployeeCancelApprovers");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BMA.EHR.Domain.Models.Retirement.RetirementResignEmployeeDebtDoc", b =>
|
||||
{
|
||||
b.Property<Guid>("Id")
|
||||
|
|
@ -19762,6 +20142,17 @@ namespace BMA.EHR.Infrastructure.Migrations
|
|||
b.Navigation("RetirementPeriod");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BMA.EHR.Domain.Models.Retirement.RetirementResignApprover", b =>
|
||||
{
|
||||
b.HasOne("BMA.EHR.Domain.Models.Retirement.RetirementResign", "RetirementResign")
|
||||
.WithMany("Approvers")
|
||||
.HasForeignKey("RetirementResignId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("RetirementResign");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BMA.EHR.Domain.Models.Retirement.RetirementResignCancel", b =>
|
||||
{
|
||||
b.HasOne("BMA.EHR.Domain.Models.Retirement.RetirementResign", "RetirementResign")
|
||||
|
|
@ -19773,6 +20164,17 @@ namespace BMA.EHR.Infrastructure.Migrations
|
|||
b.Navigation("RetirementResign");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BMA.EHR.Domain.Models.Retirement.RetirementResignCancelApprover", b =>
|
||||
{
|
||||
b.HasOne("BMA.EHR.Domain.Models.Retirement.RetirementResignCancel", "RetirementResignCancel")
|
||||
.WithMany("Approvers")
|
||||
.HasForeignKey("RetirementResignCancelId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("RetirementResignCancel");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BMA.EHR.Domain.Models.Retirement.RetirementResignDebtDoc", b =>
|
||||
{
|
||||
b.HasOne("BMA.EHR.Domain.Models.Documents.Document", "Document")
|
||||
|
|
@ -19811,6 +20213,17 @@ namespace BMA.EHR.Infrastructure.Migrations
|
|||
b.Navigation("RetirementResign");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BMA.EHR.Domain.Models.Retirement.RetirementResignEmployeeApprover", b =>
|
||||
{
|
||||
b.HasOne("BMA.EHR.Domain.Models.Retirement.RetirementResignEmployee", "RetirementResignEmployee")
|
||||
.WithMany("Approvers")
|
||||
.HasForeignKey("RetirementResignEmployeeId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("RetirementResignEmployee");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BMA.EHR.Domain.Models.Retirement.RetirementResignEmployeeCancel", b =>
|
||||
{
|
||||
b.HasOne("BMA.EHR.Domain.Models.Retirement.RetirementResignEmployee", "RetirementResignEmployee")
|
||||
|
|
@ -19822,6 +20235,17 @@ namespace BMA.EHR.Infrastructure.Migrations
|
|||
b.Navigation("RetirementResignEmployee");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BMA.EHR.Domain.Models.Retirement.RetirementResignEmployeeCancelApprover", b =>
|
||||
{
|
||||
b.HasOne("BMA.EHR.Domain.Models.Retirement.RetirementResignEmployeeCancel", "RetirementResignEmployeeCancel")
|
||||
.WithMany("Approvers")
|
||||
.HasForeignKey("RetirementResignEmployeeCancelId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("RetirementResignEmployeeCancel");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BMA.EHR.Domain.Models.Retirement.RetirementResignEmployeeDebtDoc", b =>
|
||||
{
|
||||
b.HasOne("BMA.EHR.Domain.Models.Documents.Document", "Document")
|
||||
|
|
@ -20133,6 +20557,8 @@ namespace BMA.EHR.Infrastructure.Migrations
|
|||
|
||||
modelBuilder.Entity("BMA.EHR.Domain.Models.Retirement.RetirementResign", b =>
|
||||
{
|
||||
b.Navigation("Approvers");
|
||||
|
||||
b.Navigation("RetirementResignCancels");
|
||||
|
||||
b.Navigation("RetirementResignDebtDocs");
|
||||
|
|
@ -20140,14 +20566,26 @@ namespace BMA.EHR.Infrastructure.Migrations
|
|||
b.Navigation("RetirementResignDocs");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BMA.EHR.Domain.Models.Retirement.RetirementResignCancel", b =>
|
||||
{
|
||||
b.Navigation("Approvers");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BMA.EHR.Domain.Models.Retirement.RetirementResignEmployee", b =>
|
||||
{
|
||||
b.Navigation("Approvers");
|
||||
|
||||
b.Navigation("RetirementResignEmployeeCancels");
|
||||
|
||||
b.Navigation("RetirementResignEmployeeDebtDocs");
|
||||
|
||||
b.Navigation("RetirementResignEmployeeDocs");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BMA.EHR.Domain.Models.Retirement.RetirementResignEmployeeCancel", b =>
|
||||
{
|
||||
b.Navigation("Approvers");
|
||||
});
|
||||
#pragma warning restore 612, 618
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -334,6 +334,10 @@ namespace BMA.EHR.Infrastructure.Persistence
|
|||
public DbSet<RetirementDeceased> RetirementDeceaseds { get; set; }
|
||||
public DbSet<RetirementDeceasedNoti> RetirementDeceasedNotis { get; set; }
|
||||
public DbSet<RetirementResign> RetirementResigns { get; set; }
|
||||
public DbSet<RetirementResignApprover> RetirementResignApprovers { get; set; }
|
||||
public DbSet<RetirementResignCancelApprover> RetirementResignCancelApprovers { get; set; }
|
||||
public DbSet<RetirementResignEmployeeApprover> RetirementResignEmployeeApprovers { get; set; }
|
||||
public DbSet<RetirementResignEmployeeCancelApprover> RetirementResignEmployeeCancelApprovers { get; set; }
|
||||
public DbSet<RetirementResignCancel> RetirementResignCancels { get; set; }
|
||||
public DbSet<RetirementResignDoc> RetirementResignDocs { get; set; }
|
||||
public DbSet<RetirementResignDebtDoc> RetirementResignDebtDocs { get; set; }
|
||||
|
|
|
|||
|
|
@ -264,6 +264,7 @@ namespace BMA.EHR.Retirement.Service.Controllers
|
|||
p.CancelReason,
|
||||
p.IsActive,
|
||||
p.CreatedAt,
|
||||
p.ApproveStep,
|
||||
})
|
||||
.ToListAsync();
|
||||
|
||||
|
|
@ -422,6 +423,10 @@ namespace BMA.EHR.Retirement.Service.Controllers
|
|||
p.IsNoBurden,
|
||||
p.IsDiscipline,
|
||||
p.CancelReason,
|
||||
p.ApproveStep,
|
||||
Approvers = p.Approvers.Where(x => x.ApproveType.ToUpper() == "APPROVER"),
|
||||
Commanders = p.Approvers.Where(x => x.ApproveType.ToUpper() == "COMMANDER"),
|
||||
KeycloakUserId = p.CreatedUserId,
|
||||
RetirementResignCancels = p.RetirementResignCancels.FirstOrDefault(),
|
||||
RetirementResignDocs = p.RetirementResignDocs.Where(d => d.Document != null).Select(d => new { d.Document.Id, d.Document.FileName }),
|
||||
})
|
||||
|
|
@ -501,6 +506,10 @@ namespace BMA.EHR.Retirement.Service.Controllers
|
|||
data.IsNoBurden,
|
||||
data.IsDiscipline,
|
||||
data.CancelReason,
|
||||
data.KeycloakUserId,
|
||||
data.Approvers,
|
||||
data.Commanders,
|
||||
data.ApproveStep,
|
||||
idCancel = data.RetirementResignCancels?.Id ?? null,
|
||||
statusCancel = data.RetirementResignCancels?.Status ?? null,
|
||||
statusMain = data.Status == "CANCEL" ? "DONECANCEL" : data.Status,
|
||||
|
|
@ -587,6 +596,9 @@ namespace BMA.EHR.Retirement.Service.Controllers
|
|||
p.IsNoBurden,
|
||||
p.IsDiscipline,
|
||||
p.CancelReason,
|
||||
Approvers = p.Approvers.Where(x => x.ApproveType.ToUpper() == "APPROVER"),
|
||||
Commanders = p.Approvers.Where(x => x.ApproveType.ToUpper() == "COMMANDER"),
|
||||
KeycloakUserId = p.CreatedUserId,
|
||||
idMain = p.RetirementResign.Id,
|
||||
statusMain = p.RetirementResign.Status,
|
||||
RetirementResignDocs = p.RetirementResign.RetirementResignDocs.Where(d => d.Document != null).Select(d => new { d.Document.Id, d.Document.FileName }),
|
||||
|
|
@ -669,6 +681,9 @@ namespace BMA.EHR.Retirement.Service.Controllers
|
|||
data.CancelReason,
|
||||
data.idMain,
|
||||
data.statusMain,
|
||||
data.KeycloakUserId,
|
||||
data.Approvers,
|
||||
data.Commanders,
|
||||
statusCancel = data.Status,
|
||||
Docs = retirementResignDocs,
|
||||
};
|
||||
|
|
@ -2537,6 +2552,228 @@ namespace BMA.EHR.Retirement.Service.Controllers
|
|||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// เพิ่มรายชิื่อผู้อนุมัติ หรือ ผู้บังคับบัญชา
|
||||
/// </summary>
|
||||
/// <returns>
|
||||
/// </returns>
|
||||
/// <response code="200">เมื่อทำรายการสำเร็จ</response>
|
||||
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
||||
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
||||
[HttpPost("officer/add-resign/{type}/{id:guid}")]
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
||||
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||
public async Task<ActionResult<ResponseObject>> AddApprover(string type, Guid id, [FromBody] List<RetirementRequestApproverDto> req)
|
||||
{
|
||||
try
|
||||
{
|
||||
var retirement = await _context.RetirementResigns
|
||||
.Where(x => x.Id == id)
|
||||
.FirstOrDefaultAsync();
|
||||
if (retirement == null)
|
||||
{
|
||||
return Error(GlobalMessages.DataNotFound, StatusCodes.Status404NotFound);
|
||||
}
|
||||
|
||||
var data = await _context.RetirementResignApprovers
|
||||
.Where(x => x.RetirementResign.Id == id && x.ApproveType.ToUpper() == type.ToUpper())
|
||||
.ToListAsync();
|
||||
_context.RemoveRange(data);
|
||||
|
||||
await _context.SaveChangesAsync();
|
||||
|
||||
var addList = new List<RetirementResignApprover>();
|
||||
|
||||
foreach (var r in req)
|
||||
{
|
||||
addList.Add(new RetirementResignApprover
|
||||
{
|
||||
Seq = r.Seq,
|
||||
RetirementResign = retirement,
|
||||
Prefix = r.Prefix,
|
||||
FirstName = r.FirstName,
|
||||
LastName = r.LastName,
|
||||
PositionName = r.PositionName,
|
||||
ProfileId = r.ProfileId,
|
||||
KeycloakId = r.KeycloakId,
|
||||
ApproveStatus = "PENDING",
|
||||
ApproveType = type.Trim().ToUpper()
|
||||
});
|
||||
}
|
||||
await _context.AddRangeAsync(addList);
|
||||
await _context.SaveChangesAsync();
|
||||
|
||||
return Success();
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return Error(ex);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// LV2_013 - เจ้าหน้าที่อนุมัติการลา (ADMIN)
|
||||
/// </summary>
|
||||
/// <returns>
|
||||
/// </returns>
|
||||
/// <response code="200">เมื่อทำรายการสำเร็จ</response>
|
||||
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
||||
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
||||
[HttpGet("admin/approve/officer/{id:guid}")]
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
||||
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||
public async Task<ActionResult<ResponseObject>> OfficerApproveRetirementResignAsync(Guid id)
|
||||
{
|
||||
// var getPermission = await _permission.GetPermissionAPIAsync("UPDATE", "SYS_LEAVE_LIST");
|
||||
// var jsonData = JsonConvert.DeserializeObject<JObject>(getPermission);
|
||||
// if (jsonData["status"]?.ToString() != "200")
|
||||
// {
|
||||
// return Error(jsonData["message"]?.ToString(), StatusCodes.Status403Forbidden);
|
||||
// }
|
||||
await _repository.OfficerApproveRetirementResign(id);
|
||||
|
||||
return Success();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// LV2_015 - ผู้บังคับบัญชาอนุมัติการลา(ADMIN)
|
||||
/// </summary>
|
||||
/// <returns>
|
||||
/// </returns>
|
||||
/// <response code="200">เมื่อทำรายการสำเร็จ</response>
|
||||
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
||||
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
||||
[HttpPut("admin/approve/comander/{id:guid}")]
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
||||
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||
public async Task<ActionResult<ResponseObject>> CommanderApproveRetirementResignAsync(Guid id,
|
||||
[FromBody] RetirementRequestApproveDto req)
|
||||
{
|
||||
try
|
||||
{
|
||||
// var getPermission = await _permission.GetPermissionAPIAsync("UPDATE", "SYS_LEAVE_LIST");
|
||||
// var jsonData = JsonConvert.DeserializeObject<JObject>(getPermission);
|
||||
// if (jsonData["status"]?.ToString() != "200")
|
||||
// {
|
||||
// return Error(jsonData["message"]?.ToString(), StatusCodes.Status403Forbidden);
|
||||
// }
|
||||
await _repository.CommanderApproveRetirementResign(id, req.Reason ?? "");
|
||||
|
||||
return Success();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return Error(ex);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// ผู้บังคับบัญชาไม่อนุมัติการลา(ADMIN)
|
||||
/// </summary>
|
||||
/// <returns>
|
||||
/// </returns>
|
||||
/// <response code="200">เมื่อทำรายการสำเร็จ</response>
|
||||
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
||||
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
||||
[HttpPut("admin/reject/comander/{id:guid}")]
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
||||
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||
public async Task<ActionResult<ResponseObject>> CommanderRejectRetirementResignAsync(Guid id,
|
||||
[FromBody] RetirementRequestApproveDto req)
|
||||
{
|
||||
try
|
||||
{
|
||||
// var getPermission = await _permission.GetPermissionAPIAsync("UPDATE", "SYS_LEAVE_LIST");
|
||||
// var jsonData = JsonConvert.DeserializeObject<JObject>(getPermission);
|
||||
// if (jsonData["status"]?.ToString() != "200")
|
||||
// {
|
||||
// return Error(jsonData["message"]?.ToString(), StatusCodes.Status403Forbidden);
|
||||
// }
|
||||
await _repository.CommanderRejectRetirementResign(id, req.Reason ?? "");
|
||||
|
||||
return Success();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return Error(ex);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// LV2_016 - ผู้มีอำนาจอนุมัติการลา (ADMIN)
|
||||
/// </summary>
|
||||
/// <returns>
|
||||
/// </returns>
|
||||
/// <response code="200">เมื่อทำรายการสำเร็จ</response>
|
||||
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
||||
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
||||
[HttpPut("admin/approve/{id:guid}")]
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
||||
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||
public async Task<ActionResult<ResponseObject>> ApproveRetirementResignAsync(Guid id,
|
||||
[FromBody] RetirementRequestApproveDto req)
|
||||
{
|
||||
try
|
||||
{
|
||||
// var getPermission = await _permission.GetPermissionAPIAsync("UPDATE", "SYS_LEAVE_LIST");
|
||||
// var jsonData = JsonConvert.DeserializeObject<JObject>(getPermission);
|
||||
// if (jsonData["status"]?.ToString() != "200")
|
||||
// {
|
||||
// return Error(jsonData["message"]?.ToString(), StatusCodes.Status403Forbidden);
|
||||
// }
|
||||
await _repository.ApproveRetirementResign(id, req.Reason ?? "");
|
||||
|
||||
return Success();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return Error(ex);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// LV2_017 - ผู้มีอำนาจไม่อนุมัติการลา (ADMIN)
|
||||
/// </summary>
|
||||
/// <returns>
|
||||
/// </returns>
|
||||
/// <response code="200">เมื่อทำรายการสำเร็จ</response>
|
||||
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
||||
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
||||
[HttpPut("admin/reject/{id:guid}")]
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
||||
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||
public async Task<ActionResult<ResponseObject>> RejectRetirementResignAsync(Guid id,
|
||||
[FromBody] RetirementRequestApproveDto req)
|
||||
{
|
||||
try
|
||||
{
|
||||
// var getPermission = await _permission.GetPermissionAPIAsync("UPDATE", "SYS_LEAVE_LIST");
|
||||
// var jsonData = JsonConvert.DeserializeObject<JObject>(getPermission);
|
||||
// if (jsonData["status"]?.ToString() != "200")
|
||||
// {
|
||||
// return Error(jsonData["message"]?.ToString(), StatusCodes.Status403Forbidden);
|
||||
// }
|
||||
await _repository.RejectRetirementResign(id, req.Reason ?? "");
|
||||
|
||||
return Success();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return Error(ex);
|
||||
}
|
||||
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ namespace BMA.EHR.Retirement.Service.Controllers
|
|||
[SwaggerTag("ระบบลาออกลูกจ้าง")]
|
||||
public class RetirementResignEmployeeEmployeeController : BaseController
|
||||
{
|
||||
private readonly RetirementRepository _repository;
|
||||
private readonly RetirementEmployeeRepository _repository;
|
||||
private readonly NotificationRepository _repositoryNoti;
|
||||
private readonly ApplicationDBContext _context;
|
||||
private readonly MinIOService _documentService;
|
||||
|
|
@ -33,7 +33,7 @@ namespace BMA.EHR.Retirement.Service.Controllers
|
|||
private readonly IConfiguration _configuration;
|
||||
private readonly PermissionRepository _permission;
|
||||
|
||||
public RetirementResignEmployeeEmployeeController(RetirementRepository repository,
|
||||
public RetirementResignEmployeeEmployeeController(RetirementEmployeeRepository repository,
|
||||
NotificationRepository repositoryNoti,
|
||||
ApplicationDBContext context,
|
||||
MinIOService documentService,
|
||||
|
|
@ -203,6 +203,7 @@ namespace BMA.EHR.Retirement.Service.Controllers
|
|||
p.CancelReason,
|
||||
p.IsActive,
|
||||
p.CreatedAt,
|
||||
p.ApproveStep,
|
||||
})
|
||||
.ToListAsync();
|
||||
|
||||
|
|
@ -361,6 +362,7 @@ namespace BMA.EHR.Retirement.Service.Controllers
|
|||
p.IsNoBurden,
|
||||
p.IsDiscipline,
|
||||
p.CancelReason,
|
||||
p.ApproveStep,
|
||||
RetirementResignEmployeeCancels = p.RetirementResignEmployeeCancels.FirstOrDefault(),
|
||||
RetirementResignEmployeeDocs = p.RetirementResignEmployeeDocs.Where(d => d.Document != null).Select(d => new { d.Document.Id, d.Document.FileName }),
|
||||
})
|
||||
|
|
@ -440,6 +442,7 @@ namespace BMA.EHR.Retirement.Service.Controllers
|
|||
data.IsNoBurden,
|
||||
data.IsDiscipline,
|
||||
data.CancelReason,
|
||||
data.ApproveStep,
|
||||
idCancel = data.RetirementResignEmployeeCancels?.Id ?? Guid.Empty,
|
||||
statusCancel = data.RetirementResignEmployeeCancels?.Status ?? null,
|
||||
statusMain = data.Status,
|
||||
|
|
@ -1933,5 +1936,227 @@ namespace BMA.EHR.Retirement.Service.Controllers
|
|||
}
|
||||
return Success();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// เพิ่มรายชิื่อผู้อนุมัติ หรือ ผู้บังคับบัญชา
|
||||
/// </summary>
|
||||
/// <returns>
|
||||
/// </returns>
|
||||
/// <response code="200">เมื่อทำรายการสำเร็จ</response>
|
||||
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
||||
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
||||
[HttpPost("officer/add-resign/{type}/{id:guid}")]
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
||||
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||
public async Task<ActionResult<ResponseObject>> AddApprover(string type, Guid id, [FromBody] List<RetirementRequestApproverDto> req)
|
||||
{
|
||||
try
|
||||
{
|
||||
var retirement = await _context.RetirementResignEmployees
|
||||
.Where(x => x.Id == id)
|
||||
.FirstOrDefaultAsync();
|
||||
if (retirement == null)
|
||||
{
|
||||
return Error(GlobalMessages.DataNotFound, StatusCodes.Status404NotFound);
|
||||
}
|
||||
|
||||
var data = await _context.RetirementResignEmployeeApprovers
|
||||
.Where(x => x.RetirementResignEmployee.Id == id && x.ApproveType.ToUpper() == type.ToUpper())
|
||||
.ToListAsync();
|
||||
_context.RemoveRange(data);
|
||||
|
||||
await _context.SaveChangesAsync();
|
||||
|
||||
var addList = new List<RetirementResignEmployeeApprover>();
|
||||
|
||||
foreach (var r in req)
|
||||
{
|
||||
addList.Add(new RetirementResignEmployeeApprover
|
||||
{
|
||||
Seq = r.Seq,
|
||||
RetirementResignEmployee = retirement,
|
||||
Prefix = r.Prefix,
|
||||
FirstName = r.FirstName,
|
||||
LastName = r.LastName,
|
||||
PositionName = r.PositionName,
|
||||
ProfileId = r.ProfileId,
|
||||
KeycloakId = r.KeycloakId,
|
||||
ApproveStatus = "PENDING",
|
||||
ApproveType = type.Trim().ToUpper()
|
||||
});
|
||||
}
|
||||
await _context.AddRangeAsync(addList);
|
||||
await _context.SaveChangesAsync();
|
||||
|
||||
return Success();
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return Error(ex);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// LV2_013 - เจ้าหน้าที่อนุมัติการลา (ADMIN)
|
||||
/// </summary>
|
||||
/// <returns>
|
||||
/// </returns>
|
||||
/// <response code="200">เมื่อทำรายการสำเร็จ</response>
|
||||
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
||||
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
||||
[HttpGet("admin/approve/officer/{id:guid}")]
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
||||
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||
public async Task<ActionResult<ResponseObject>> OfficerApproveRetirementResignEmployeeAsync(Guid id)
|
||||
{
|
||||
// var getPermission = await _permission.GetPermissionAPIAsync("UPDATE", "SYS_LEAVE_LIST");
|
||||
// var jsonData = JsonConvert.DeserializeObject<JObject>(getPermission);
|
||||
// if (jsonData["status"]?.ToString() != "200")
|
||||
// {
|
||||
// return Error(jsonData["message"]?.ToString(), StatusCodes.Status403Forbidden);
|
||||
// }
|
||||
await _repository.OfficerApproveRetirementResignEmployee(id);
|
||||
|
||||
return Success();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// LV2_015 - ผู้บังคับบัญชาอนุมัติการลา(ADMIN)
|
||||
/// </summary>
|
||||
/// <returns>
|
||||
/// </returns>
|
||||
/// <response code="200">เมื่อทำรายการสำเร็จ</response>
|
||||
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
||||
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
||||
[HttpPut("admin/approve/comander/{id:guid}")]
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
||||
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||
public async Task<ActionResult<ResponseObject>> CommanderApproveRetirementResignEmployeeAsync(Guid id,
|
||||
[FromBody] RetirementRequestApproveDto req)
|
||||
{
|
||||
try
|
||||
{
|
||||
// var getPermission = await _permission.GetPermissionAPIAsync("UPDATE", "SYS_LEAVE_LIST");
|
||||
// var jsonData = JsonConvert.DeserializeObject<JObject>(getPermission);
|
||||
// if (jsonData["status"]?.ToString() != "200")
|
||||
// {
|
||||
// return Error(jsonData["message"]?.ToString(), StatusCodes.Status403Forbidden);
|
||||
// }
|
||||
await _repository.CommanderApproveRetirementResignEmployee(id, req.Reason ?? "");
|
||||
|
||||
return Success();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return Error(ex);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// ผู้บังคับบัญชาไม่อนุมัติการลา(ADMIN)
|
||||
/// </summary>
|
||||
/// <returns>
|
||||
/// </returns>
|
||||
/// <response code="200">เมื่อทำรายการสำเร็จ</response>
|
||||
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
||||
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
||||
[HttpPut("admin/reject/comander/{id:guid}")]
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
||||
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||
public async Task<ActionResult<ResponseObject>> CommanderRejectRetirementResignEmployeeAsync(Guid id,
|
||||
[FromBody] RetirementRequestApproveDto req)
|
||||
{
|
||||
try
|
||||
{
|
||||
// var getPermission = await _permission.GetPermissionAPIAsync("UPDATE", "SYS_LEAVE_LIST");
|
||||
// var jsonData = JsonConvert.DeserializeObject<JObject>(getPermission);
|
||||
// if (jsonData["status"]?.ToString() != "200")
|
||||
// {
|
||||
// return Error(jsonData["message"]?.ToString(), StatusCodes.Status403Forbidden);
|
||||
// }
|
||||
await _repository.CommanderRejectRetirementResignEmployee(id, req.Reason ?? "");
|
||||
|
||||
return Success();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return Error(ex);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// LV2_016 - ผู้มีอำนาจอนุมัติการลา (ADMIN)
|
||||
/// </summary>
|
||||
/// <returns>
|
||||
/// </returns>
|
||||
/// <response code="200">เมื่อทำรายการสำเร็จ</response>
|
||||
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
||||
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
||||
[HttpPut("admin/approve/{id:guid}")]
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
||||
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||
public async Task<ActionResult<ResponseObject>> ApproveRetirementResignEmployeeAsync(Guid id,
|
||||
[FromBody] RetirementRequestApproveDto req)
|
||||
{
|
||||
try
|
||||
{
|
||||
// var getPermission = await _permission.GetPermissionAPIAsync("UPDATE", "SYS_LEAVE_LIST");
|
||||
// var jsonData = JsonConvert.DeserializeObject<JObject>(getPermission);
|
||||
// if (jsonData["status"]?.ToString() != "200")
|
||||
// {
|
||||
// return Error(jsonData["message"]?.ToString(), StatusCodes.Status403Forbidden);
|
||||
// }
|
||||
await _repository.ApproveRetirementResignEmployee(id, req.Reason ?? "");
|
||||
|
||||
return Success();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return Error(ex);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// LV2_017 - ผู้มีอำนาจไม่อนุมัติการลา (ADMIN)
|
||||
/// </summary>
|
||||
/// <returns>
|
||||
/// </returns>
|
||||
/// <response code="200">เมื่อทำรายการสำเร็จ</response>
|
||||
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
||||
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
||||
[HttpPut("admin/reject/{id:guid}")]
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
||||
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||
public async Task<ActionResult<ResponseObject>> RejectRetirementResignEmployeeAsync(Guid id,
|
||||
[FromBody] RetirementRequestApproveDto req)
|
||||
{
|
||||
try
|
||||
{
|
||||
// var getPermission = await _permission.GetPermissionAPIAsync("UPDATE", "SYS_LEAVE_LIST");
|
||||
// var jsonData = JsonConvert.DeserializeObject<JObject>(getPermission);
|
||||
// if (jsonData["status"]?.ToString() != "200")
|
||||
// {
|
||||
// return Error(jsonData["message"]?.ToString(), StatusCodes.Status403Forbidden);
|
||||
// }
|
||||
await _repository.RejectRetirementResignEmployee(id, req.Reason ?? "");
|
||||
|
||||
return Success();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return Error(ex);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,8 @@
|
|||
|
||||
namespace BMA.EHR.Retirement.Service.Requests
|
||||
{
|
||||
public class RetirementRequestApproveDto
|
||||
{
|
||||
public string? Reason { get; set; }
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,28 @@
|
|||
using Newtonsoft.Json;
|
||||
|
||||
namespace BMA.EHR.Retirement.Service.Requests
|
||||
{
|
||||
public class RetirementRequestApproverDto
|
||||
{
|
||||
[JsonProperty("seq")]
|
||||
public int Seq { get; set; } = 0;
|
||||
|
||||
[JsonProperty("prefix")]
|
||||
public string Prefix { get; set; } = string.Empty;
|
||||
|
||||
[JsonProperty("firstName")]
|
||||
public string FirstName { get; set; } = string.Empty;
|
||||
|
||||
[JsonProperty("lastName")]
|
||||
public string LastName { get; set; } = string.Empty;
|
||||
|
||||
[JsonProperty("positionName")]
|
||||
public string PositionName { get; set; } = string.Empty;
|
||||
|
||||
[JsonProperty("profileId")]
|
||||
public Guid ProfileId { get; set; } = Guid.Empty;
|
||||
|
||||
[JsonProperty("keycloakId")]
|
||||
public Guid KeycloakId { get; set; } = Guid.Empty;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,42 +1,43 @@
|
|||
{
|
||||
"Serilog": {
|
||||
"MinimumLevel": {
|
||||
"Default": "Information",
|
||||
"Override": {
|
||||
"Microsoft": "Information",
|
||||
"System": "Warning"
|
||||
}
|
||||
}
|
||||
},
|
||||
"ElasticConfiguration": {
|
||||
"Uri": "http://192.168.1.40:9200",
|
||||
"IndexFormat": "bma-ehr-log-index",
|
||||
"SystemName": "retirement"
|
||||
},
|
||||
"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.80;user=root;password=adminVM123;port=3306;database=hrms;Convert Zero Datetime=True;Allow User Variables=true;Pooling=True;",
|
||||
"DisciplineConnection": "server=192.168.1.80;user=root;password=adminVM123;port=3306;database=hrms_discipline;Convert Zero Datetime=True;Allow User Variables=true;Pooling=True;"
|
||||
},
|
||||
"Jwt": {
|
||||
"Key": "HP-FnQMUj9msHMSD3T9HtdEnphAKoCJLEl85CIqROFI",
|
||||
"Issuer": "https://id.frappet.synology.me/realms/hrms"
|
||||
},
|
||||
"EPPlus": {
|
||||
"ExcelPackage": {
|
||||
"LicenseContext": "NonCommercial"
|
||||
}
|
||||
},
|
||||
"MinIO": {
|
||||
"Endpoint": "https://s3.frappet.com/",
|
||||
"AccessKey": "frappet",
|
||||
"SecretKey": "P@ssw0rd",
|
||||
"BucketName": "bma-recruit"
|
||||
},
|
||||
"Protocol": "HTTPS",
|
||||
"API": "https://bma-ehr.frappet.synology.me/api/v1",
|
||||
"APIV2": "https://bma-ehr.frappet.synology.me/api/v2",
|
||||
"API_KEY": "fKRL16yyEgbyTEJdsMw2h64tGSCmkW685PRtM3CygzX1JOSdptT9UJtpgWwKM8FybRTJups3GTFwj27ZRvlPdIkv3XgCoVJaD5LmR06ozuEPvCCRSdp2WFthg08V5xHc56fTPfZLpr1VmXrhd6dvYhHIqKkQUJR02Rlkss11cLRWEQOssEFVA4xdu2J5DIRO1EM5m7wRRvEwcDB4mYRXD9HH52SMq6iYqUWEWsMwLdbk7QW9yYESUEuzMW5gWrb6vIeWZxJV5bTz1PcWUyR7eO9Fyw1F5DiQYc9JgzTC1mW7cv31fEtTtrfbJYKIb5EbWilqIEUKC6A0UKBDDek35ML0006cqRVm0pvdOH6jeq7VQyYrhdXe59dBEyhYGUIfozoVBvW7Up4QBuOMjyPjSqJPlMBKwaseptfrblxQV1AOOivSBpf1ZcQyOZ8JktRtKUDSuXsmG0lsXwFlI3JCeSHdpVdgZWFYcJPegqfrB6KotR02t9AVkpLs1ZWrixwz"
|
||||
}
|
||||
"Serilog": {
|
||||
"MinimumLevel": {
|
||||
"Default": "Information",
|
||||
"Override": {
|
||||
"Microsoft": "Information",
|
||||
"System": "Warning"
|
||||
}
|
||||
}
|
||||
},
|
||||
"ElasticConfiguration": {
|
||||
"Uri": "http://192.168.1.40:9200",
|
||||
"IndexFormat": "bma-ehr-log-index",
|
||||
"SystemName": "retirement"
|
||||
},
|
||||
"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.80;user=root;password=adminVM123;port=3306;database=hrms;Convert Zero Datetime=True;Allow User Variables=true;Pooling=True;",
|
||||
"DisciplineConnection": "server=192.168.1.80;user=root;password=adminVM123;port=3306;database=hrms_discipline;Convert Zero Datetime=True;Allow User Variables=true;Pooling=True;"
|
||||
},
|
||||
"Jwt": {
|
||||
"Key": "HP-FnQMUj9msHMSD3T9HtdEnphAKoCJLEl85CIqROFI",
|
||||
"Issuer": "https://id.frappet.synology.me/realms/hrms"
|
||||
},
|
||||
"EPPlus": {
|
||||
"ExcelPackage": {
|
||||
"LicenseContext": "NonCommercial"
|
||||
}
|
||||
},
|
||||
"MinIO": {
|
||||
"Endpoint": "https://s3.frappet.com/",
|
||||
"AccessKey": "frappet",
|
||||
"SecretKey": "P@ssw0rd",
|
||||
"BucketName": "bma-recruit"
|
||||
},
|
||||
"Protocol": "HTTPS",
|
||||
"MAIN_PAGE": "https://bma-ehr.frappet.synology.me",
|
||||
"API": "https://bma-ehr.frappet.synology.me/api/v1",
|
||||
"APIV2": "https://bma-ehr.frappet.synology.me/api/v2",
|
||||
"API_KEY": "fKRL16yyEgbyTEJdsMw2h64tGSCmkW685PRtM3CygzX1JOSdptT9UJtpgWwKM8FybRTJups3GTFwj27ZRvlPdIkv3XgCoVJaD5LmR06ozuEPvCCRSdp2WFthg08V5xHc56fTPfZLpr1VmXrhd6dvYhHIqKkQUJR02Rlkss11cLRWEQOssEFVA4xdu2J5DIRO1EM5m7wRRvEwcDB4mYRXD9HH52SMq6iYqUWEWsMwLdbk7QW9yYESUEuzMW5gWrb6vIeWZxJV5bTz1PcWUyR7eO9Fyw1F5DiQYc9JgzTC1mW7cv31fEtTtrfbJYKIb5EbWilqIEUKC6A0UKBDDek35ML0006cqRVm0pvdOH6jeq7VQyYrhdXe59dBEyhYGUIfozoVBvW7Up4QBuOMjyPjSqJPlMBKwaseptfrblxQV1AOOivSBpf1ZcQyOZ8JktRtKUDSuXsmG0lsXwFlI3JCeSHdpVdgZWFYcJPegqfrB6KotR02t9AVkpLs1ZWrixwz"
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue