Merge branch 'develop' into working
This commit is contained in:
commit
a1f866bcbe
3 changed files with 59 additions and 26 deletions
|
|
@ -12,7 +12,9 @@ using BMA.EHR.Placement.Service.Requests;
|
||||||
using Microsoft.AspNetCore.Authorization;
|
using Microsoft.AspNetCore.Authorization;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using Newtonsoft.Json;
|
||||||
using Swashbuckle.AspNetCore.Annotations;
|
using Swashbuckle.AspNetCore.Annotations;
|
||||||
|
using System.Net.Http.Headers;
|
||||||
using System.Security.Claims;
|
using System.Security.Claims;
|
||||||
using System.Security.Cryptography;
|
using System.Security.Cryptography;
|
||||||
|
|
||||||
|
|
@ -31,18 +33,21 @@ namespace BMA.EHR.Placement.Service.Controllers
|
||||||
private readonly MinIOService _documentService;
|
private readonly MinIOService _documentService;
|
||||||
private readonly IHttpContextAccessor _httpContextAccessor;
|
private readonly IHttpContextAccessor _httpContextAccessor;
|
||||||
private readonly NotificationRepository _repositoryNoti;
|
private readonly NotificationRepository _repositoryNoti;
|
||||||
|
private readonly IConfiguration _configuration;
|
||||||
|
|
||||||
public NotifyController(PlacementRepository repository,
|
public NotifyController(PlacementRepository repository,
|
||||||
ApplicationDBContext context,
|
ApplicationDBContext context,
|
||||||
MinIOService documentService,
|
MinIOService documentService,
|
||||||
NotificationRepository repositoryNoti,
|
NotificationRepository repositoryNoti,
|
||||||
IHttpContextAccessor httpContextAccessor)
|
IHttpContextAccessor httpContextAccessor,
|
||||||
|
IConfiguration configuration)
|
||||||
{
|
{
|
||||||
_repository = repository;
|
_repository = repository;
|
||||||
_repositoryNoti = repositoryNoti;
|
_repositoryNoti = repositoryNoti;
|
||||||
_context = context;
|
_context = context;
|
||||||
_documentService = documentService;
|
_documentService = documentService;
|
||||||
_httpContextAccessor = httpContextAccessor;
|
_httpContextAccessor = httpContextAccessor;
|
||||||
|
_configuration = configuration;
|
||||||
}
|
}
|
||||||
|
|
||||||
#region " Properties "
|
#region " Properties "
|
||||||
|
|
@ -50,6 +55,7 @@ namespace BMA.EHR.Placement.Service.Controllers
|
||||||
private string? UserId => _httpContextAccessor?.HttpContext?.User?.FindFirst(ClaimTypes.NameIdentifier)?.Value;
|
private string? UserId => _httpContextAccessor?.HttpContext?.User?.FindFirst(ClaimTypes.NameIdentifier)?.Value;
|
||||||
|
|
||||||
private string? FullName => _httpContextAccessor?.HttpContext?.User?.FindFirst("name")?.Value;
|
private string? FullName => _httpContextAccessor?.HttpContext?.User?.FindFirst("name")?.Value;
|
||||||
|
private string? token => _httpContextAccessor?.HttpContext?.Request.Headers["Authorization"];
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
|
@ -79,14 +85,27 @@ namespace BMA.EHR.Placement.Service.Controllers
|
||||||
// if (profile == null)
|
// if (profile == null)
|
||||||
// return Error(GlobalMessages.DataNotFound);
|
// return Error(GlobalMessages.DataNotFound);
|
||||||
|
|
||||||
await _repositoryNoti.PushNotificationAsync(
|
var apiUrl = $"{_configuration["API"]}org/profile/keycloak/position";
|
||||||
req.ReceiverUserId,
|
using (var client = new HttpClient())
|
||||||
req.Subject,
|
{
|
||||||
req.Body,
|
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
|
||||||
req.Payload,
|
var _req = new HttpRequestMessage(HttpMethod.Get, apiUrl);
|
||||||
req.IsSendInbox,
|
var _res = await client.SendAsync(_req);
|
||||||
req.IsSendMail
|
var _result = await _res.Content.ReadAsStringAsync();
|
||||||
);
|
var org = JsonConvert.DeserializeObject<OrgRequest>(_result);
|
||||||
|
if (org != null && org.result != null)
|
||||||
|
{
|
||||||
|
await _repositoryNoti.PushNotificationAsync(
|
||||||
|
Guid.Parse(org.result.profileId),
|
||||||
|
req.Subject,
|
||||||
|
req.Body,
|
||||||
|
req.Payload,
|
||||||
|
req.IsSendInbox,
|
||||||
|
req.IsSendMail
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return Success();
|
||||||
|
}
|
||||||
|
|
||||||
return Success();
|
return Success();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -669,7 +669,7 @@ namespace BMA.EHR.Retirement.Service.Controllers
|
||||||
var profile = req.Persons.FirstOrDefault(x => x.ProfileId == item.profileId);
|
var profile = req.Persons.FirstOrDefault(x => x.ProfileId == item.profileId);
|
||||||
if (profile != null)
|
if (profile != null)
|
||||||
{
|
{
|
||||||
await _repositoryNoti.PushNotificationAsyncV2(
|
await _repositoryNoti.PushNotificationAsync(
|
||||||
item.profileId,
|
item.profileId,
|
||||||
$"หนังสือเวียนถึงแก่กรรมของ {item.RetirementDeceased.prefix}{item.RetirementDeceased.firstName} {item.RetirementDeceased.lastName}",
|
$"หนังสือเวียนถึงแก่กรรมของ {item.RetirementDeceased.prefix}{item.RetirementDeceased.firstName} {item.RetirementDeceased.lastName}",
|
||||||
$"แจ้งข่าวการถึงแก่กรรมของ {item.RetirementDeceased.prefix}{item.RetirementDeceased.firstName} {item.RetirementDeceased.lastName}",
|
$"แจ้งข่าวการถึงแก่กรรมของ {item.RetirementDeceased.prefix}{item.RetirementDeceased.firstName} {item.RetirementDeceased.lastName}",
|
||||||
|
|
@ -683,7 +683,7 @@ namespace BMA.EHR.Retirement.Service.Controllers
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
await _repositoryNoti.PushNotificationAsyncV2(
|
await _repositoryNoti.PushNotificationAsync(
|
||||||
item.profileId,
|
item.profileId,
|
||||||
$"หนังสือเวียนถึงแก่กรรมของ {item.RetirementDeceased.prefix}{item.RetirementDeceased.firstName} {item.RetirementDeceased.lastName}",
|
$"หนังสือเวียนถึงแก่กรรมของ {item.RetirementDeceased.prefix}{item.RetirementDeceased.firstName} {item.RetirementDeceased.lastName}",
|
||||||
$"แจ้งข่าวการถึงแก่กรรมของ {item.RetirementDeceased.prefix}{item.RetirementDeceased.firstName} {item.RetirementDeceased.lastName}",
|
$"แจ้งข่าวการถึงแก่กรรมของ {item.RetirementDeceased.prefix}{item.RetirementDeceased.firstName} {item.RetirementDeceased.lastName}",
|
||||||
|
|
|
||||||
|
|
@ -491,7 +491,7 @@ namespace BMA.EHR.Retirement.Service.Controllers
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
await _repositoryNoti.PushNotificationAsync(
|
await _repositoryNoti.PushNotificationAsync(
|
||||||
Guid.Parse("08dbc953-6268-4e2c-80a3-aca65eedc6d0"),
|
Guid.Parse("aec26ac3-417c-4cf9-9cbe-874939f99ecc"),
|
||||||
$"{retirementResign.prefix}{retirementResign.firstName} {retirementResign.lastName} ได้ทำการยื่นขอลาออก",
|
$"{retirementResign.prefix}{retirementResign.firstName} {retirementResign.lastName} ได้ทำการยื่นขอลาออก",
|
||||||
$"{retirementResign.prefix}{retirementResign.firstName} {retirementResign.lastName} ได้ทำการยื่นขอลาออก",
|
$"{retirementResign.prefix}{retirementResign.firstName} {retirementResign.lastName} ได้ทำการยื่นขอลาออก",
|
||||||
"",
|
"",
|
||||||
|
|
@ -742,14 +742,14 @@ namespace BMA.EHR.Retirement.Service.Controllers
|
||||||
updated.LastUpdateUserId = UserId ?? "";
|
updated.LastUpdateUserId = UserId ?? "";
|
||||||
updated.LastUpdatedAt = DateTime.Now;
|
updated.LastUpdatedAt = DateTime.Now;
|
||||||
await _repositoryNoti.PushNotificationAsync(
|
await _repositoryNoti.PushNotificationAsync(
|
||||||
Guid.Parse("08dbca3a-8b6a-4a4e-8b23-1f62e4f30ef6"),
|
Guid.Parse("08dc432c-2bc5-4b81-8089-9c057c51192c"),
|
||||||
$"คำขอลาออกขอ {updated.prefix}{updated.firstName} {updated.lastName} ได้รับการอนุมัติจากการเจ้าหน้าที่",
|
$"คำขอลาออกขอ {updated.prefix}{updated.firstName} {updated.lastName} ได้รับการอนุมัติจากการเจ้าหน้าที่",
|
||||||
$"คำขอลาออกขอ {updated.prefix}{updated.firstName} {updated.lastName} ได้รับการอนุมัติจากการเจ้าหน้าที่",
|
$"คำขอลาออกขอ {updated.prefix}{updated.firstName} {updated.lastName} ได้รับการอนุมัติจากการเจ้าหน้าที่",
|
||||||
"",
|
"",
|
||||||
true
|
true
|
||||||
);
|
);
|
||||||
await _repositoryNoti.PushNotificationAsync(
|
await _repositoryNoti.PushNotificationAsync(
|
||||||
Guid.Parse("08dbc953-61ac-47eb-82d7-0e72df7669b5"),
|
updated.profileId,
|
||||||
$"คำขอลาออกขอ {updated.prefix}{updated.firstName} {updated.lastName} ได้รับการอนุมัติจากการเจ้าหน้าที่",
|
$"คำขอลาออกขอ {updated.prefix}{updated.firstName} {updated.lastName} ได้รับการอนุมัติจากการเจ้าหน้าที่",
|
||||||
$"คำขอลาออกขอ {updated.prefix}{updated.firstName} {updated.lastName} ได้รับการอนุมัติจากการเจ้าหน้าที่",
|
$"คำขอลาออกขอ {updated.prefix}{updated.firstName} {updated.lastName} ได้รับการอนุมัติจากการเจ้าหน้าที่",
|
||||||
"",
|
"",
|
||||||
|
|
@ -786,14 +786,14 @@ namespace BMA.EHR.Retirement.Service.Controllers
|
||||||
updated.LastUpdateUserId = UserId ?? "";
|
updated.LastUpdateUserId = UserId ?? "";
|
||||||
updated.LastUpdatedAt = DateTime.Now;
|
updated.LastUpdatedAt = DateTime.Now;
|
||||||
await _repositoryNoti.PushNotificationAsync(
|
await _repositoryNoti.PushNotificationAsync(
|
||||||
Guid.Parse("08dbca3a-8b6a-4a4e-8b23-1f62e4f30ef6"),
|
Guid.Parse("08dc432c-2bc5-4b81-8089-9c057c51192c"),
|
||||||
$"คำขอลาออกขอ {updated.prefix}{updated.firstName} {updated.lastName} ถูกยับยั้งจากการเจ้าหน้าที่",
|
$"คำขอลาออกขอ {updated.prefix}{updated.firstName} {updated.lastName} ถูกยับยั้งจากการเจ้าหน้าที่",
|
||||||
$"คำขอลาออกขอ {updated.prefix}{updated.firstName} {updated.lastName} ถูกยับยั้งจากการเจ้าหน้าที่",
|
$"คำขอลาออกขอ {updated.prefix}{updated.firstName} {updated.lastName} ถูกยับยั้งจากการเจ้าหน้าที่",
|
||||||
"",
|
"",
|
||||||
true
|
true
|
||||||
);
|
);
|
||||||
await _repositoryNoti.PushNotificationAsync(
|
await _repositoryNoti.PushNotificationAsync(
|
||||||
Guid.Parse("08dbc953-61ac-47eb-82d7-0e72df7669b5"),
|
updated.profileId,
|
||||||
$"คำขอลาออกขอ {updated.prefix}{updated.firstName} {updated.lastName} ถูกยับยั้งจากการเจ้าหน้าที่",
|
$"คำขอลาออกขอ {updated.prefix}{updated.firstName} {updated.lastName} ถูกยับยั้งจากการเจ้าหน้าที่",
|
||||||
$"คำขอลาออกขอ {updated.prefix}{updated.firstName} {updated.lastName} ถูกยับยั้งจากการเจ้าหน้าที่",
|
$"คำขอลาออกขอ {updated.prefix}{updated.firstName} {updated.lastName} ถูกยับยั้งจากการเจ้าหน้าที่",
|
||||||
"",
|
"",
|
||||||
|
|
@ -828,14 +828,14 @@ namespace BMA.EHR.Retirement.Service.Controllers
|
||||||
updated.LastUpdateUserId = UserId ?? "";
|
updated.LastUpdateUserId = UserId ?? "";
|
||||||
updated.LastUpdatedAt = DateTime.Now;
|
updated.LastUpdatedAt = DateTime.Now;
|
||||||
await _repositoryNoti.PushNotificationAsync(
|
await _repositoryNoti.PushNotificationAsync(
|
||||||
Guid.Parse("08dbca3a-8b6a-4a4e-8b23-1f62e4f30ef6"),
|
Guid.Parse("08dc4307-0adc-4bcd-8213-5479bb010236"),
|
||||||
$"คำขอลาออกขอ {updated.prefix}{updated.firstName} {updated.lastName} ได้รับการอนุมัติจากผู้บังคับบัญชา",
|
$"คำขอลาออกขอ {updated.prefix}{updated.firstName} {updated.lastName} ได้รับการอนุมัติจากผู้บังคับบัญชา",
|
||||||
$"คำขอลาออกขอ {updated.prefix}{updated.firstName} {updated.lastName} ได้รับการอนุมัติจากผู้บังคับบัญชา",
|
$"คำขอลาออกขอ {updated.prefix}{updated.firstName} {updated.lastName} ได้รับการอนุมัติจากผู้บังคับบัญชา",
|
||||||
"",
|
"",
|
||||||
true
|
true
|
||||||
);
|
);
|
||||||
await _repositoryNoti.PushNotificationAsync(
|
await _repositoryNoti.PushNotificationAsync(
|
||||||
Guid.Parse("08dbc953-61ac-47eb-82d7-0e72df7669b5"),
|
updated.profileId,
|
||||||
$"คำขอลาออกขอ {updated.prefix}{updated.firstName} {updated.lastName} ได้รับการอนุมัติจากผู้บังคับบัญชา",
|
$"คำขอลาออกขอ {updated.prefix}{updated.firstName} {updated.lastName} ได้รับการอนุมัติจากผู้บังคับบัญชา",
|
||||||
$"คำขอลาออกขอ {updated.prefix}{updated.firstName} {updated.lastName} ได้รับการอนุมัติจากผู้บังคับบัญชา",
|
$"คำขอลาออกขอ {updated.prefix}{updated.firstName} {updated.lastName} ได้รับการอนุมัติจากผู้บังคับบัญชา",
|
||||||
"",
|
"",
|
||||||
|
|
@ -872,14 +872,14 @@ namespace BMA.EHR.Retirement.Service.Controllers
|
||||||
updated.LastUpdateUserId = UserId ?? "";
|
updated.LastUpdateUserId = UserId ?? "";
|
||||||
updated.LastUpdatedAt = DateTime.Now;
|
updated.LastUpdatedAt = DateTime.Now;
|
||||||
await _repositoryNoti.PushNotificationAsync(
|
await _repositoryNoti.PushNotificationAsync(
|
||||||
Guid.Parse("08dbca3a-8b6a-4a4e-8b23-1f62e4f30ef6"),
|
Guid.Parse("08dc4307-0adc-4bcd-8213-5479bb010236"),
|
||||||
$"คำขอลาออกขอ {updated.prefix}{updated.firstName} {updated.lastName} ถูกยับยั้งจากผู้บังคับบัญชา",
|
$"คำขอลาออกขอ {updated.prefix}{updated.firstName} {updated.lastName} ถูกยับยั้งจากผู้บังคับบัญชา",
|
||||||
$"คำขอลาออกขอ {updated.prefix}{updated.firstName} {updated.lastName} ถูกยับยั้งจากผู้บังคับบัญชา",
|
$"คำขอลาออกขอ {updated.prefix}{updated.firstName} {updated.lastName} ถูกยับยั้งจากผู้บังคับบัญชา",
|
||||||
"",
|
"",
|
||||||
true
|
true
|
||||||
);
|
);
|
||||||
await _repositoryNoti.PushNotificationAsync(
|
await _repositoryNoti.PushNotificationAsync(
|
||||||
Guid.Parse("08dbc953-61ac-47eb-82d7-0e72df7669b5"),
|
updated.profileId,
|
||||||
$"คำขอลาออกขอ {updated.prefix}{updated.firstName} {updated.lastName} ถูกยับยั้งจากผู้บังคับบัญชา",
|
$"คำขอลาออกขอ {updated.prefix}{updated.firstName} {updated.lastName} ถูกยับยั้งจากผู้บังคับบัญชา",
|
||||||
$"คำขอลาออกขอ {updated.prefix}{updated.firstName} {updated.lastName} ถูกยับยั้งจากผู้บังคับบัญชา",
|
$"คำขอลาออกขอ {updated.prefix}{updated.firstName} {updated.lastName} ถูกยับยั้งจากผู้บังคับบัญชา",
|
||||||
"",
|
"",
|
||||||
|
|
@ -912,8 +912,15 @@ namespace BMA.EHR.Retirement.Service.Controllers
|
||||||
updated.LastUpdateFullName = FullName ?? "System Administrator";
|
updated.LastUpdateFullName = FullName ?? "System Administrator";
|
||||||
updated.LastUpdateUserId = UserId ?? "";
|
updated.LastUpdateUserId = UserId ?? "";
|
||||||
updated.LastUpdatedAt = DateTime.Now;
|
updated.LastUpdatedAt = DateTime.Now;
|
||||||
await _repositoryNoti.PushNotificationAsyncV2(
|
await _repositoryNoti.PushNotificationAsync(
|
||||||
updated.CreatedUserId,
|
Guid.Parse("aec26ac3-417c-4cf9-9cbe-874939f99ecc"),
|
||||||
|
$"คำขอลาออกขอ {updated.prefix}{updated.firstName} {updated.lastName} ได้รับการอนุมัติจากผู้มีอำนาจ",
|
||||||
|
$"คำขอลาออกขอ {updated.prefix}{updated.firstName} {updated.lastName} ได้รับการอนุมัติจากผู้มีอำนาจ",
|
||||||
|
"",
|
||||||
|
true
|
||||||
|
);
|
||||||
|
await _repositoryNoti.PushNotificationAsync(
|
||||||
|
updated.profileId,
|
||||||
$"คำขอลาออกขอ {updated.prefix}{updated.firstName} {updated.lastName} ได้รับการอนุมัติจากผู้มีอำนาจ",
|
$"คำขอลาออกขอ {updated.prefix}{updated.firstName} {updated.lastName} ได้รับการอนุมัติจากผู้มีอำนาจ",
|
||||||
$"คำขอลาออกขอ {updated.prefix}{updated.firstName} {updated.lastName} ได้รับการอนุมัติจากผู้มีอำนาจ",
|
$"คำขอลาออกขอ {updated.prefix}{updated.firstName} {updated.lastName} ได้รับการอนุมัติจากผู้มีอำนาจ",
|
||||||
"",
|
"",
|
||||||
|
|
@ -949,8 +956,15 @@ namespace BMA.EHR.Retirement.Service.Controllers
|
||||||
updated.LastUpdateFullName = FullName ?? "System Administrator";
|
updated.LastUpdateFullName = FullName ?? "System Administrator";
|
||||||
updated.LastUpdateUserId = UserId ?? "";
|
updated.LastUpdateUserId = UserId ?? "";
|
||||||
updated.LastUpdatedAt = DateTime.Now;
|
updated.LastUpdatedAt = DateTime.Now;
|
||||||
await _repositoryNoti.PushNotificationAsyncV2(
|
await _repositoryNoti.PushNotificationAsync(
|
||||||
updated.CreatedUserId,
|
Guid.Parse("aec26ac3-417c-4cf9-9cbe-874939f99ecc"),
|
||||||
|
$"คำขอลาออกขอ {updated.prefix}{updated.firstName} {updated.lastName} ได้รับการอนุมัติจากผู้มีอำนาจ",
|
||||||
|
$"คำขอลาออกขอ {updated.prefix}{updated.firstName} {updated.lastName} ได้รับการอนุมัติจากผู้มีอำนาจ",
|
||||||
|
"",
|
||||||
|
true
|
||||||
|
);
|
||||||
|
await _repositoryNoti.PushNotificationAsync(
|
||||||
|
updated.profileId,
|
||||||
$"คำขอลาออกขอ {updated.prefix}{updated.firstName} {updated.lastName} ถูกยับยั้งจากผู้มีอำนาจ",
|
$"คำขอลาออกขอ {updated.prefix}{updated.firstName} {updated.lastName} ถูกยับยั้งจากผู้มีอำนาจ",
|
||||||
$"คำขอลาออกขอ {updated.prefix}{updated.firstName} {updated.lastName} ถูกยับยั้งจากผู้มีอำนาจ",
|
$"คำขอลาออกขอ {updated.prefix}{updated.firstName} {updated.lastName} ถูกยับยั้งจากผู้มีอำนาจ",
|
||||||
"",
|
"",
|
||||||
|
|
@ -1331,8 +1345,8 @@ namespace BMA.EHR.Retirement.Service.Controllers
|
||||||
uppdated.LastUpdateFullName = FullName ?? "System Administrator";
|
uppdated.LastUpdateFullName = FullName ?? "System Administrator";
|
||||||
uppdated.LastUpdateUserId = UserId ?? "";
|
uppdated.LastUpdateUserId = UserId ?? "";
|
||||||
uppdated.LastUpdatedAt = DateTime.Now;
|
uppdated.LastUpdatedAt = DateTime.Now;
|
||||||
await _repositoryNoti.PushNotificationAsyncV2(
|
await _repositoryNoti.PushNotificationAsync(
|
||||||
uppdated.RetirementResign.CreatedUserId,
|
uppdated.RetirementResign.profileId,
|
||||||
$"การนัดสัมภาษณ์เหตุผลการลาออก {req.AppointDate.ToThaiFullDate()}",
|
$"การนัดสัมภาษณ์เหตุผลการลาออก {req.AppointDate.ToThaiFullDate()}",
|
||||||
$"การนัดสัมภาษณ์เหตุผลการลาออก {req.AppointDate.ToThaiFullDate()}",
|
$"การนัดสัมภาษณ์เหตุผลการลาออก {req.AppointDate.ToThaiFullDate()}",
|
||||||
"",
|
"",
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue