fix bug upload
api ออกคำสั่ง ส่ง inbox and noti
This commit is contained in:
parent
9ff5725be4
commit
c99cb5344e
11 changed files with 13843 additions and 4 deletions
|
|
@ -19,6 +19,7 @@ namespace BMA.EHR.Application
|
|||
services.AddTransient<InsigniaPeriodsRepository>();
|
||||
services.AddTransient<RetirementRepository>();
|
||||
services.AddTransient<UserProfileRepository>();
|
||||
services.AddTransient<OrganizationCommonRepository>();
|
||||
|
||||
return services;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,14 +1,19 @@
|
|||
using BMA.EHR.Application.Common.Interfaces;
|
||||
using Amazon;
|
||||
using BMA.EHR.Application.Common.Interfaces;
|
||||
using BMA.EHR.Application.Requests.Commands;
|
||||
using BMA.EHR.Application.Responses;
|
||||
using BMA.EHR.Domain.Extensions;
|
||||
using BMA.EHR.Domain.Models.Commands.Core;
|
||||
using BMA.EHR.Domain.Models.HR;
|
||||
using BMA.EHR.Domain.Models.MetaData;
|
||||
using BMA.EHR.Domain.Models.Notifications;
|
||||
using BMA.EHR.Domain.Models.Organizations;
|
||||
using BMA.EHR.Domain.Models.Placement;
|
||||
using BMA.EHR.Domain.Shared;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Command = BMA.EHR.Domain.Models.Commands.Core.Command;
|
||||
using Profile = BMA.EHR.Domain.Models.HR.Profile;
|
||||
|
||||
namespace BMA.EHR.Application.Repositories.Commands
|
||||
{
|
||||
|
|
@ -18,16 +23,19 @@ namespace BMA.EHR.Application.Repositories.Commands
|
|||
|
||||
private readonly IApplicationDBContext _dbContext;
|
||||
private readonly IHttpContextAccessor _httpContextAccessor;
|
||||
private readonly OrganizationCommonRepository _organizationCommonRepository;
|
||||
|
||||
#endregion
|
||||
|
||||
#region " Constructor and Destuctor "
|
||||
|
||||
public CommandRepository(IApplicationDBContext dbContext,
|
||||
IHttpContextAccessor httpContextAccessor) : base(dbContext, httpContextAccessor)
|
||||
IHttpContextAccessor httpContextAccessor,
|
||||
OrganizationCommonRepository organizationCommonRepository) : base(dbContext, httpContextAccessor)
|
||||
{
|
||||
_dbContext = dbContext;
|
||||
_httpContextAccessor = httpContextAccessor;
|
||||
_organizationCommonRepository = organizationCommonRepository;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
|
@ -137,7 +145,240 @@ namespace BMA.EHR.Application.Repositories.Commands
|
|||
{
|
||||
try
|
||||
{
|
||||
// create new profile
|
||||
foreach (var recv in command.Receivers)
|
||||
{
|
||||
// query placement Profile
|
||||
var placementProfile = await _dbContext.Set<PlacementProfile>()
|
||||
.Include(x => x.Prefix)
|
||||
.Include(x => x.FatherPrefix)
|
||||
.Include(x => x.MotherPrefix)
|
||||
.Include(x => x.MarryPrefix)
|
||||
.Include(x => x.Gender)
|
||||
.Include(x => x.Relationship)
|
||||
.Include(x => x.BloodGroup)
|
||||
.Include(x => x.Religion)
|
||||
|
||||
.Include(x => x.RegistSubDistrict)
|
||||
.Include(x => x.RegistDistrict)
|
||||
.Include(x => x.RegistProvince)
|
||||
.Include(x => x.CurrentSubDistrict)
|
||||
.Include(x => x.CurrentDistrict)
|
||||
.Include(x => x.CurrentProvince)
|
||||
|
||||
.Include(x => x.PositionPath)
|
||||
.Include(x => x.PositionPathSide)
|
||||
.Include(x => x.PositionType)
|
||||
.Include(x => x.PositionLine)
|
||||
.Include(x => x.PositionLevel)
|
||||
.Include(x => x.PositionNumber)
|
||||
|
||||
.Include(x => x.PlacementCertificates)
|
||||
.Include(x => x.PlacementEducations)
|
||||
.ThenInclude(x => x.EducationLevel)
|
||||
|
||||
.Include(x => x.OrganizationPosition)
|
||||
.ThenInclude(x => x.Organization)
|
||||
.ThenInclude(x => x.OrganizationShortName)
|
||||
|
||||
.Include(x => x.OrganizationPosition)
|
||||
.ThenInclude(x => x.PositionMaster)
|
||||
.ThenInclude(x => x.PositionExecutive)
|
||||
|
||||
.Include(x => x.OrganizationPosition)
|
||||
.ThenInclude(x => x.PositionMaster)
|
||||
.ThenInclude(x => x.PositionExecutiveSide)
|
||||
|
||||
.Include(x => x.OrganizationPosition)
|
||||
.ThenInclude(x => x.PositionMaster)
|
||||
.ThenInclude(x => x.PositionLine)
|
||||
|
||||
.FirstOrDefaultAsync(x => x.Id == recv.RefPlacementProfileId);
|
||||
|
||||
if (placementProfile == null)
|
||||
throw new Exception("Invalid placement profile: " + recv.RefPlacementProfileId);
|
||||
|
||||
// ใส่ฟีลจากข้อมูล
|
||||
var profile = new Profile
|
||||
{
|
||||
ProfileType = "officer",
|
||||
CitizenId = placementProfile.CitizenId,
|
||||
Prefix = placementProfile.Prefix,
|
||||
FirstName = placementProfile.Firstname,
|
||||
LastName = placementProfile.Lastname,
|
||||
Gender = placementProfile.Gender,
|
||||
Nationality = placementProfile.Nationality,
|
||||
BirthDate = placementProfile.DateOfBirth == null ? DateTime.MinValue : placementProfile.DateOfBirth.Value,
|
||||
RelationshipId = placementProfile.Relationship == null ? Guid.Empty : placementProfile.Relationship!.Id,
|
||||
TelephoneNumber = placementProfile.Telephone,
|
||||
Race = placementProfile.Race,
|
||||
ReligionId = placementProfile.Religion == null ? Guid.Empty : placementProfile.Religion.Id,
|
||||
BloodGroupId = placementProfile.BloodGroup == null ? Guid.Empty : placementProfile.BloodGroup.Id,
|
||||
|
||||
|
||||
RegistrationAddress = placementProfile.RegistAddress,
|
||||
RegistrationSubDistrictId = placementProfile.RegistSubDistrict == null ? Guid.Empty : placementProfile.RegistSubDistrict!.Id,
|
||||
RegistrationDistrictId = placementProfile.RegistDistrict == null ? Guid.Empty : placementProfile.RegistDistrict!.Id,
|
||||
RegistrationProvinceId = placementProfile.RegistProvince == null ? Guid.Empty : placementProfile.RegistProvince!.Id,
|
||||
|
||||
CurrentAddress = placementProfile.CurrentAddress,
|
||||
CurrentSubDistrictId = placementProfile.CurrentSubDistrict == null ? Guid.Empty : placementProfile.CurrentSubDistrict!.Id,
|
||||
CurrentDistrictId = placementProfile.CurrentDistrict == null ? Guid.Empty : placementProfile.CurrentDistrict!.Id,
|
||||
CurrentProvinceId = placementProfile.CurrentProvince == null ? Guid.Empty : placementProfile.CurrentProvince!.Id,
|
||||
|
||||
FatherPrefixId = placementProfile.FatherPrefix == null ? Guid.Empty : placementProfile.FatherPrefix.Id,
|
||||
FatherFirstName = placementProfile.FatherFirstName,
|
||||
FatherLastName = placementProfile.FatherLastName,
|
||||
FatherCareer = placementProfile.FatherOccupation,
|
||||
|
||||
MotherPrefixId = placementProfile.MotherPrefix == null ? Guid.Empty : placementProfile.MotherPrefix.Id,
|
||||
MotherFirstName = placementProfile.MotherFirstName,
|
||||
MotherLastName = placementProfile.MotherLastName,
|
||||
MotherCareer = placementProfile.MotherOccupation,
|
||||
|
||||
CouplePrefixId = placementProfile.MarryPrefix == null ? Guid.Empty : placementProfile.MarryPrefix.Id,
|
||||
CoupleFirstName = placementProfile.MarryFirstName,
|
||||
CoupleLastName = placementProfile.MarryLastName,
|
||||
CoupleCareer = placementProfile.MarryOccupation,
|
||||
|
||||
Position = placementProfile.PositionPath,
|
||||
PositionPathSideId = placementProfile.PositionPathSide == null ? Guid.Empty : placementProfile.PositionPathSide.Id,
|
||||
PositionType = placementProfile.PositionType,
|
||||
PositionLevel = placementProfile.PositionLevel,
|
||||
PositionLineId = placementProfile.PositionLine == null ? Guid.Empty : placementProfile.PositionLine.Id,
|
||||
IsVerified = true,
|
||||
IsProbation = true,
|
||||
|
||||
Educations = new List<ProfileEducation>(),
|
||||
Certificates = new List<ProfileCertificate>(),
|
||||
Salaries = new List<ProfileSalary>()
|
||||
};
|
||||
|
||||
// add profile education
|
||||
foreach (var edu in placementProfile.PlacementEducations)
|
||||
{
|
||||
profile.Educations.Add(new ProfileEducation
|
||||
{
|
||||
Country = edu.Country,
|
||||
Degree = edu.Degree,
|
||||
Duration = edu.Duration,
|
||||
DurationYear = edu.DurationYear == null ? 0 : edu.DurationYear.Value,
|
||||
EducationLevelId = edu.EducationLevel == null ? Guid.Empty : edu.EducationLevel.Id,
|
||||
EducationLevel = edu.EducationLevel == null ? "" : edu.EducationLevel.Name,
|
||||
StartDate = edu.StartDate,
|
||||
EndDate = edu.EndDate,
|
||||
Field = edu.Field,
|
||||
FinishDate = edu.FinishDate,
|
||||
FundName = edu.FundName,
|
||||
Gpa = edu.Gpa,
|
||||
Institute = edu.Institute,
|
||||
});
|
||||
}
|
||||
|
||||
// add profile certificate
|
||||
foreach (var cert in placementProfile.PlacementCertificates)
|
||||
{
|
||||
profile.Certificates.Add(new ProfileCertificate
|
||||
{
|
||||
CertificateNo = cert.CertificateNo,
|
||||
IssueDate = cert.IssueDate,
|
||||
Issuer = cert.Issuer,
|
||||
CertificateType = cert.CertificateType,
|
||||
ExpireDate = cert.ExpireDate,
|
||||
});
|
||||
}
|
||||
|
||||
// add profile salary
|
||||
|
||||
var oc = _dbContext.Set<OrganizationEntity>()
|
||||
.FirstOrDefault(x => x.Id == placementProfile.OrganizationPosition!.Organization!.Id);
|
||||
|
||||
var position = placementProfile.PositionPath;
|
||||
|
||||
var positionNumber = placementProfile.PositionNumber;
|
||||
|
||||
var positionType = placementProfile.PositionType;
|
||||
|
||||
var positionLevel = placementProfile.PositionLevel;
|
||||
|
||||
|
||||
var salary = new ProfileSalary
|
||||
{
|
||||
Order = 1,
|
||||
Date = command.CommandAffectDate,
|
||||
Amount = placementProfile.Amount,
|
||||
PositionSalaryAmount = placementProfile.PositionSalaryAmount,
|
||||
MouthSalaryAmount = placementProfile.MouthSalaryAmount,
|
||||
|
||||
SalaryRef = "บรรจุและแต่งตั้งผู้สอบแข่งขันได้วุฒิ คำสั่ง" + command.IssuerOrganizationName + "ที่ " + $"{command.CommandNo}/{command.CommandYear} ลงวันที่ {command.CommandExcecuteDate!.Value.ToThaiFullDate3()}",
|
||||
|
||||
OcId = oc == null ? Guid.Empty : oc.Id,
|
||||
PositionExecutiveId = placementProfile.OrganizationPosition!.PositionMaster!.PositionExecutive!.Id,
|
||||
PositionExecutiveSideId = placementProfile.OrganizationPosition!.PositionMaster!.PositionExecutiveSide!.Id,
|
||||
PositionLevel = placementProfile.PositionLevel,
|
||||
PositionLineId = placementProfile.PositionLine!.Id,
|
||||
PositionTypeId = placementProfile.PositionType!.Id,
|
||||
OrganizationShortNameId = placementProfile.OrganizationPosition!.Organization!.OrganizationShortName!.Id,
|
||||
|
||||
CommandNo = $"{command.CommandNo}/{command.CommandYear}",
|
||||
CommandTypeName = command.CommandType.Name
|
||||
};
|
||||
|
||||
profile.Salaries.Add(salary);
|
||||
|
||||
_dbContext.Set<Profile>().Add(profile);
|
||||
|
||||
// update placementstatus
|
||||
placementProfile.PlacementStatus = "CONTAIN";
|
||||
|
||||
await _dbContext.SaveChangesAsync();
|
||||
|
||||
// Send noti inbox and email
|
||||
var inbox = new Inbox
|
||||
{
|
||||
Subject = $"คุณได้รับคำสั่งเลขที่ {command.CommandNo}/{command.CommandYear} ลงวันที่ {command.CommandExcecuteDate.Value.ToThaiFullDate3()}",
|
||||
Body = $"คุณได้รับบรรจุเป็นข้าราชการกรุงเทพมหานครสามัญ ตามคำสั่งเลขที่ {command.CommandNo}/{command.CommandYear} ลงวันที่ {command.CommandExcecuteDate.Value.ToThaiFullDate3()}",
|
||||
ReceiverUserId = profile.Id,
|
||||
};
|
||||
_dbContext.Set<Inbox>().Add(inbox);
|
||||
|
||||
var noti = new Notification
|
||||
{
|
||||
Body = $"คุณได้รับบรรจุเป็นข้าราชการกรุงเทพมหานครสามัญ ตามคำสั่งเลขที่ {command.CommandNo}/{command.CommandYear} ลงวันที่ {command.CommandExcecuteDate.Value.ToThaiFullDate3()}",
|
||||
ReceiverUserId = profile.Id,
|
||||
};
|
||||
_dbContext.Set<Notification>().Add(noti);
|
||||
await _dbContext.SaveChangesAsync();
|
||||
}
|
||||
|
||||
// send cc noti inbox
|
||||
foreach (var cc in command.Deployments)
|
||||
{
|
||||
var pf = await _dbContext.Set<Profile>().FirstOrDefaultAsync(x => x.CitizenId == cc.CitizenId);
|
||||
if (pf != null)
|
||||
{
|
||||
var inbox = new Inbox
|
||||
{
|
||||
Subject = $"คุณได้รับสำเนาคำสั่งเลขที่ {command.CommandNo}/{command.CommandYear} ลงวันที่ {command.CommandExcecuteDate.Value.ToThaiFullDate3()}",
|
||||
Body = $"คำสั่งบบรรจุเป็นข้าราชการกรุงเทพมหานครสามัญ คำสั่งเลขที่ {command.CommandNo}/{command.CommandYear} ลงวันที่ {command.CommandExcecuteDate.Value.ToThaiFullDate3()}",
|
||||
ReceiverUserId = pf.Id,
|
||||
};
|
||||
_dbContext.Set<Inbox>().Add(inbox);
|
||||
|
||||
var noti = new Notification
|
||||
{
|
||||
Body = $"คำสั่งบบรรจุเป็นข้าราชการกรุงเทพมหานครสามัญ คำสั่งเลขที่ {command.CommandNo}/{command.CommandYear} ลงวันที่ {command.CommandExcecuteDate.Value.ToThaiFullDate3()}",
|
||||
ReceiverUserId = pf.Id,
|
||||
};
|
||||
_dbContext.Set<Notification>().Add(noti);
|
||||
}
|
||||
}
|
||||
|
||||
// change command status
|
||||
var cmdStatus = await _dbContext.Set<CommandStatus>().FirstOrDefaultAsync(x => x.Sequence == 5);
|
||||
command.CommandStatusId = cmdStatus!.Id;
|
||||
|
||||
await _dbContext.SaveChangesAsync();
|
||||
}
|
||||
catch
|
||||
{
|
||||
|
|
@ -193,6 +434,31 @@ namespace BMA.EHR.Application.Repositories.Commands
|
|||
|
||||
#endregion
|
||||
|
||||
#region " Execute Command "
|
||||
|
||||
public async Task ExecuteCommandAsync(Guid id)
|
||||
{
|
||||
try
|
||||
{
|
||||
var command = await _dbContext.Set<Command>()
|
||||
.Include(x => x.Receivers)
|
||||
.Include(x => x.Deployments)
|
||||
.Include(x => x.CommandType)
|
||||
.FirstOrDefaultAsync(x => x.Id == id);
|
||||
|
||||
if (command == null)
|
||||
throw new Exception(GlobalMessages.CommandNotFound);
|
||||
else
|
||||
await ExecuteCommandByTypeAsync(command);
|
||||
}
|
||||
catch
|
||||
{
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region " Command Receiver "
|
||||
|
||||
public async Task SaveSelectedReceiverAsync(Guid id, List<Guid> selected)
|
||||
|
|
|
|||
102
BMA.EHR.Application/Repositories/OrganizationCommonRepository.cs
Normal file
102
BMA.EHR.Application/Repositories/OrganizationCommonRepository.cs
Normal file
|
|
@ -0,0 +1,102 @@
|
|||
using BMA.EHR.Application.Common.Interfaces;
|
||||
using BMA.EHR.Application.Responses;
|
||||
using BMA.EHR.Domain.Models.Organizations;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace BMA.EHR.Application.Repositories
|
||||
{
|
||||
public class OrganizationCommonRepository
|
||||
{
|
||||
#region " Fields "
|
||||
|
||||
private readonly IApplicationDBContext _dbContext;
|
||||
private readonly IHttpContextAccessor _httpContextAccessor;
|
||||
|
||||
#endregion
|
||||
|
||||
#region " Constructor and Destuctor "
|
||||
|
||||
public OrganizationCommonRepository(IApplicationDBContext dbContext,
|
||||
IHttpContextAccessor httpContextAccessor)
|
||||
{
|
||||
_dbContext = dbContext;
|
||||
_httpContextAccessor = httpContextAccessor;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region " Methods "
|
||||
|
||||
public string GetOrganizationNameFullPath(Guid id, bool showRoot = false, bool descending = false)
|
||||
{
|
||||
try
|
||||
{
|
||||
var ocList = GetOCWithFullPath(id, showRoot);
|
||||
if (descending)
|
||||
ocList = ocList.OrderBy(x => x.Order).ToList();
|
||||
|
||||
var ret = String.Empty;
|
||||
foreach (var oc in ocList)
|
||||
{
|
||||
ret = oc.Name + " " + ret;
|
||||
}
|
||||
if (ret.Length > 2)
|
||||
ret = ret.Substring(0, ret.Length - 1);
|
||||
|
||||
return ret;
|
||||
}
|
||||
catch
|
||||
{
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
public List<OrganizationItem> GetOCWithFullPath(Guid id, bool showRoot = false)
|
||||
{
|
||||
try
|
||||
{
|
||||
var ocList = new List<OrganizationItem>();
|
||||
|
||||
var ocData = _dbContext.Set<OrganizationEntity>()
|
||||
.Include(x => x.OrganizationOrganization)
|
||||
.Include(x => x.Parent)
|
||||
.Select(x => new
|
||||
{
|
||||
Id = x.Id,
|
||||
Name = x.OrganizationOrganization!.Name,
|
||||
ParentId = x.Parent!.Id
|
||||
})
|
||||
.FirstOrDefault(x => x.Id == id);
|
||||
|
||||
if (ocData != null)
|
||||
{
|
||||
ocList.Add(new OrganizationItem { Id = ocData.Id, Name = ocData.Name });
|
||||
|
||||
//if (!showRoot)
|
||||
//{
|
||||
// if (!oc.IsRoot)
|
||||
// ocList.Add(new OrganizationItem { Id = oc.OCId, Name = oc.OrganizationName });
|
||||
//}
|
||||
//else
|
||||
// ocList.Add(new OrganizationItem { Id = oc.OCId, Name = oc.OrganizationName });
|
||||
|
||||
if (ocData.ParentId != null)
|
||||
{
|
||||
ocList.AddRange(GetOCWithFullPath(ocData.ParentId, showRoot));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
return ocList;
|
||||
}
|
||||
catch
|
||||
{
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
11
BMA.EHR.Application/Responses/OrganizationItem.cs
Normal file
11
BMA.EHR.Application/Responses/OrganizationItem.cs
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
namespace BMA.EHR.Application.Responses
|
||||
{
|
||||
public class OrganizationItem
|
||||
{
|
||||
public Guid Id { get; set; }
|
||||
|
||||
public string Name { get; set; } = string.Empty;
|
||||
|
||||
public int Order { get; set; } = 0;
|
||||
}
|
||||
}
|
||||
|
|
@ -880,7 +880,7 @@ namespace BMA.EHR.Command.Service.Controllers
|
|||
Summary = "Upload a file",
|
||||
Description = "Upload a file using multipart/form-data",
|
||||
OperationId = "UploadCommandCoverAsync"
|
||||
//Tags = new[] { "File" }
|
||||
//Tags = new[] { "File" }
|
||||
)]
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
||||
|
|
@ -941,7 +941,7 @@ namespace BMA.EHR.Command.Service.Controllers
|
|||
Summary = "Upload a file",
|
||||
Description = "Upload a file using multipart/form-data",
|
||||
OperationId = "UploadCommandAttachmentAsync"
|
||||
//Tags = new[] { "File" }
|
||||
//Tags = new[] { "File" }
|
||||
)]
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
||||
|
|
@ -1119,6 +1119,33 @@ namespace BMA.EHR.Command.Service.Controllers
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// ออกคำสั่ง
|
||||
/// </summary>
|
||||
/// <param name="orderId">Record Id ของคำสั่ง</param>
|
||||
/// <returns></returns>
|
||||
/// <response code="200">เมื่อทำการอ่านข้อมูลจาก Relational Database สำเร็จ</response>
|
||||
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
||||
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
||||
[HttpPut("execute/{orderId}")]
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
||||
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||
public async Task<ActionResult<ResponseObject>> ExecuteCommandAsync(Guid orderId)
|
||||
{
|
||||
try
|
||||
{
|
||||
await _repository.ExecuteCommandAsync(orderId);
|
||||
|
||||
return Success();
|
||||
}
|
||||
catch
|
||||
{
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
|
|
|||
31
BMA.EHR.Domain/Models/Notifications/Inbox.cs
Normal file
31
BMA.EHR.Domain/Models/Notifications/Inbox.cs
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
using BMA.EHR.Domain.Models.Base;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
namespace BMA.EHR.Domain.Models.Notifications
|
||||
{
|
||||
public class Inbox : EntityBase
|
||||
{
|
||||
[Required, MaxLength(200), Comment("หัวเรื่อง")]
|
||||
public string Subject { get; set; }
|
||||
|
||||
[Required, Column(TypeName = "text"), Comment("รายละเอียดข้อความ")]
|
||||
public string Body { get; set; }
|
||||
|
||||
[Required,Comment("รหัสผู้รับข้อความ")]
|
||||
public Guid ReceiverUserId { get; set; }
|
||||
|
||||
[Column(TypeName = "text"),Comment("สิงที่แนบมาด้วย")]
|
||||
public string Payload { get; set; }
|
||||
|
||||
[Comment("เปิดอ่านแล้วหรือยัง")]
|
||||
public bool IsOpen { get; set; } = false;
|
||||
|
||||
[Required,Comment("วันที่ได้รับ")]
|
||||
public DateTime ReceiveDate { get; set; } = DateTime.Now;
|
||||
|
||||
[Comment("วันที่เปิดอ่าน")]
|
||||
public DateTime? OpenDate { get; set; }
|
||||
}
|
||||
}
|
||||
31
BMA.EHR.Domain/Models/Notifications/Notification.cs
Normal file
31
BMA.EHR.Domain/Models/Notifications/Notification.cs
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
using BMA.EHR.Domain.Models.Base;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
namespace BMA.EHR.Domain.Models.Notifications
|
||||
{
|
||||
public class Notification : EntityBase
|
||||
{
|
||||
[Required, Column(TypeName = "text"), Comment("รายละเอียดข้อความ")]
|
||||
public string Body { get; set; }
|
||||
|
||||
[Required, Comment("รหัสผู้รับข้อความ")]
|
||||
public Guid ReceiverUserId { get; set; }
|
||||
|
||||
[Required,Comment("ประเภทการแจ้งเตือน")]
|
||||
public string Type { get; set; }
|
||||
|
||||
[Column(TypeName = "text"), Comment("สิงที่แนบมาด้วย")]
|
||||
public string Payload { get; set; }
|
||||
|
||||
[Comment("เปิดอ่านแล้วหรือยัง")]
|
||||
public bool IsOpen { get; set; } = false;
|
||||
|
||||
[Required, Comment("วันที่ได้รับ")]
|
||||
public DateTime ReceiveDate { get; set; } = DateTime.Now;
|
||||
|
||||
[Comment("วันที่เปิดอ่าน")]
|
||||
public DateTime? OpenDate { get; set; }
|
||||
}
|
||||
}
|
||||
13110
BMA.EHR.Infrastructure/Migrations/20230808061523_Add Inbox and Notification Table.Designer.cs
generated
Normal file
13110
BMA.EHR.Infrastructure/Migrations/20230808061523_Add Inbox and Notification Table.Designer.cs
generated
Normal file
File diff suppressed because it is too large
Load diff
|
|
@ -0,0 +1,89 @@
|
|||
using System;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace BMA.EHR.Infrastructure.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class AddInboxandNotificationTable : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Inboxes",
|
||||
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"),
|
||||
Subject = table.Column<string>(type: "varchar(200)", maxLength: 200, nullable: false, comment: "หัวเรื่อง")
|
||||
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||
Body = table.Column<string>(type: "text", nullable: false, comment: "รายละเอียดข้อความ")
|
||||
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||
ReceiverUserId = table.Column<Guid>(type: "char(36)", nullable: false, comment: "รหัสผู้รับข้อความ", collation: "ascii_general_ci"),
|
||||
Payload = table.Column<string>(type: "text", nullable: false, comment: "สิงที่แนบมาด้วย")
|
||||
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||
IsOpen = table.Column<bool>(type: "tinyint(1)", nullable: false, comment: "เปิดอ่านแล้วหรือยัง"),
|
||||
ReceiveDate = table.Column<DateTime>(type: "datetime(6)", nullable: false, comment: "วันที่ได้รับ"),
|
||||
OpenDate = table.Column<DateTime>(type: "datetime(6)", nullable: true, comment: "วันที่เปิดอ่าน")
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Inboxes", x => x.Id);
|
||||
})
|
||||
.Annotation("MySql:CharSet", "utf8mb4");
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Notifications",
|
||||
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"),
|
||||
Body = table.Column<string>(type: "text", nullable: false, comment: "รายละเอียดข้อความ")
|
||||
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||
ReceiverUserId = table.Column<Guid>(type: "char(36)", nullable: false, comment: "รหัสผู้รับข้อความ", collation: "ascii_general_ci"),
|
||||
Type = table.Column<string>(type: "longtext", nullable: false, comment: "ประเภทการแจ้งเตือน")
|
||||
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||
Payload = table.Column<string>(type: "text", nullable: false, comment: "สิงที่แนบมาด้วย")
|
||||
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||
IsOpen = table.Column<bool>(type: "tinyint(1)", nullable: false, comment: "เปิดอ่านแล้วหรือยัง"),
|
||||
ReceiveDate = table.Column<DateTime>(type: "datetime(6)", nullable: false, comment: "วันที่ได้รับ"),
|
||||
OpenDate = table.Column<DateTime>(type: "datetime(6)", nullable: true, comment: "วันที่เปิดอ่าน")
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Notifications", x => x.Id);
|
||||
})
|
||||
.Annotation("MySql:CharSet", "utf8mb4");
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropTable(
|
||||
name: "Inboxes");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Notifications");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -8162,6 +8162,90 @@ namespace BMA.EHR.Infrastructure.Migrations
|
|||
b.ToTable("SubDistricts");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BMA.EHR.Domain.Models.Notifications.Inbox", b =>
|
||||
{
|
||||
b.Property<Guid>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("char(36)")
|
||||
.HasColumnOrder(0)
|
||||
.HasComment("PrimaryKey")
|
||||
.HasAnnotation("Relational:JsonPropertyName", "id");
|
||||
|
||||
b.Property<string>("Body")
|
||||
.IsRequired()
|
||||
.HasColumnType("text")
|
||||
.HasComment("รายละเอียดข้อความ");
|
||||
|
||||
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<bool>("IsOpen")
|
||||
.HasColumnType("tinyint(1)")
|
||||
.HasComment("เปิดอ่านแล้วหรือยัง");
|
||||
|
||||
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<DateTime?>("OpenDate")
|
||||
.HasColumnType("datetime(6)")
|
||||
.HasComment("วันที่เปิดอ่าน");
|
||||
|
||||
b.Property<string>("Payload")
|
||||
.IsRequired()
|
||||
.HasColumnType("text")
|
||||
.HasComment("สิงที่แนบมาด้วย");
|
||||
|
||||
b.Property<DateTime>("ReceiveDate")
|
||||
.HasColumnType("datetime(6)")
|
||||
.HasComment("วันที่ได้รับ");
|
||||
|
||||
b.Property<Guid>("ReceiverUserId")
|
||||
.HasColumnType("char(36)")
|
||||
.HasComment("รหัสผู้รับข้อความ");
|
||||
|
||||
b.Property<string>("Subject")
|
||||
.IsRequired()
|
||||
.HasMaxLength(200)
|
||||
.HasColumnType("varchar(200)")
|
||||
.HasComment("หัวเรื่อง");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Inboxes");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BMA.EHR.Domain.Models.Notifications.MessageQueueEntity", b =>
|
||||
{
|
||||
b.Property<Guid>("Id")
|
||||
|
|
@ -8262,6 +8346,89 @@ namespace BMA.EHR.Infrastructure.Migrations
|
|||
b.ToTable("MessageQueues");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BMA.EHR.Domain.Models.Notifications.Notification", b =>
|
||||
{
|
||||
b.Property<Guid>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("char(36)")
|
||||
.HasColumnOrder(0)
|
||||
.HasComment("PrimaryKey")
|
||||
.HasAnnotation("Relational:JsonPropertyName", "id");
|
||||
|
||||
b.Property<string>("Body")
|
||||
.IsRequired()
|
||||
.HasColumnType("text")
|
||||
.HasComment("รายละเอียดข้อความ");
|
||||
|
||||
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<bool>("IsOpen")
|
||||
.HasColumnType("tinyint(1)")
|
||||
.HasComment("เปิดอ่านแล้วหรือยัง");
|
||||
|
||||
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<DateTime?>("OpenDate")
|
||||
.HasColumnType("datetime(6)")
|
||||
.HasComment("วันที่เปิดอ่าน");
|
||||
|
||||
b.Property<string>("Payload")
|
||||
.IsRequired()
|
||||
.HasColumnType("text")
|
||||
.HasComment("สิงที่แนบมาด้วย");
|
||||
|
||||
b.Property<DateTime>("ReceiveDate")
|
||||
.HasColumnType("datetime(6)")
|
||||
.HasComment("วันที่ได้รับ");
|
||||
|
||||
b.Property<Guid>("ReceiverUserId")
|
||||
.HasColumnType("char(36)")
|
||||
.HasComment("รหัสผู้รับข้อความ");
|
||||
|
||||
b.Property<string>("Type")
|
||||
.IsRequired()
|
||||
.HasColumnType("longtext")
|
||||
.HasComment("ประเภทการแจ้งเตือน");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Notifications");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BMA.EHR.Domain.Models.OrganizationEmployee.OrgEmployee", b =>
|
||||
{
|
||||
b.Property<Guid>("Id")
|
||||
|
|
|
|||
|
|
@ -287,6 +287,10 @@ namespace BMA.EHR.Infrastructure.Persistence
|
|||
|
||||
public DbSet<MessageQueueEntity> MessageQueues { get; set; }
|
||||
|
||||
public DbSet<Inbox> Inboxes { get; set; }
|
||||
|
||||
public DbSet<Notification> Notifications { get; set; }
|
||||
|
||||
#endregion
|
||||
|
||||
#region " Insignia "
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue