retire add approve
This commit is contained in:
parent
8ce58201e9
commit
2b8713cbe0
19 changed files with 22944 additions and 43 deletions
|
|
@ -264,6 +264,7 @@ namespace BMA.EHR.Retirement.Service.Controllers
|
|||
p.CancelReason,
|
||||
p.IsActive,
|
||||
p.CreatedAt,
|
||||
p.ApproveStep,
|
||||
})
|
||||
.ToListAsync();
|
||||
|
||||
|
|
@ -422,6 +423,10 @@ namespace BMA.EHR.Retirement.Service.Controllers
|
|||
p.IsNoBurden,
|
||||
p.IsDiscipline,
|
||||
p.CancelReason,
|
||||
p.ApproveStep,
|
||||
Approvers = p.Approvers.Where(x => x.ApproveType.ToUpper() == "APPROVER"),
|
||||
Commanders = p.Approvers.Where(x => x.ApproveType.ToUpper() == "COMMANDER"),
|
||||
KeycloakUserId = p.CreatedUserId,
|
||||
RetirementResignCancels = p.RetirementResignCancels.FirstOrDefault(),
|
||||
RetirementResignDocs = p.RetirementResignDocs.Where(d => d.Document != null).Select(d => new { d.Document.Id, d.Document.FileName }),
|
||||
})
|
||||
|
|
@ -501,6 +506,10 @@ namespace BMA.EHR.Retirement.Service.Controllers
|
|||
data.IsNoBurden,
|
||||
data.IsDiscipline,
|
||||
data.CancelReason,
|
||||
data.KeycloakUserId,
|
||||
data.Approvers,
|
||||
data.Commanders,
|
||||
data.ApproveStep,
|
||||
idCancel = data.RetirementResignCancels?.Id ?? null,
|
||||
statusCancel = data.RetirementResignCancels?.Status ?? null,
|
||||
statusMain = data.Status == "CANCEL" ? "DONECANCEL" : data.Status,
|
||||
|
|
@ -587,6 +596,9 @@ namespace BMA.EHR.Retirement.Service.Controllers
|
|||
p.IsNoBurden,
|
||||
p.IsDiscipline,
|
||||
p.CancelReason,
|
||||
Approvers = p.Approvers.Where(x => x.ApproveType.ToUpper() == "APPROVER"),
|
||||
Commanders = p.Approvers.Where(x => x.ApproveType.ToUpper() == "COMMANDER"),
|
||||
KeycloakUserId = p.CreatedUserId,
|
||||
idMain = p.RetirementResign.Id,
|
||||
statusMain = p.RetirementResign.Status,
|
||||
RetirementResignDocs = p.RetirementResign.RetirementResignDocs.Where(d => d.Document != null).Select(d => new { d.Document.Id, d.Document.FileName }),
|
||||
|
|
@ -669,6 +681,9 @@ namespace BMA.EHR.Retirement.Service.Controllers
|
|||
data.CancelReason,
|
||||
data.idMain,
|
||||
data.statusMain,
|
||||
data.KeycloakUserId,
|
||||
data.Approvers,
|
||||
data.Commanders,
|
||||
statusCancel = data.Status,
|
||||
Docs = retirementResignDocs,
|
||||
};
|
||||
|
|
@ -2537,6 +2552,228 @@ namespace BMA.EHR.Retirement.Service.Controllers
|
|||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// เพิ่มรายชิื่อผู้อนุมัติ หรือ ผู้บังคับบัญชา
|
||||
/// </summary>
|
||||
/// <returns>
|
||||
/// </returns>
|
||||
/// <response code="200">เมื่อทำรายการสำเร็จ</response>
|
||||
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
||||
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
||||
[HttpPost("officer/add-resign/{type}/{id:guid}")]
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
||||
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||
public async Task<ActionResult<ResponseObject>> AddApprover(string type, Guid id, [FromBody] List<RetirementRequestApproverDto> req)
|
||||
{
|
||||
try
|
||||
{
|
||||
var retirement = await _context.RetirementResigns
|
||||
.Where(x => x.Id == id)
|
||||
.FirstOrDefaultAsync();
|
||||
if (retirement == null)
|
||||
{
|
||||
return Error(GlobalMessages.DataNotFound, StatusCodes.Status404NotFound);
|
||||
}
|
||||
|
||||
var data = await _context.RetirementResignApprovers
|
||||
.Where(x => x.RetirementResign.Id == id && x.ApproveType.ToUpper() == type.ToUpper())
|
||||
.ToListAsync();
|
||||
_context.RemoveRange(data);
|
||||
|
||||
await _context.SaveChangesAsync();
|
||||
|
||||
var addList = new List<RetirementResignApprover>();
|
||||
|
||||
foreach (var r in req)
|
||||
{
|
||||
addList.Add(new RetirementResignApprover
|
||||
{
|
||||
Seq = r.Seq,
|
||||
RetirementResign = retirement,
|
||||
Prefix = r.Prefix,
|
||||
FirstName = r.FirstName,
|
||||
LastName = r.LastName,
|
||||
PositionName = r.PositionName,
|
||||
ProfileId = r.ProfileId,
|
||||
KeycloakId = r.KeycloakId,
|
||||
ApproveStatus = "PENDING",
|
||||
ApproveType = type.Trim().ToUpper()
|
||||
});
|
||||
}
|
||||
await _context.AddRangeAsync(addList);
|
||||
await _context.SaveChangesAsync();
|
||||
|
||||
return Success();
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return Error(ex);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// LV2_013 - เจ้าหน้าที่อนุมัติการลา (ADMIN)
|
||||
/// </summary>
|
||||
/// <returns>
|
||||
/// </returns>
|
||||
/// <response code="200">เมื่อทำรายการสำเร็จ</response>
|
||||
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
||||
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
||||
[HttpGet("admin/approve/officer/{id:guid}")]
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
||||
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||
public async Task<ActionResult<ResponseObject>> OfficerApproveRetirementResignAsync(Guid id)
|
||||
{
|
||||
// var getPermission = await _permission.GetPermissionAPIAsync("UPDATE", "SYS_LEAVE_LIST");
|
||||
// var jsonData = JsonConvert.DeserializeObject<JObject>(getPermission);
|
||||
// if (jsonData["status"]?.ToString() != "200")
|
||||
// {
|
||||
// return Error(jsonData["message"]?.ToString(), StatusCodes.Status403Forbidden);
|
||||
// }
|
||||
await _repository.OfficerApproveRetirementResign(id);
|
||||
|
||||
return Success();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// LV2_015 - ผู้บังคับบัญชาอนุมัติการลา(ADMIN)
|
||||
/// </summary>
|
||||
/// <returns>
|
||||
/// </returns>
|
||||
/// <response code="200">เมื่อทำรายการสำเร็จ</response>
|
||||
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
||||
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
||||
[HttpPut("admin/approve/comander/{id:guid}")]
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
||||
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||
public async Task<ActionResult<ResponseObject>> CommanderApproveRetirementResignAsync(Guid id,
|
||||
[FromBody] RetirementRequestApproveDto req)
|
||||
{
|
||||
try
|
||||
{
|
||||
// var getPermission = await _permission.GetPermissionAPIAsync("UPDATE", "SYS_LEAVE_LIST");
|
||||
// var jsonData = JsonConvert.DeserializeObject<JObject>(getPermission);
|
||||
// if (jsonData["status"]?.ToString() != "200")
|
||||
// {
|
||||
// return Error(jsonData["message"]?.ToString(), StatusCodes.Status403Forbidden);
|
||||
// }
|
||||
await _repository.CommanderApproveRetirementResign(id, req.Reason ?? "");
|
||||
|
||||
return Success();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return Error(ex);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// ผู้บังคับบัญชาไม่อนุมัติการลา(ADMIN)
|
||||
/// </summary>
|
||||
/// <returns>
|
||||
/// </returns>
|
||||
/// <response code="200">เมื่อทำรายการสำเร็จ</response>
|
||||
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
||||
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
||||
[HttpPut("admin/reject/comander/{id:guid}")]
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
||||
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||
public async Task<ActionResult<ResponseObject>> CommanderRejectRetirementResignAsync(Guid id,
|
||||
[FromBody] RetirementRequestApproveDto req)
|
||||
{
|
||||
try
|
||||
{
|
||||
// var getPermission = await _permission.GetPermissionAPIAsync("UPDATE", "SYS_LEAVE_LIST");
|
||||
// var jsonData = JsonConvert.DeserializeObject<JObject>(getPermission);
|
||||
// if (jsonData["status"]?.ToString() != "200")
|
||||
// {
|
||||
// return Error(jsonData["message"]?.ToString(), StatusCodes.Status403Forbidden);
|
||||
// }
|
||||
await _repository.CommanderRejectRetirementResign(id, req.Reason ?? "");
|
||||
|
||||
return Success();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return Error(ex);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// LV2_016 - ผู้มีอำนาจอนุมัติการลา (ADMIN)
|
||||
/// </summary>
|
||||
/// <returns>
|
||||
/// </returns>
|
||||
/// <response code="200">เมื่อทำรายการสำเร็จ</response>
|
||||
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
||||
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
||||
[HttpPut("admin/approve/{id:guid}")]
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
||||
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||
public async Task<ActionResult<ResponseObject>> ApproveRetirementResignAsync(Guid id,
|
||||
[FromBody] RetirementRequestApproveDto req)
|
||||
{
|
||||
try
|
||||
{
|
||||
// var getPermission = await _permission.GetPermissionAPIAsync("UPDATE", "SYS_LEAVE_LIST");
|
||||
// var jsonData = JsonConvert.DeserializeObject<JObject>(getPermission);
|
||||
// if (jsonData["status"]?.ToString() != "200")
|
||||
// {
|
||||
// return Error(jsonData["message"]?.ToString(), StatusCodes.Status403Forbidden);
|
||||
// }
|
||||
await _repository.ApproveRetirementResign(id, req.Reason ?? "");
|
||||
|
||||
return Success();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return Error(ex);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// LV2_017 - ผู้มีอำนาจไม่อนุมัติการลา (ADMIN)
|
||||
/// </summary>
|
||||
/// <returns>
|
||||
/// </returns>
|
||||
/// <response code="200">เมื่อทำรายการสำเร็จ</response>
|
||||
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
||||
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
||||
[HttpPut("admin/reject/{id:guid}")]
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
||||
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||
public async Task<ActionResult<ResponseObject>> RejectRetirementResignAsync(Guid id,
|
||||
[FromBody] RetirementRequestApproveDto req)
|
||||
{
|
||||
try
|
||||
{
|
||||
// var getPermission = await _permission.GetPermissionAPIAsync("UPDATE", "SYS_LEAVE_LIST");
|
||||
// var jsonData = JsonConvert.DeserializeObject<JObject>(getPermission);
|
||||
// if (jsonData["status"]?.ToString() != "200")
|
||||
// {
|
||||
// return Error(jsonData["message"]?.ToString(), StatusCodes.Status403Forbidden);
|
||||
// }
|
||||
await _repository.RejectRetirementResign(id, req.Reason ?? "");
|
||||
|
||||
return Success();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return Error(ex);
|
||||
}
|
||||
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue