Merge branch 'develop' into adiDev
This commit is contained in:
commit
3bbf4e26e7
11 changed files with 107 additions and 9 deletions
|
|
@ -334,6 +334,61 @@ namespace BMA.EHR.Application.Repositories.MessageQueue
|
|||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
public class NotisLinkSendRequest
|
||||
{
|
||||
public Guid ReceiverUserId { get; set; }
|
||||
public string NotiLink { get; set; }
|
||||
public bool IsSendMail { get; set; }
|
||||
public bool IsSendInbox { get; set; }
|
||||
}
|
||||
public async Task PushNotificationsLinkSendAsync(NotisLinkSendRequest[] ReceiverUserIds, string Subject, string Body, string Payload = "")
|
||||
{
|
||||
try
|
||||
{
|
||||
foreach (var data in ReceiverUserIds)
|
||||
{
|
||||
_dbContext.Set<Notification>().Add(new Notification
|
||||
{
|
||||
Body = Body,
|
||||
ReceiverUserId = data.ReceiverUserId,
|
||||
Type = "",
|
||||
Payload = data.NotiLink,
|
||||
CreatedFullName = FullName ?? "System Administrator",
|
||||
CreatedUserId = UserId ?? "",
|
||||
CreatedAt = DateTime.Now,
|
||||
LastUpdateFullName = FullName ?? "System Administrator",
|
||||
LastUpdateUserId = UserId ?? "",
|
||||
LastUpdatedAt = DateTime.Now,
|
||||
});
|
||||
if (data.IsSendInbox == true)
|
||||
{
|
||||
_dbContext.Set<Inbox>().Add(new Inbox
|
||||
{
|
||||
Subject = Subject,
|
||||
Body = Body,
|
||||
ReceiverUserId = data.ReceiverUserId,
|
||||
Payload = Payload,
|
||||
CreatedFullName = FullName ?? "System Administrator",
|
||||
CreatedUserId = UserId ?? "",
|
||||
CreatedAt = DateTime.Now,
|
||||
LastUpdateFullName = FullName ?? "System Administrator",
|
||||
LastUpdateUserId = UserId ?? "",
|
||||
LastUpdatedAt = DateTime.Now,
|
||||
});
|
||||
}
|
||||
if (data.IsSendMail == true)
|
||||
{
|
||||
_emailSenderService.SendMail(Subject, Body, "kittapath@frappet.com");
|
||||
}
|
||||
}
|
||||
await _dbContext.SaveChangesAsync();
|
||||
}
|
||||
catch
|
||||
{
|
||||
throw;
|
||||
}
|
||||
}
|
||||
public async Task PushNotificationAsyncV2(string? ReceiverUserId, string Subject, string Body, string Payload = "", bool IsSendInbox = false, bool IsSendMail = false)
|
||||
{
|
||||
try
|
||||
|
|
|
|||
|
|
@ -135,6 +135,18 @@ namespace BMA.EHR.Placement.Service.Controllers
|
|||
return Success();
|
||||
}
|
||||
|
||||
[HttpPost("profiles-send")]
|
||||
public async Task<ActionResult<ResponseObject>> UpdatePropertyByUserProfiles_send([FromBody] NotisSendRequest req)
|
||||
{
|
||||
await _repositoryNoti.PushNotificationsLinkSendAsync(
|
||||
req.ReceiverUserIds,
|
||||
req.Subject,
|
||||
req.Body,
|
||||
req.Payload
|
||||
);
|
||||
return Success();
|
||||
}
|
||||
|
||||
[HttpPut("{id:length(36)}")]
|
||||
public async Task<ActionResult<ResponseObject>> ReplyPropertyByUser([FromBody] NotiReplyRequest req, Guid id)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -57,7 +57,8 @@ namespace BMA.EHR.Placement.Service.Controllers
|
|||
private string? FullName => _httpContextAccessor?.HttpContext?.User?.FindFirst("name")?.Value;
|
||||
private string? token => _httpContextAccessor?.HttpContext?.Request.Headers["Authorization"];
|
||||
|
||||
private bool? PlacementAdmin => _httpContextAccessor?.HttpContext?.User?.IsInRole("placement1");
|
||||
//private bool? PlacementAdmin => _httpContextAccessor?.HttpContext?.User?.IsInRole("placement1");
|
||||
private bool? PlacementAdmin => _httpContextAccessor?.HttpContext?.User?.Claims?.Any(claim => new[] { "placement", "placement1", "placement2" }.Contains(claim.Value));
|
||||
|
||||
#endregion
|
||||
|
||||
|
|
|
|||
|
|
@ -56,7 +56,8 @@ namespace BMA.EHR.Placement.Service.Controllers
|
|||
private string? FullName => _httpContextAccessor?.HttpContext?.User?.FindFirst("name")?.Value;
|
||||
private string? token => _httpContextAccessor?.HttpContext?.Request.Headers["Authorization"];
|
||||
|
||||
private bool? PlacementAdmin => _httpContextAccessor?.HttpContext?.User?.IsInRole("placement1");
|
||||
//private bool? PlacementAdmin => _httpContextAccessor?.HttpContext?.User?.IsInRole("placement1");
|
||||
private bool? PlacementAdmin => _httpContextAccessor?.HttpContext?.User?.Claims?.Any(claim => new[] { "placement", "placement1", "placement2" }.Contains(claim.Value));
|
||||
|
||||
#endregion
|
||||
|
||||
|
|
|
|||
|
|
@ -57,7 +57,8 @@ namespace BMA.EHR.Placement.Service.Controllers
|
|||
private string? FullName => _httpContextAccessor?.HttpContext?.User?.FindFirst("name")?.Value;
|
||||
private string? token => _httpContextAccessor.HttpContext.Request.Headers["Authorization"];
|
||||
|
||||
private bool? PlacementAdmin => _httpContextAccessor?.HttpContext?.User?.IsInRole("placement1");
|
||||
//private bool? PlacementAdmin => _httpContextAccessor?.HttpContext?.User?.IsInRole("placement");
|
||||
private bool? PlacementAdmin => _httpContextAccessor?.HttpContext?.User?.Claims?.Any(claim => new[] { "placement", "placement1", "placement2" }.Contains(claim.Value));
|
||||
|
||||
#endregion
|
||||
|
||||
|
|
@ -1531,6 +1532,7 @@ namespace BMA.EHR.Placement.Service.Controllers
|
|||
var report_data = (from p in _context.PlacementProfiles
|
||||
.Include(x => x.Placement)
|
||||
.Include(x => x.PlacementEducations)
|
||||
.Include(x => x.PositionCandidate)
|
||||
// .ThenInclude(x => x.PlacementType)
|
||||
.Where(x => req.refIds.Select(x => x.refId).Contains(x.Id.ToString()))
|
||||
// .Where(x => x.Placement!.PlacementType!.Name != "สอบแข่งขัน")
|
||||
|
|
@ -1548,7 +1550,12 @@ namespace BMA.EHR.Placement.Service.Controllers
|
|||
PositionName = p.positionName == null ? "" : p.positionName,
|
||||
ExamNumber = p.ExamNumber == null ? "0" : p.ExamNumber.Value.ToString().ToThaiNumber(),
|
||||
PlacementName = $"{p.Placement.Name.ToThaiNumber()} ครั้งที่ {p.Placement.Round.ToThaiNumber()}/{p.Placement.Year.ToThaiYear().ToString().ToThaiNumber()}",
|
||||
Oc = (p.positionName == null ? "" : p.positionName) + "/" + (p.root == null ? "" : p.root),
|
||||
Oc = p.root == null ? "" :
|
||||
p.node == 4 ? $"{p.child4}/{p.child3}/{p.child2}/{p.child1}/{p.root}" :
|
||||
p.node == 3 ? $"{p.child3}/{p.child2}/{p.child1}/{p.root}" :
|
||||
p.node == 2 ? $"{p.child2}/{p.child1}/{p.root}" :
|
||||
p.node == 1 ? $"{p.child1}/{p.root}" :
|
||||
p.node == 0 ? $"{p.root}" : "",
|
||||
PositionType = p.posTypeName == null ? "" : p.posTypeName,
|
||||
PositionLevel = p.posLevelName == null ? "" : p.posLevelName,
|
||||
PositionNumber = p.posMasterNo == null ? "" :
|
||||
|
|
@ -1561,6 +1568,8 @@ namespace BMA.EHR.Placement.Service.Controllers
|
|||
AppointDate = p.ReportingDate == null ? "" : p.ReportingDate.Value.ToThaiShortDate2().ToThaiNumber(),
|
||||
RemarkHorizontal = r.RemarkHorizontal,
|
||||
RemarkVertical = r.RemarkVertical,
|
||||
OccupationPosition = p.OccupationPosition == null ? "" : p.OccupationPosition, //ตำแหน่งเก่าก่อนสอบ
|
||||
PositionCandidate = p.PositionCandidate == null ? "" : p.PositionCandidate.Name //ตำแหน่งที่สอบแข่งขัน
|
||||
}).ToList();
|
||||
return Success(report_data);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -57,7 +57,8 @@ namespace BMA.EHR.Placement.Service.Controllers
|
|||
private string? FullName => _httpContextAccessor?.HttpContext?.User?.FindFirst("name")?.Value;
|
||||
private string? token => _httpContextAccessor?.HttpContext?.Request.Headers["Authorization"];
|
||||
|
||||
private bool? PlacementAdmin => _httpContextAccessor?.HttpContext?.User?.IsInRole("placement1");
|
||||
//private bool? PlacementAdmin => _httpContextAccessor?.HttpContext?.User?.IsInRole("placement1");
|
||||
private bool? PlacementAdmin => _httpContextAccessor?.HttpContext?.User?.Claims?.Any(claim => new[] { "placement", "placement1", "placement2" }.Contains(claim.Value));
|
||||
|
||||
#endregion
|
||||
|
||||
|
|
|
|||
|
|
@ -57,7 +57,8 @@ namespace BMA.EHR.Placement.Service.Controllers
|
|||
private string? FullName => _httpContextAccessor?.HttpContext?.User?.FindFirst("name")?.Value;
|
||||
private string? token => _httpContextAccessor?.HttpContext?.Request.Headers["Authorization"];
|
||||
|
||||
private bool? PlacementAdmin => _httpContextAccessor?.HttpContext?.User?.IsInRole("placement1");
|
||||
//private bool? PlacementAdmin => _httpContextAccessor?.HttpContext?.User?.IsInRole("placement1");
|
||||
private bool? PlacementAdmin => _httpContextAccessor?.HttpContext?.User?.Claims?.Any(claim => new[] { "placement", "placement1", "placement2" }.Contains(claim.Value));
|
||||
|
||||
#endregion
|
||||
|
||||
|
|
|
|||
|
|
@ -46,7 +46,8 @@ namespace BMA.EHR.Placement.Service.Controllers
|
|||
|
||||
private string? FullName => _httpContextAccessor?.HttpContext?.User?.FindFirst("name")?.Value;
|
||||
|
||||
private bool? PlacementAdmin => _httpContextAccessor?.HttpContext?.User?.IsInRole("placement1");
|
||||
//private bool? PlacementAdmin => _httpContextAccessor?.HttpContext?.User?.IsInRole("placement1");
|
||||
private bool? PlacementAdmin => _httpContextAccessor?.HttpContext?.User?.Claims?.Any(claim => new[] { "placement", "placement1", "placement2" }.Contains(claim.Value));
|
||||
|
||||
#endregion
|
||||
|
||||
|
|
|
|||
|
|
@ -58,7 +58,8 @@ namespace BMA.EHR.Placement.Service.Controllers
|
|||
private string? FullName => _httpContextAccessor?.HttpContext?.User?.FindFirst("name")?.Value;
|
||||
private string? token => _httpContextAccessor?.HttpContext?.Request.Headers["Authorization"];
|
||||
|
||||
private bool? PlacementAdmin => _httpContextAccessor?.HttpContext?.User?.IsInRole("placement1");
|
||||
//private bool? PlacementAdmin => _httpContextAccessor?.HttpContext?.User?.IsInRole("placement1");
|
||||
private bool? PlacementAdmin => _httpContextAccessor?.HttpContext?.User?.Claims?.Any(claim => new[] { "placement", "placement1", "placement2" }.Contains(claim.Value));
|
||||
|
||||
#endregion
|
||||
|
||||
|
|
|
|||
|
|
@ -57,7 +57,8 @@ namespace BMA.EHR.Placement.Service.Controllers
|
|||
private string? FullName => _httpContextAccessor?.HttpContext?.User?.FindFirst("name")?.Value;
|
||||
private string? token => _httpContextAccessor?.HttpContext?.Request.Headers["Authorization"];
|
||||
|
||||
private bool? PlacementAdmin => _httpContextAccessor?.HttpContext?.User?.IsInRole("placement1");
|
||||
//private bool? PlacementAdmin => _httpContextAccessor?.HttpContext?.User?.IsInRole("placement1");
|
||||
private bool? PlacementAdmin => _httpContextAccessor?.HttpContext?.User?.Claims?.Any(claim => new[] { "placement", "placement1", "placement2" }.Contains(claim.Value));
|
||||
|
||||
#endregion
|
||||
|
||||
|
|
|
|||
15
BMA.EHR.Placement.Service/Requests/NotisSendRequest.cs
Normal file
15
BMA.EHR.Placement.Service/Requests/NotisSendRequest.cs
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
using BMA.EHR.Domain.Models.MetaData;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using static BMA.EHR.Application.Repositories.MessageQueue.NotificationRepository;
|
||||
|
||||
namespace BMA.EHR.Placement.Service.Requests
|
||||
{
|
||||
public class NotisSendRequest
|
||||
{
|
||||
public string Subject { get; set; }
|
||||
public string Body { get; set; }
|
||||
public string Payload { get; set; }
|
||||
// public string NotiLink { get; set; }
|
||||
public NotisLinkSendRequest[] ReceiverUserIds { get; set; }
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue