ระบบลาออกเพิ่มstepยับยั้ง

This commit is contained in:
DESKTOP-2S5P7D1\Windows 10 2023-08-29 11:47:01 +07:00
parent 069ee389e0
commit 27724dffb5
3 changed files with 146 additions and 0 deletions

View file

@ -214,6 +214,12 @@ namespace BMA.EHR.Retirement.Service.Controllers
p.PositionLevelOld,
p.PositionNumberOld,
p.OrganizationPositionOld,
p.OligarchReject,
p.OligarchRejectReason,
p.OligarchRejectDate,
p.CommanderReject,
p.CommanderRejectReason,
p.CommanderRejectDate,
RetirementResignDocs = p.RetirementResignDocs.Where(d => d.Document != null).Select(d => new { d.Document.Id, d.Document.FileName }),
})
.FirstOrDefaultAsync();
@ -252,6 +258,12 @@ namespace BMA.EHR.Retirement.Service.Controllers
data.RejectReason,
data.IsActive,
data.CreatedAt,
data.OligarchReject,
data.OligarchRejectReason,
data.OligarchRejectDate,
data.CommanderReject,
data.CommanderRejectReason,
data.CommanderRejectDate,
Docs = retirementResignDocs,
};
@ -453,6 +465,116 @@ namespace BMA.EHR.Retirement.Service.Controllers
return Success();
}
/// <summary>
/// ผู้บังคับบัญชา อนุมัติคำลาออก
/// </summary>
/// <param name="id">Id คำลาออก</param>
/// <returns></returns>
/// <response code="200"></response>
/// <response code="400">ค่าตัวแปรที่ส่งมาไม่ถูกต้อง</response>
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
[HttpPut("commander/confirm/{id:length(36)}")]
public async Task<ActionResult<ResponseObject>> AdminConfirm([FromBody] RetirementReasonDateRequest req, Guid id)
{
var updated = await _context.RetirementResigns
.FirstOrDefaultAsync(x => x.Id == id);
if (updated == null)
return Error(GlobalMessages.RetirementResignNotFound, 404);
// updated.Status = "APPROVE";
updated.CommanderReject = false;
updated.LastUpdateFullName = FullName ?? "System Administrator";
updated.LastUpdateUserId = UserId ?? "";
updated.LastUpdatedAt = DateTime.Now;
await _context.SaveChangesAsync();
return Success();
}
/// <summary>
/// ผู้บังคับบัญชา ไม่อนุมัติคำลาออก
/// </summary>
/// <param name="id">Id คำลาออก</param>
/// <returns></returns>
/// <response code="200"></response>
/// <response code="400">ค่าตัวแปรที่ส่งมาไม่ถูกต้อง</response>
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
[HttpPut("commander/reject/{id:length(36)}")]
public async Task<ActionResult<ResponseObject>> AdminReject([FromBody] RetirementReasonDateRequest req, Guid id)
{
var updated = await _context.RetirementResigns
.FirstOrDefaultAsync(x => x.Id == id);
if (updated == null)
return Error(GlobalMessages.RetirementResignNotFound, 404);
// updated.Status = "REJECT";
updated.CommanderReject = true;
updated.CommanderRejectReason = req.Reason;
updated.CommanderRejectDate = req.Date;
updated.LastUpdateFullName = FullName ?? "System Administrator";
updated.LastUpdateUserId = UserId ?? "";
updated.LastUpdatedAt = DateTime.Now;
await _context.SaveChangesAsync();
return Success();
}
/// <summary>
/// ผู้มีอำนาจ อนุมัติคำลาออก
/// </summary>
/// <param name="id">Id คำลาออก</param>
/// <returns></returns>
/// <response code="200"></response>
/// <response code="400">ค่าตัวแปรที่ส่งมาไม่ถูกต้อง</response>
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
[HttpPut("oligarch/confirm/{id:length(36)}")]
public async Task<ActionResult<ResponseObject>> AdminConfirm([FromBody] RetirementReasonDateRequest req, Guid id)
{
var updated = await _context.RetirementResigns
.FirstOrDefaultAsync(x => x.Id == id);
if (updated == null)
return Error(GlobalMessages.RetirementResignNotFound, 404);
// updated.Status = "APPROVE";
updated.OligarchReject = false;
updated.LastUpdateFullName = FullName ?? "System Administrator";
updated.LastUpdateUserId = UserId ?? "";
updated.LastUpdatedAt = DateTime.Now;
await _context.SaveChangesAsync();
return Success();
}
/// <summary>
/// ผู้มีอำนาจ ไม่อนุมัติคำลาออก
/// </summary>
/// <param name="id">Id คำลาออก</param>
/// <returns></returns>
/// <response code="200"></response>
/// <response code="400">ค่าตัวแปรที่ส่งมาไม่ถูกต้อง</response>
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
[HttpPut("oligarch/reject/{id:length(36)}")]
public async Task<ActionResult<ResponseObject>> AdminReject([FromBody] RetirementReasonDateRequest req, Guid id)
{
var updated = await _context.RetirementResigns
.FirstOrDefaultAsync(x => x.Id == id);
if (updated == null)
return Error(GlobalMessages.RetirementResignNotFound, 404);
// updated.Status = "REJECT";
updated.OligarchReject = true;
updated.OligarchRejectReason = req.Reason;
updated.OligarchRejectDate = req.Date;
updated.LastUpdateFullName = FullName ?? "System Administrator";
updated.LastUpdateUserId = UserId ?? "";
updated.LastUpdatedAt = DateTime.Now;
await _context.SaveChangesAsync();
return Success();
}
/// <summary>
/// สั่งรายชื่อไปออกคำสั่ง