API อัพเดทสถานะเป็นบรรจุ เฉพาะ Super_admin
All checks were successful
Build & Deploy Placement Service / build (push) Successful in 1m57s
All checks were successful
Build & Deploy Placement Service / build (push) Successful in 1m57s
This commit is contained in:
parent
09a7208074
commit
970319e8c2
2 changed files with 44 additions and 1 deletions
|
|
@ -62,9 +62,9 @@ namespace BMA.EHR.Placement.Service.Controllers
|
||||||
#region " Properties "
|
#region " Properties "
|
||||||
|
|
||||||
private string? UserId => _httpContextAccessor?.HttpContext?.User?.FindFirst(ClaimTypes.NameIdentifier)?.Value;
|
private string? UserId => _httpContextAccessor?.HttpContext?.User?.FindFirst(ClaimTypes.NameIdentifier)?.Value;
|
||||||
|
|
||||||
private string? FullName => _httpContextAccessor?.HttpContext?.User?.FindFirst("name")?.Value;
|
private string? FullName => _httpContextAccessor?.HttpContext?.User?.FindFirst("name")?.Value;
|
||||||
private string? token => _httpContextAccessor.HttpContext.Request.Headers["Authorization"];
|
private string? token => _httpContextAccessor.HttpContext.Request.Headers["Authorization"];
|
||||||
|
private bool isSuperAdmin => _httpContextAccessor?.HttpContext?.User?.IsInRole("SUPER_ADMIN") ?? false;
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
|
@ -852,6 +852,39 @@ namespace BMA.EHR.Placement.Service.Controllers
|
||||||
return Success();
|
return Success();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// API อัพเดทสถานะเป็นบรรจุ
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
/// <response code="200"></response>
|
||||||
|
/// <response code="400">ค่าตัวแปรที่ส่งมาไม่ถูกต้อง</response>
|
||||||
|
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
||||||
|
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
||||||
|
[HttpPost("pass/update-status")]
|
||||||
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||||
|
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||||
|
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
||||||
|
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||||
|
public async Task<ActionResult<ResponseObject>> PersonUpdateStatus([FromBody] PersonUpdateStatusRequest req)
|
||||||
|
{
|
||||||
|
if (isSuperAdmin == false)
|
||||||
|
return Success();
|
||||||
|
|
||||||
|
var person = await _context.PlacementProfiles
|
||||||
|
.FirstOrDefaultAsync(x => x.Id == req.PersonalId);
|
||||||
|
if (person == null)
|
||||||
|
return Error(GlobalMessages.DataNotFound, 404);
|
||||||
|
|
||||||
|
person.PlacementStatus = "DONE";
|
||||||
|
person.LastUpdateFullName = FullName ?? "System Administrator";
|
||||||
|
person.LastUpdateUserId = UserId ?? "";
|
||||||
|
person.LastUpdatedAt = DateTime.Now;
|
||||||
|
|
||||||
|
await _context.SaveChangesAsync();
|
||||||
|
|
||||||
|
return Success();
|
||||||
|
}
|
||||||
|
|
||||||
[HttpGet("pass/deferment/{personalId:length(36)}")]
|
[HttpGet("pass/deferment/{personalId:length(36)}")]
|
||||||
public async Task<ActionResult<ResponseObject>> GetPersonDeferment(Guid personalId)
|
public async Task<ActionResult<ResponseObject>> GetPersonDeferment(Guid personalId)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,10 @@
|
||||||
|
using BMA.EHR.Domain.Models.MetaData;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
|
||||||
|
namespace BMA.EHR.Placement.Service.Requests
|
||||||
|
{
|
||||||
|
public class PersonUpdateStatusRequest
|
||||||
|
{
|
||||||
|
public Guid PersonalId { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue