Merge branch 'dev' into working
All checks were successful
Build & Deploy Leave Service / build (push) Successful in 1m56s
All checks were successful
Build & Deploy Leave Service / build (push) Successful in 1m56s
This commit is contained in:
commit
513956c861
8 changed files with 404 additions and 26 deletions
|
|
@ -1062,6 +1062,42 @@ namespace BMA.EHR.Application.Repositories
|
|||
}
|
||||
}
|
||||
|
||||
public async Task<List<GetProfileByKeycloakIdRootDto>> GetEmployeeByAdminRolev2(string? accessToken, int? node, string? nodeId, string role, string? revisionId, int? reqNode, string? reqNodeId, DateTime? startDate, DateTime? endDate)
|
||||
{
|
||||
try
|
||||
{
|
||||
var apiPath = $"{_configuration["API"]}/org/dotnet/employee-by-admin-rolev2";
|
||||
var apiKey = _configuration["API_KEY"];
|
||||
var body = new
|
||||
{
|
||||
node = node,
|
||||
nodeId = nodeId,
|
||||
role = role,
|
||||
// isRetirement
|
||||
reqNode = reqNode,
|
||||
reqNodeId = reqNodeId,
|
||||
date = endDate
|
||||
};
|
||||
Console.WriteLine(body);
|
||||
|
||||
var profiles = new List<SearchProfileDto>();
|
||||
|
||||
var apiResult = await PostExternalAPIAsync(apiPath, accessToken, body, apiKey);
|
||||
if (apiResult != null)
|
||||
{
|
||||
var raw = JsonConvert.DeserializeObject<GetListProfileByKeycloakIdRootResultDto>(apiResult);
|
||||
if (raw != null)
|
||||
return raw.Result;
|
||||
}
|
||||
|
||||
return new List<GetProfileByKeycloakIdRootDto>();
|
||||
}
|
||||
catch
|
||||
{
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<GetProfileByKeycloakIdRootAddTotalDto> SearchProfile(string? citizenId, string? firstName, string? lastName, string accessToken, int page, int pageSize, string? role, string? nodeId, int? node,string? selectedNodeId,int? selectedNode )
|
||||
{
|
||||
try
|
||||
|
|
|
|||
|
|
@ -968,12 +968,20 @@ namespace BMA.EHR.DisciplineResult.Service.Controllers
|
|||
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
||||
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
||||
[HttpPost("command19/report")]
|
||||
public async Task<ActionResult<ResponseObject>> PostReportCommand19([FromBody] ReportPersonRequest req)
|
||||
public async Task<ActionResult<ResponseObject>> PostReportCommand19([FromBody] ReportPersonAndCommandRequest req)
|
||||
{
|
||||
var data = await _context.DisciplineDisciplinary_ProfileComplaintInvestigates
|
||||
.Where(x => req.refIds.Contains(x.Id.ToString()))
|
||||
.ToListAsync();
|
||||
data.ForEach(profile => profile.Status = req.status.Trim().ToUpper());
|
||||
// data.ForEach(profile => profile.Status = req.status.Trim().ToUpper());
|
||||
data.ForEach(profile =>
|
||||
{
|
||||
profile.Status = !string.IsNullOrEmpty(req.status)
|
||||
? req.status.Trim().ToUpper() : null;
|
||||
profile.CommandTypeId = !string.IsNullOrEmpty(req.commandTypeId) && Guid.TryParse(req.commandTypeId, out var cmdTypeId)
|
||||
? cmdTypeId : null;
|
||||
profile.CommandCode = req.commandCode ?? null;
|
||||
});
|
||||
await _context.SaveChangesAsync();
|
||||
return Success();
|
||||
}
|
||||
|
|
@ -993,7 +1001,13 @@ namespace BMA.EHR.DisciplineResult.Service.Controllers
|
|||
.Where(x => req.refIds.Contains(x.Id.ToString()))
|
||||
// .Where(x => x.Status.ToUpper() == "REPORT")
|
||||
.ToListAsync();
|
||||
data.ForEach(profile => profile.Status = "NEW");
|
||||
// data.ForEach(profile => profile.Status = "NEW");
|
||||
data.ForEach(profile =>
|
||||
{
|
||||
profile.Status = "NEW";
|
||||
profile.CommandTypeId = null;
|
||||
profile.CommandCode = null;
|
||||
});
|
||||
await _context.SaveChangesAsync();
|
||||
return Success();
|
||||
}
|
||||
|
|
@ -1110,12 +1124,20 @@ namespace BMA.EHR.DisciplineResult.Service.Controllers
|
|||
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
||||
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
||||
[HttpPost("command20/report")]
|
||||
public async Task<ActionResult<ResponseObject>> PostReportcommand20([FromBody] ReportPersonRequest req)
|
||||
public async Task<ActionResult<ResponseObject>> PostReportcommand20([FromBody] ReportPersonAndCommandRequest req)
|
||||
{
|
||||
var data = await _context.DisciplineDisciplinary_ProfileComplaintInvestigates
|
||||
.Where(x => req.refIds.Contains(x.Id.ToString()))
|
||||
.ToListAsync();
|
||||
data.ForEach(profile => profile.Status = req.status.Trim().ToUpper());
|
||||
// data.ForEach(profile => profile.Status = req.status.Trim().ToUpper());
|
||||
data.ForEach(profile =>
|
||||
{
|
||||
profile.Status = !string.IsNullOrEmpty(req.status)
|
||||
? req.status.Trim().ToUpper() : null;
|
||||
profile.CommandTypeId = !string.IsNullOrEmpty(req.commandTypeId) && Guid.TryParse(req.commandTypeId, out var cmdTypeId)
|
||||
? cmdTypeId : null;
|
||||
profile.CommandCode = req.commandCode ?? null;
|
||||
});
|
||||
await _context.SaveChangesAsync();
|
||||
return Success();
|
||||
}
|
||||
|
|
@ -1135,7 +1157,13 @@ namespace BMA.EHR.DisciplineResult.Service.Controllers
|
|||
.Where(x => req.refIds.Contains(x.Id.ToString()))
|
||||
// .Where(x => x.Status.ToUpper() == "REPORT")
|
||||
.ToListAsync();
|
||||
data.ForEach(profile => profile.Status = "NEW");
|
||||
// data.ForEach(profile => profile.Status = "NEW");
|
||||
data.ForEach(profile =>
|
||||
{
|
||||
profile.Status = "NEW";
|
||||
profile.CommandTypeId = null;
|
||||
profile.CommandCode = null;
|
||||
});
|
||||
await _context.SaveChangesAsync();
|
||||
return Success();
|
||||
}
|
||||
|
|
@ -1602,14 +1630,22 @@ namespace BMA.EHR.DisciplineResult.Service.Controllers
|
|||
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
||||
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
||||
[HttpPost("command27/report")]
|
||||
public async Task<ActionResult<ResponseObject>> PostReportCommand27([FromBody] ReportPersonRequest req)
|
||||
public async Task<ActionResult<ResponseObject>> PostReportCommand27([FromBody] ReportPersonAndCommandRequest req)
|
||||
{
|
||||
try
|
||||
{
|
||||
var data = await _context.DisciplineDisciplinary_ProfileComplaintInvestigates
|
||||
.Where(x => req.refIds.Contains(x.Id.ToString()))
|
||||
.ToListAsync();
|
||||
data.ForEach(profile => profile.Status = req.status.Trim().ToUpper());
|
||||
// data.ForEach(profile => profile.Status = req.status.Trim().ToUpper());
|
||||
data.ForEach(profile =>
|
||||
{
|
||||
profile.Status = !string.IsNullOrEmpty(req.status)
|
||||
? req.status.Trim().ToUpper() : null;
|
||||
profile.CommandTypeId = !string.IsNullOrEmpty(req.commandTypeId) && Guid.TryParse(req.commandTypeId, out var cmdTypeId)
|
||||
? cmdTypeId : null;
|
||||
profile.CommandCode = req.commandCode ?? null;
|
||||
});
|
||||
await _context.SaveChangesAsync();
|
||||
return Success();
|
||||
}
|
||||
|
|
@ -1636,7 +1672,13 @@ namespace BMA.EHR.DisciplineResult.Service.Controllers
|
|||
.Where(x => req.refIds.Contains(x.Id.ToString()))
|
||||
// .Where(x => x.Status.ToUpper() == "REPORT")
|
||||
.ToListAsync();
|
||||
data.ForEach(profile => profile.Status = "NEW");
|
||||
// data.ForEach(profile => profile.Status = "NEW");
|
||||
data.ForEach(profile =>
|
||||
{
|
||||
profile.Status = "NEW";
|
||||
profile.CommandTypeId = null;
|
||||
profile.CommandCode = null;
|
||||
});
|
||||
await _context.SaveChangesAsync();
|
||||
return Success();
|
||||
}
|
||||
|
|
@ -1730,14 +1772,22 @@ namespace BMA.EHR.DisciplineResult.Service.Controllers
|
|||
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
||||
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
||||
[HttpPost("command28/report")]
|
||||
public async Task<ActionResult<ResponseObject>> PostReportCommand28([FromBody] ReportPersonRequest req)
|
||||
public async Task<ActionResult<ResponseObject>> PostReportCommand28([FromBody] ReportPersonAndCommandRequest req)
|
||||
{
|
||||
try
|
||||
{
|
||||
var data = await _context.DisciplineDisciplinary_ProfileComplaintInvestigates
|
||||
.Where(x => req.refIds.Contains(x.Id.ToString()))
|
||||
.ToListAsync();
|
||||
data.ForEach(profile => profile.Status = req.status.Trim().ToUpper());
|
||||
// data.ForEach(profile => profile.Status = req.status.Trim().ToUpper());
|
||||
data.ForEach(profile =>
|
||||
{
|
||||
profile.Status = !string.IsNullOrEmpty(req.status)
|
||||
? req.status.Trim().ToUpper() : null;
|
||||
profile.CommandTypeId = !string.IsNullOrEmpty(req.commandTypeId) && Guid.TryParse(req.commandTypeId, out var cmdTypeId)
|
||||
? cmdTypeId : null;
|
||||
profile.CommandCode = req.commandCode ?? null;
|
||||
});
|
||||
await _context.SaveChangesAsync();
|
||||
return Success();
|
||||
}
|
||||
|
|
@ -1764,7 +1814,13 @@ namespace BMA.EHR.DisciplineResult.Service.Controllers
|
|||
.Where(x => req.refIds.Contains(x.Id.ToString()))
|
||||
// .Where(x => x.Status.ToUpper() == "REPORT")
|
||||
.ToListAsync();
|
||||
data.ForEach(profile => profile.Status = "NEW");
|
||||
// data.ForEach(profile => profile.Status = "NEW");
|
||||
data.ForEach(profile =>
|
||||
{
|
||||
profile.Status = "NEW";
|
||||
profile.CommandTypeId = null;
|
||||
profile.CommandCode = null;
|
||||
});
|
||||
await _context.SaveChangesAsync();
|
||||
return Success();
|
||||
}
|
||||
|
|
@ -1858,14 +1914,22 @@ namespace BMA.EHR.DisciplineResult.Service.Controllers
|
|||
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
||||
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
||||
[HttpPost("command29/report")]
|
||||
public async Task<ActionResult<ResponseObject>> PostReportCommand29([FromBody] ReportPersonRequest req)
|
||||
public async Task<ActionResult<ResponseObject>> PostReportCommand29([FromBody] ReportPersonAndCommandRequest req)
|
||||
{
|
||||
try
|
||||
{
|
||||
var data = await _context.DisciplineDisciplinary_ProfileComplaintInvestigates
|
||||
.Where(x => req.refIds.Contains(x.Id.ToString()))
|
||||
.ToListAsync();
|
||||
data.ForEach(profile => profile.Status = req.status.Trim().ToUpper());
|
||||
// data.ForEach(profile => profile.Status = req.status.Trim().ToUpper());
|
||||
data.ForEach(profile =>
|
||||
{
|
||||
profile.Status = !string.IsNullOrEmpty(req.status)
|
||||
? req.status.Trim().ToUpper() : null;
|
||||
profile.CommandTypeId = !string.IsNullOrEmpty(req.commandTypeId) && Guid.TryParse(req.commandTypeId, out var cmdTypeId)
|
||||
? cmdTypeId : null;
|
||||
profile.CommandCode = req.commandCode ?? null;
|
||||
});
|
||||
await _context.SaveChangesAsync();
|
||||
return Success();
|
||||
}
|
||||
|
|
@ -1892,7 +1956,13 @@ namespace BMA.EHR.DisciplineResult.Service.Controllers
|
|||
.Where(x => req.refIds.Contains(x.Id.ToString()))
|
||||
// .Where(x => x.Status.ToUpper() == "REPORT")
|
||||
.ToListAsync();
|
||||
data.ForEach(profile => profile.Status = "NEW");
|
||||
// data.ForEach(profile => profile.Status = "NEW");
|
||||
data.ForEach(profile =>
|
||||
{
|
||||
profile.Status = "NEW";
|
||||
profile.CommandTypeId = null;
|
||||
profile.CommandCode = null;
|
||||
});
|
||||
await _context.SaveChangesAsync();
|
||||
return Success();
|
||||
}
|
||||
|
|
@ -1986,14 +2056,22 @@ namespace BMA.EHR.DisciplineResult.Service.Controllers
|
|||
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
||||
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
||||
[HttpPost("command30/report")]
|
||||
public async Task<ActionResult<ResponseObject>> PostReportCommand30([FromBody] ReportPersonRequest req)
|
||||
public async Task<ActionResult<ResponseObject>> PostReportCommand30([FromBody] ReportPersonAndCommandRequest req)
|
||||
{
|
||||
try
|
||||
{
|
||||
var data = await _context.DisciplineDisciplinary_ProfileComplaintInvestigates
|
||||
.Where(x => req.refIds.Contains(x.Id.ToString()))
|
||||
.ToListAsync();
|
||||
data.ForEach(profile => profile.Status = req.status.Trim().ToUpper());
|
||||
// data.ForEach(profile => profile.Status = req.status.Trim().ToUpper());
|
||||
data.ForEach(profile =>
|
||||
{
|
||||
profile.Status = !string.IsNullOrEmpty(req.status)
|
||||
? req.status.Trim().ToUpper() : null;
|
||||
profile.CommandTypeId = !string.IsNullOrEmpty(req.commandTypeId) && Guid.TryParse(req.commandTypeId, out var cmdTypeId)
|
||||
? cmdTypeId : null;
|
||||
profile.CommandCode = req.commandCode ?? null;
|
||||
});
|
||||
await _context.SaveChangesAsync();
|
||||
return Success();
|
||||
}
|
||||
|
|
@ -2020,7 +2098,13 @@ namespace BMA.EHR.DisciplineResult.Service.Controllers
|
|||
.Where(x => req.refIds.Contains(x.Id.ToString()))
|
||||
// .Where(x => x.Status.ToUpper() == "REPORT")
|
||||
.ToListAsync();
|
||||
data.ForEach(profile => profile.Status = "NEW");
|
||||
// data.ForEach(profile => profile.Status = "NEW");
|
||||
data.ForEach(profile =>
|
||||
{
|
||||
profile.Status = "NEW";
|
||||
profile.CommandTypeId = null;
|
||||
profile.CommandCode = null;
|
||||
});
|
||||
await _context.SaveChangesAsync();
|
||||
return Success();
|
||||
}
|
||||
|
|
@ -2114,14 +2198,22 @@ namespace BMA.EHR.DisciplineResult.Service.Controllers
|
|||
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
||||
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
||||
[HttpPost("command31/report")]
|
||||
public async Task<ActionResult<ResponseObject>> PostReportCommand31([FromBody] ReportPersonRequest req)
|
||||
public async Task<ActionResult<ResponseObject>> PostReportCommand31([FromBody] ReportPersonAndCommandRequest req)
|
||||
{
|
||||
try
|
||||
{
|
||||
var data = await _context.DisciplineDisciplinary_ProfileComplaintInvestigates
|
||||
.Where(x => req.refIds.Contains(x.Id.ToString()))
|
||||
.ToListAsync();
|
||||
data.ForEach(profile => profile.Status = req.status.Trim().ToUpper());
|
||||
// data.ForEach(profile => profile.Status = req.status.Trim().ToUpper());
|
||||
data.ForEach(profile =>
|
||||
{
|
||||
profile.Status = !string.IsNullOrEmpty(req.status)
|
||||
? req.status.Trim().ToUpper() : null;
|
||||
profile.CommandTypeId = !string.IsNullOrEmpty(req.commandTypeId) && Guid.TryParse(req.commandTypeId, out var cmdTypeId)
|
||||
? cmdTypeId : null;
|
||||
profile.CommandCode = req.commandCode ?? null;
|
||||
});
|
||||
await _context.SaveChangesAsync();
|
||||
return Success();
|
||||
}
|
||||
|
|
@ -2148,7 +2240,13 @@ namespace BMA.EHR.DisciplineResult.Service.Controllers
|
|||
.Where(x => req.refIds.Contains(x.Id.ToString()))
|
||||
// .Where(x => x.Status.ToUpper() == "REPORT")
|
||||
.ToListAsync();
|
||||
data.ForEach(profile => profile.Status = "NEW");
|
||||
// data.ForEach(profile => profile.Status = "NEW");
|
||||
data.ForEach(profile =>
|
||||
{
|
||||
profile.Status = "NEW";
|
||||
profile.CommandTypeId = null;
|
||||
profile.CommandCode = null;
|
||||
});
|
||||
await _context.SaveChangesAsync();
|
||||
return Success();
|
||||
}
|
||||
|
|
@ -2242,7 +2340,7 @@ namespace BMA.EHR.DisciplineResult.Service.Controllers
|
|||
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
||||
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
||||
[HttpPost("command32/report")]
|
||||
public async Task<ActionResult<ResponseObject>> PostReportCommand32([FromBody] ReportPersonRequest req)
|
||||
public async Task<ActionResult<ResponseObject>> PostReportCommand32([FromBody] ReportPersonAndCommandRequest req)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
|
@ -2255,7 +2353,15 @@ namespace BMA.EHR.DisciplineResult.Service.Controllers
|
|||
.Where(x => req.refIds.Contains(x.Id.ToString()))
|
||||
.ToListAsync();
|
||||
|
||||
data2.ForEach(profile => profile.IsReport = req.status.Trim().ToUpper());
|
||||
// data2.ForEach(profile => profile.IsReport = req.status.Trim().ToUpper());
|
||||
data2.ForEach(profile =>
|
||||
{
|
||||
profile.Status = !string.IsNullOrEmpty(req.status)
|
||||
? req.status.Trim().ToUpper() : null;
|
||||
profile.CommandTypeId = !string.IsNullOrEmpty(req.commandTypeId) && Guid.TryParse(req.commandTypeId, out var cmdTypeId)
|
||||
? cmdTypeId : null;
|
||||
profile.CommandCode = req.commandCode ?? null;
|
||||
});
|
||||
|
||||
await _context.SaveChangesAsync();
|
||||
return Success();
|
||||
|
|
@ -2290,7 +2396,13 @@ namespace BMA.EHR.DisciplineResult.Service.Controllers
|
|||
// .Where(x => x.IsReport == "REPORT")
|
||||
.ToListAsync();
|
||||
|
||||
data2.ForEach(profile => profile.IsReport = "NEW");
|
||||
// data2.ForEach(profile => profile.IsReport = "NEW");
|
||||
data2.ForEach(profile =>
|
||||
{
|
||||
profile.Status = "NEW";
|
||||
profile.CommandTypeId = null;
|
||||
profile.CommandCode = null;
|
||||
});
|
||||
|
||||
await _context.SaveChangesAsync();
|
||||
return Success();
|
||||
|
|
|
|||
|
|
@ -1352,7 +1352,7 @@ namespace BMA.EHR.Leave.Service.Controllers
|
|||
}
|
||||
else
|
||||
{
|
||||
profile = await _userProfileRepository.GetEmployeeByAdminRole(AccessToken, profileAdmin?.Node, nodeId, role, req.revisionId, req.node, req.nodeId, req.StartDate.Date, req.EndDate.Date);
|
||||
profile = await _userProfileRepository.GetEmployeeByAdminRolev2(AccessToken, profileAdmin?.Node, nodeId, role, req.revisionId, req.node, req.nodeId, req.StartDate.Date, req.EndDate.Date);
|
||||
}
|
||||
// get leave day
|
||||
var leaveDays = await _leaveRequestRepository.GetSumApproveLeaveByTypeAndRange(req.StartDate, req.EndDate);
|
||||
|
|
@ -2380,7 +2380,7 @@ namespace BMA.EHR.Leave.Service.Controllers
|
|||
}
|
||||
else
|
||||
{
|
||||
profile = await _userProfileRepository.GetEmployeeByAdminRole(AccessToken, profileAdmin?.Node, nodeId, role, req.revisionId, req.node, req.nodeId, req.StartDate.Date, req.EndDate.Date);
|
||||
profile = await _userProfileRepository.GetEmployeeByAdminRolev2(AccessToken, profileAdmin?.Node, nodeId, role, req.revisionId, req.node, req.nodeId, req.StartDate.Date, req.EndDate.Date);
|
||||
}
|
||||
// Child กรองตามที่ fe ส่งมาอีกชั้น
|
||||
if ((role == "ROOT" || role == "OWNER" || role == "CHILD" || role == "PARENT" || role == "BROTHER") /*&& req.node > profileAdmin?.Node*/)
|
||||
|
|
|
|||
|
|
@ -2134,6 +2134,45 @@ namespace BMA.EHR.Leave.Service.Controllers
|
|||
return Success();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// API ลบรายการการลา (ADMIN)
|
||||
/// </summary>
|
||||
/// <returns>
|
||||
/// </returns>
|
||||
/// <response code="200">เมื่อทำรายการสำเร็จ</response>
|
||||
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
||||
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
||||
[HttpDelete("admin/{id:guid}")]
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
||||
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||
public async Task<ActionResult<ResponseObject>> DeleteLeaveRequestForAdminAsync(Guid id)
|
||||
{
|
||||
var jsonData = await _permission.GetPermissionWithActingAPIAsync("DELETE", "SYS_LEAVE_LIST");
|
||||
if (jsonData!.status != 200)
|
||||
{
|
||||
return Error(jsonData.message, StatusCodes.Status403Forbidden);
|
||||
}
|
||||
// ตรวจสอบว่า role ต้องเป็น OWNER เท่านั้น
|
||||
if (jsonData.result.privilege != "OWNER")
|
||||
{
|
||||
return Error("ไม่มีสิทธิ์ในการลบรายการขอลา", StatusCodes.Status403Forbidden);
|
||||
}
|
||||
|
||||
var deleted = await _leaveRequestRepository.GetByIdAsync(id);
|
||||
if (deleted == null)
|
||||
return Error(GlobalMessages.DataNotFound);
|
||||
|
||||
// ห้ามลบเฉพาะสถานะ APPROVE, DELETING, DELETE
|
||||
if (new[] { "APPROVE", "DELETING", "DELETE" }.Contains(deleted.LeaveStatus))
|
||||
{
|
||||
return Error("ไม่สามารถลบรายการขอลาสถานะนี้ได้");
|
||||
}
|
||||
|
||||
await _leaveRequestRepository.DeleteAsync(deleted);
|
||||
return Success();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// LV2_014 - รายการขอยกเลิกการลา (ADMIN)
|
||||
/// </summary>
|
||||
|
|
|
|||
|
|
@ -923,6 +923,61 @@ namespace BMA.EHR.Placement.Service.Controllers
|
|||
return Success();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// API ลบรายการรับโอน (ADMIN)
|
||||
/// </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>
|
||||
[HttpDelete("admin/{id:length(36)}")]
|
||||
public async Task<ActionResult<ResponseObject>> DeleteForAdminAsync(Guid id)
|
||||
{
|
||||
var jsonData = await _permission.GetPermissionWithActingAPIAsync("DELETE", "SYS_TRANSFER_RECEIVE");
|
||||
if (jsonData!.status != 200)
|
||||
{
|
||||
return Error(jsonData.message, StatusCodes.Status403Forbidden);
|
||||
}
|
||||
// ตรวจสอบว่า role ต้องเป็น OWNER เท่านั้น
|
||||
if (jsonData.result.privilege != "OWNER")
|
||||
{
|
||||
return Error("ไม่มีสิทธิ์ในการลบรายการรับโอน", StatusCodes.Status403Forbidden);
|
||||
}
|
||||
var deleted = await _context.PlacementReceives.AsQueryable()
|
||||
.Include(x => x.PlacementReceiveDocs)
|
||||
.ThenInclude(x => x.Document)
|
||||
.FirstOrDefaultAsync(x => x.Id == id);
|
||||
if (deleted == null)
|
||||
return NotFound();
|
||||
|
||||
// ห้ามลบเฉพาะสถานะ REPORT, WAITING, DONE
|
||||
if (new[] { "REPORT", "WAITING", "DONE" }.Contains(deleted.Status))
|
||||
{
|
||||
return Error("ไม่สามารถลบรายการรับโอนสถานะนี้ได้");
|
||||
}
|
||||
|
||||
var placementReceiveDocs = new List<dynamic>();
|
||||
foreach (var doc in deleted.PlacementReceiveDocs)
|
||||
{
|
||||
if (doc.Document != null)
|
||||
placementReceiveDocs.Add(doc.Document.Id);
|
||||
}
|
||||
_context.PlacementReceiveDocs.RemoveRange(deleted.PlacementReceiveDocs);
|
||||
await _context.SaveChangesAsync();
|
||||
_context.PlacementReceives.Remove(deleted);
|
||||
foreach (var doc in placementReceiveDocs)
|
||||
{
|
||||
if (doc != null)
|
||||
await _documentService.DeleteFileAsync(doc);
|
||||
}
|
||||
await _context.SaveChangesAsync();
|
||||
|
||||
return Success();
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// สั่งรายชื่อไปออกคำสั่ง
|
||||
/// </summary>
|
||||
|
|
|
|||
|
|
@ -932,6 +932,60 @@ namespace BMA.EHR.Placement.Service.Controllers
|
|||
return Success();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// API ลบรายการคำขอโอน (ADMIN)
|
||||
/// </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>
|
||||
[HttpDelete("admin/{id:length(36)}")]
|
||||
public async Task<ActionResult<ResponseObject>> DeleteForAdminAsync(Guid id)
|
||||
{
|
||||
var jsonData = await _permission.GetPermissionWithActingAPIAsync("DELETE", "SYS_TRANSFER_REQ");
|
||||
if (jsonData!.status != 200)
|
||||
{
|
||||
return Error(jsonData.message, StatusCodes.Status403Forbidden);
|
||||
}
|
||||
// ตรวจสอบว่า role ต้องเป็น OWNER เท่านั้น
|
||||
if (jsonData.result.privilege != "OWNER")
|
||||
{
|
||||
return Error("ไม่มีสิทธิ์ในการลบรายการคำขอโอน", StatusCodes.Status403Forbidden);
|
||||
}
|
||||
var deleted = await _context.PlacementTransfers.AsQueryable()
|
||||
.Include(x => x.PlacementTransferDocs)
|
||||
.ThenInclude(x => x.Document)
|
||||
.FirstOrDefaultAsync(x => x.Id == id);
|
||||
if (deleted == null)
|
||||
return NotFound();
|
||||
|
||||
// ห้ามลบเฉพาะสถานะ REPORT, WAITING, DONE
|
||||
if (new[] { "REPORT", "WAITING", "DONE" }.Contains(deleted.Status))
|
||||
{
|
||||
return Error("ไม่สามารถลบรายการคำขอโอนสถานะนี้ได้");
|
||||
}
|
||||
|
||||
var placementTransferDocs = new List<dynamic>();
|
||||
foreach (var doc in deleted.PlacementTransferDocs)
|
||||
{
|
||||
if (doc.Document != null)
|
||||
placementTransferDocs.Add(doc.Document.Id);
|
||||
}
|
||||
_context.PlacementTransferDocs.RemoveRange(deleted.PlacementTransferDocs);
|
||||
await _context.SaveChangesAsync();
|
||||
_context.PlacementTransfers.Remove(deleted);
|
||||
foreach (var doc in placementTransferDocs)
|
||||
{
|
||||
if (doc != null)
|
||||
await _documentService.DeleteFileAsync(doc);
|
||||
}
|
||||
await _context.SaveChangesAsync();
|
||||
|
||||
return Success();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// สั่งรายชื่อไปออกคำสั่ง
|
||||
/// </summary>
|
||||
|
|
|
|||
|
|
@ -1811,6 +1811,47 @@ namespace BMA.EHR.Retirement.Service.Controllers
|
|||
return Success();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// API ลบรายการลาออก (ADMIN)
|
||||
/// </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>
|
||||
[HttpDelete("admin/{id:length(36)}")]
|
||||
public async Task<ActionResult<ResponseObject>> DeleteForAdminAsync(Guid id)
|
||||
{
|
||||
var jsonData = await _permission.GetPermissionWithActingAPIAsync("DELETE", "SYS_RESIGN");
|
||||
if (jsonData!.status != 200)
|
||||
{
|
||||
return Error(jsonData.message, StatusCodes.Status403Forbidden);
|
||||
}
|
||||
// ตรวจสอบว่า role ต้องเป็น OWNER เท่านั้น
|
||||
if (jsonData.result.privilege != "OWNER")
|
||||
{
|
||||
return Error("ไม่มีสิทธิ์ในการลบรายการลาออก", StatusCodes.Status403Forbidden);
|
||||
}
|
||||
var deleted = await _context.RetirementResigns.AsQueryable()
|
||||
.FirstOrDefaultAsync(x => x.Id == id);
|
||||
if (deleted == null)
|
||||
return Error(GlobalMessages.RetirementResignNotFound, 404);
|
||||
|
||||
// ห้ามลบเฉพาะสถานะ REPORT, WAITING, DONE, CANCELING, CANCEL
|
||||
if (new[] { "REPORT", "WAITING", "DONE", "CANCELING", "CANCEL" }.Contains(deleted.Status))
|
||||
{
|
||||
return Error("ไม่สามารถลบรายการลาออกสถานะนี้ได้");
|
||||
}
|
||||
|
||||
deleted.Status = "DELETE";
|
||||
deleted.LastUpdateFullName = FullName ?? "System Administrator";
|
||||
deleted.LastUpdateUserId = UserId ?? "";
|
||||
deleted.LastUpdatedAt = DateTime.Now;
|
||||
await _context.SaveChangesAsync();
|
||||
return Success();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// อนุมัติคำลาออก
|
||||
/// </summary>
|
||||
|
|
|
|||
|
|
@ -1719,6 +1719,47 @@ namespace BMA.EHR.Retirement.Service.Controllers
|
|||
return Success();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// API ลบรายการลาออกลูกจ้าง (ADMIN)
|
||||
/// </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>
|
||||
[HttpDelete("admin/{id:length(36)}")]
|
||||
public async Task<ActionResult<ResponseObject>> DeleteForAdminAsync(Guid id)
|
||||
{
|
||||
var jsonData = await _permission.GetPermissionWithActingAPIAsync("DELETE", "SYS_RESIGN_EMP");
|
||||
if (jsonData!.status != 200)
|
||||
{
|
||||
return Error(jsonData.message, StatusCodes.Status403Forbidden);
|
||||
}
|
||||
// ตรวจสอบว่า role ต้องเป็น OWNER เท่านั้น
|
||||
if (jsonData.result.privilege != "OWNER")
|
||||
{
|
||||
return Error("ไม่มีสิทธิ์ในการลบรายการลาออกลูกจ้าง", StatusCodes.Status403Forbidden);
|
||||
}
|
||||
var deleted = await _context.RetirementResignEmployees.AsQueryable()
|
||||
.FirstOrDefaultAsync(x => x.Id == id);
|
||||
if (deleted == null)
|
||||
return Error(GlobalMessages.RetirementResignEmployeeNotFound, 404);
|
||||
|
||||
// ห้ามลบเฉพาะสถานะ REPORT, WAITING, DONE, CANCELING, CANCEL
|
||||
if (new[] { "REPORT", "WAITING", "DONE", "CANCELING", "CANCEL" }.Contains(deleted.Status))
|
||||
{
|
||||
return Error("ไม่สามารถลบรายการลาออกลูกจ้างสถานะนี้ได้");
|
||||
}
|
||||
|
||||
deleted.Status = "DELETE";
|
||||
deleted.LastUpdateFullName = FullName ?? "System Administrator";
|
||||
deleted.LastUpdateUserId = UserId ?? "";
|
||||
deleted.LastUpdatedAt = DateTime.Now;
|
||||
await _context.SaveChangesAsync();
|
||||
return Success();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// อนุมัติคำลาออก
|
||||
/// </summary>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue