api ใบประกอบวิชาชีพ
This commit is contained in:
parent
e4fa2ff1c1
commit
0a626fb393
8 changed files with 104 additions and 55 deletions
|
|
@ -1,30 +0,0 @@
|
||||||
using Microsoft.EntityFrameworkCore;
|
|
||||||
using System.ComponentModel.DataAnnotations;
|
|
||||||
using BMA.EHR.Domain.Models.Base;
|
|
||||||
|
|
||||||
namespace BMA.EHR.Domain.Models.Placement
|
|
||||||
{
|
|
||||||
public class PlacementCareer : EntityBase
|
|
||||||
{
|
|
||||||
[Required, Comment("Id ผู้สมัคร")]
|
|
||||||
public virtual PlacementProfile? PlacementProfile { get; set; }
|
|
||||||
|
|
||||||
[Required, Comment("ระยะเวลาเริ่ม")]
|
|
||||||
public DateTime DurationStart { get; set; } = DateTime.Now.Date;
|
|
||||||
|
|
||||||
[Required, Comment("ระยะเวลาสิ้นสุด")]
|
|
||||||
public DateTime DurationEnd { get; set; } = DateTime.Now.Date;
|
|
||||||
|
|
||||||
[Required, Comment("สถานที่ทำงาน/ฝึกงาน")]
|
|
||||||
public string Name { get; set; } = string.Empty;
|
|
||||||
|
|
||||||
[Required, Comment("ตำแหน่ง/ลักษณะงาน")]
|
|
||||||
public string Position { get; set; } = string.Empty;
|
|
||||||
|
|
||||||
[Required, MaxLength(20), Comment("เงินเดือนสุดท้ายก่อนออก")]
|
|
||||||
public int Salary { get; set; }
|
|
||||||
|
|
||||||
[Required, Comment("เหตุผลที่ออก")]
|
|
||||||
public string Reason { get; set; } = string.Empty;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
22
BMA.EHR.Domain/Models/Placement/PlacementCertificate.cs
Normal file
22
BMA.EHR.Domain/Models/Placement/PlacementCertificate.cs
Normal file
|
|
@ -0,0 +1,22 @@
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
using BMA.EHR.Domain.Models.Base;
|
||||||
|
|
||||||
|
namespace BMA.EHR.Domain.Models.Placement
|
||||||
|
{
|
||||||
|
public class PlacementCertificate : EntityBase
|
||||||
|
{
|
||||||
|
[Required, Comment("Id ผู้สมัคร")]
|
||||||
|
public virtual PlacementProfile? PlacementProfile { get; set; }
|
||||||
|
[MaxLength(20), Comment("เลขที่ใบอนุญาต")]
|
||||||
|
public string? CertificateNo { get; set; }
|
||||||
|
[MaxLength(200), Comment("หน่วยงานผู้ออกใบอนุญาต")]
|
||||||
|
public string? Issuer { get; set; }
|
||||||
|
[Comment("วันที่ออกใบอนุญาต")]
|
||||||
|
public DateTime? IssueDate { get; set; }
|
||||||
|
[Comment("วันที่หมดอายุ")]
|
||||||
|
public DateTime? ExpireDate { get; set; }
|
||||||
|
[MaxLength(100), Comment("ชื่อใบอนุญาต")]
|
||||||
|
public string? CertificateType { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -236,7 +236,7 @@ namespace BMA.EHR.Domain.Models.Placement
|
||||||
|
|
||||||
[Comment("ผลสมัครสอบ")]
|
[Comment("ผลสมัครสอบ")]
|
||||||
public string? Pass { get; set; }
|
public string? Pass { get; set; }
|
||||||
public virtual List<PlacementCareer> PlacementCareers { get; set; } = new List<PlacementCareer>();
|
public virtual List<PlacementCertificate> PlacementCertificates { get; set; } = new List<PlacementCertificate>();
|
||||||
public virtual List<PlacementEducation> PlacementEducations { get; set; } = new List<PlacementEducation>();
|
public virtual List<PlacementEducation> PlacementEducations { get; set; } = new List<PlacementEducation>();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -54,5 +54,9 @@
|
||||||
public static readonly string PositionEmployeePositionSideNotFound = "ไม่พบข้อมูลด้านของตำแหน่ง";
|
public static readonly string PositionEmployeePositionSideNotFound = "ไม่พบข้อมูลด้านของตำแหน่ง";
|
||||||
public static readonly string PositionEmployeePositionNotFound = "ไม่พบข้อมูลตำแหน่ง";
|
public static readonly string PositionEmployeePositionNotFound = "ไม่พบข้อมูลตำแหน่ง";
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
#region " Placement "
|
||||||
|
public static readonly string CertificateNotFound = "ไม่พบข้อมูลใบประกอบอาชีพ";
|
||||||
|
#endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -239,7 +239,7 @@ namespace BMA.EHR.Infrastructure.Persistence
|
||||||
#region " Placements "
|
#region " Placements "
|
||||||
|
|
||||||
public DbSet<Placement> Placements { get; set; }
|
public DbSet<Placement> Placements { get; set; }
|
||||||
public DbSet<PlacementCareer> PlacementCareers { get; set; }
|
public DbSet<PlacementCertificate> PlacementCertificates { get; set; }
|
||||||
public DbSet<PlacementEducation> PlacementEducations { get; set; }
|
public DbSet<PlacementEducation> PlacementEducations { get; set; }
|
||||||
public DbSet<PlacementIsProperty> PlacementIsProperties { get; set; }
|
public DbSet<PlacementIsProperty> PlacementIsProperties { get; set; }
|
||||||
public DbSet<PlacementProfile> PlacementProfiles { get; set; }
|
public DbSet<PlacementProfile> PlacementProfiles { get; set; }
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
using BMA.EHR.Application.Repositories;
|
using BMA.EHR.Application.Repositories;
|
||||||
using BMA.EHR.Domain.Common;
|
using BMA.EHR.Domain.Common;
|
||||||
|
using BMA.EHR.Domain.Models.Placement;
|
||||||
using BMA.EHR.Domain.Shared;
|
using BMA.EHR.Domain.Shared;
|
||||||
using BMA.EHR.Infrastructure.Persistence;
|
using BMA.EHR.Infrastructure.Persistence;
|
||||||
using BMA.EHR.Placement.Service.Requests;
|
using BMA.EHR.Placement.Service.Requests;
|
||||||
|
|
@ -541,16 +542,64 @@ namespace BMA.EHR.Placement.Service.Controllers
|
||||||
return Success();
|
return Success();
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpGet("certificate/{personalId:length(36)}")]
|
[HttpPut("certificate/{personalId:length(36)}")]
|
||||||
public async Task<ActionResult<ResponseObject>> UpdateCertificate([FromBody] PersonCertificateRequest req, Guid personalId)
|
public async Task<ActionResult<ResponseObject>> UpdateCertificate([FromBody] PersonCertificateRequest req, Guid personalId)
|
||||||
{
|
{
|
||||||
var person = await _context.PlacementProfiles.FindAsync(personalId);
|
var person = await _context.PlacementProfiles
|
||||||
|
.Include(x => x.PlacementCertificates)
|
||||||
|
.FirstOrDefaultAsync(x => x.Id == personalId);
|
||||||
if (person == null)
|
if (person == null)
|
||||||
return Error(GlobalMessages.DataNotFound, 404);
|
return Error(GlobalMessages.DataNotFound, 404);
|
||||||
|
|
||||||
person.LastUpdateFullName = FullName ?? "System Administrator";
|
if (req.Id == null)
|
||||||
person.LastUpdateUserId = UserId ?? "";
|
{
|
||||||
person.LastUpdatedAt = DateTime.Now;
|
var data = new PlacementCertificate
|
||||||
|
{
|
||||||
|
PlacementProfile = person,
|
||||||
|
CertificateNo = req.CertificateNo,
|
||||||
|
Issuer = req.Issuer,
|
||||||
|
IssueDate = req.IssueDate,
|
||||||
|
ExpireDate = req.ExpireDate,
|
||||||
|
CertificateType = req.CertificateType,
|
||||||
|
CreatedUserId = FullName ?? "",
|
||||||
|
CreatedFullName = UserId ?? "System Administrator",
|
||||||
|
CreatedAt = DateTime.Now,
|
||||||
|
LastUpdateFullName = FullName ?? "System Administrator",
|
||||||
|
LastUpdateUserId = UserId ?? "",
|
||||||
|
LastUpdatedAt = DateTime.Now,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
var certificate = person.PlacementCertificates.FirstOrDefault(x => x.Id == req.Id);
|
||||||
|
if (certificate == null)
|
||||||
|
return Error(GlobalMessages.CertificateNotFound, 404);
|
||||||
|
certificate.CertificateNo = req.CertificateNo;
|
||||||
|
certificate.Issuer = req.Issuer;
|
||||||
|
certificate.IssueDate = req.IssueDate;
|
||||||
|
certificate.ExpireDate = req.ExpireDate;
|
||||||
|
certificate.CertificateType = req.CertificateType;
|
||||||
|
certificate.LastUpdateFullName = FullName ?? "System Administrator";
|
||||||
|
certificate.LastUpdateUserId = UserId ?? "";
|
||||||
|
certificate.LastUpdatedAt = DateTime.Now;
|
||||||
|
}
|
||||||
|
_context.SaveChanges();
|
||||||
|
|
||||||
|
return Success();
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpDelete("certificate/{personalId:length(36)}/{certificateId:length(36)}")]
|
||||||
|
public async Task<ActionResult<ResponseObject>> DeleteCertificate(Guid personalId, Guid certificateId)
|
||||||
|
{
|
||||||
|
var person = await _context.PlacementProfiles
|
||||||
|
.Include(x => x.PlacementCertificates)
|
||||||
|
.FirstOrDefaultAsync(x => x.Id == personalId);
|
||||||
|
if (person == null)
|
||||||
|
return Error(GlobalMessages.DataNotFound, 404);
|
||||||
|
var certificate = person.PlacementCertificates.FirstOrDefault(x => x.Id == certificateId);
|
||||||
|
if (certificate == null)
|
||||||
|
return Error(GlobalMessages.CertificateNotFound, 404);
|
||||||
|
_context.PlacementCertificates.Remove(certificate);
|
||||||
_context.SaveChanges();
|
_context.SaveChanges();
|
||||||
|
|
||||||
return Success();
|
return Success();
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,11 @@ namespace BMA.EHR.Placement.Service.Requests
|
||||||
{
|
{
|
||||||
public class PersonCertificateRequest
|
public class PersonCertificateRequest
|
||||||
{
|
{
|
||||||
public string Name { get; set; }
|
public Guid? Id { get; set; }
|
||||||
public bool Value { get; set; }
|
public string? CertificateNo { get; set; }
|
||||||
|
public string? Issuer { get; set; }
|
||||||
|
public DateTime? IssueDate { get; set; }
|
||||||
|
public DateTime? ExpireDate { get; set; }
|
||||||
|
public string? CertificateType { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -11,31 +11,31 @@ namespace BMA.EHR.Placement.Service.Requests
|
||||||
public string? CoupleLastName { get; set; }
|
public string? CoupleLastName { get; set; }
|
||||||
public string? CoupleLastNameOld { get; set; }
|
public string? CoupleLastNameOld { get; set; }
|
||||||
public string? CoupleCareer { get; set; }
|
public string? CoupleCareer { get; set; }
|
||||||
public string? CoupleCitizenId { get; set; }
|
// public string? CoupleCitizenId { get; set; }
|
||||||
public bool CoupleLive { get; set; }
|
// public bool CoupleLive { get; set; }
|
||||||
|
|
||||||
public Guid? FatherPrefixId { get; set; }
|
public Guid? FatherPrefixId { get; set; }
|
||||||
public string? FatherFirstName { get; set; }
|
public string? FatherFirstName { get; set; }
|
||||||
public string? FatherLastName { get; set; }
|
public string? FatherLastName { get; set; }
|
||||||
public string? FatherCareer { get; set; }
|
public string? FatherCareer { get; set; }
|
||||||
public string? FatherCitizenId { get; set; }
|
// public string? FatherCitizenId { get; set; }
|
||||||
public bool FatherLive { get; set; }
|
// public bool FatherLive { get; set; }
|
||||||
|
|
||||||
public Guid? MotherPrefixId { get; set; }
|
public Guid? MotherPrefixId { get; set; }
|
||||||
public string? MotherFirstName { get; set; }
|
public string? MotherFirstName { get; set; }
|
||||||
public string? MotherLastName { get; set; }
|
public string? MotherLastName { get; set; }
|
||||||
public string? MotherCareer { get; set; }
|
public string? MotherCareer { get; set; }
|
||||||
public string? MotherCitizenId { get; set; }
|
// public string? MotherCitizenId { get; set; }
|
||||||
public bool MotherLive { get; set; }
|
// public bool MotherLive { get; set; }
|
||||||
public virtual List<ProfileChildrenRequest> Childrens { get; set; } = new List<ProfileChildrenRequest>();
|
// public virtual List<ProfileChildrenRequest> Childrens { get; set; } = new List<ProfileChildrenRequest>();
|
||||||
}
|
|
||||||
public class ProfileChildrenRequest
|
|
||||||
{
|
|
||||||
public Guid? ChildrenPrefixId { get; set; }
|
|
||||||
public string? ChildrenFirstName { get; set; }
|
|
||||||
public string? ChildrenLastName { get; set; }
|
|
||||||
public string? ChildrenCareer { get; set; }
|
|
||||||
public string? ChildrenCitizenId { get; set; }
|
|
||||||
public string ChildrenLive { get; set; }
|
|
||||||
}
|
}
|
||||||
|
// public class ProfileChildrenRequest
|
||||||
|
// {
|
||||||
|
// public Guid? ChildrenPrefixId { get; set; }
|
||||||
|
// public string? ChildrenFirstName { get; set; }
|
||||||
|
// public string? ChildrenLastName { get; set; }
|
||||||
|
// public string? ChildrenCareer { get; set; }
|
||||||
|
// public string? ChildrenCitizenId { get; set; }
|
||||||
|
// public string ChildrenLive { get; set; }
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue