Merge branch 'develop' into ananda

This commit is contained in:
AnandaTon 2023-03-31 15:03:43 +07:00
commit d16435c2c9
13 changed files with 3036 additions and 5 deletions

View file

@ -1,4 +1,5 @@
using BMA.EHR.Core;
// using BMA.EHR.Core;
using BMA.EHR.Recurit.Exam.Service.Core;
using BMA.EHR.Recurit.Exam.Service.Request;
using BMA.EHR.Recurit.Exam.Service.Response;
using BMA.EHR.Recurit.Exam.Service.Services;
@ -13,7 +14,7 @@ namespace BMA.EHR.Recurit.Exam.Service.Controllers
[ApiController]
[Produces("application/json")]
[Authorize]
[SwaggerTag("จัดการข้อมูลศาสนา เพื่อนำไปใช้งานในระบบ")]
[SwaggerTag("จัดการข้อมูลสมัครสอบ เพื่อนำไปใช้งานในระบบ")]
public class CandidateController : BaseController
{
#region " Fields "
@ -24,9 +25,11 @@ namespace BMA.EHR.Recurit.Exam.Service.Controllers
#region " Constructor and Destructor "
public CandidateController(CandidateService candidateService)
public CandidateController(CandidateService candidateService,
MinIOService minioService)
{
_candidateService = candidateService;
_minioService = minioService;
}
#endregion
@ -785,6 +788,95 @@ namespace BMA.EHR.Recurit.Exam.Service.Controllers
}
/// <summary>
/// อัปเอกสารหลักฐาน
/// </summary>
/// <param name="examId">รหัสรอบสมัคร</param>
/// <returns></returns>
/// <response code="200">เมื่ออัปเอกสารหลักฐานสำเร็จ</response>
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
[HttpPut("upload/{examId:length(36)}"), DisableRequestSizeLimit]
[ProducesResponseType(StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
public async Task<ActionResult<ResponseObject>> CreateFileCandidateService(string examId)
{
try
{
if (Request.Form.Files == null || Request.Form.Files.Count == 0)
{
return Error(GlobalMessages.NoFileToUpload);
}
var file = Request.Form.Files[0];
await _candidateService.UpdateAsyncDocument(examId, file);
return Success();
}
catch (Exception ex)
{
return Error(ex);
}
}
/// <summary>
/// ลบเอกสารหลักฐาน
/// </summary>
/// <param name="documentId">รหัสไฟล์เอกสาร</param>
/// <returns></returns>
/// <response code="200">เมื่อลบเอกสารหลักฐานสำเร็จ</response>
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
[HttpDelete("upload/{examId:length(36)}"), DisableRequestSizeLimit]
[ProducesResponseType(StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
public async Task<ActionResult<ResponseObject>> DeleteFileCandidateService(string documentId)
{
try
{
await _candidateService.DeleteAsyncDocument(documentId);
return Success();
}
catch (Exception ex)
{
return Error(ex);
}
}
/// <summary>
/// โหลดไฟล์
/// </summary>
/// <param name="examId">รหัสรอบสมัคร</param>
/// <returns></returns>
/// <response code="200">เมื่อโหลดไฟล์สำเร็จ</response>
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
[HttpGet("download/{id:length(36)}")]
[ProducesResponseType(StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
public async Task<ActionResult<ResponseObject>> DownloadFile(Guid id)
{
try
{
var file_data = await _minioService.DownloadFileAsync(id);
Response.Headers["Content-Disposition"] = $"inline; filename={file_data.FileName}";
var ret = new FileContentResult(file_data.FileContent, file_data.FileType)
{
FileDownloadName = file_data.FileName
};
return ret;
}
catch (Exception ex)
{
return Error(ex);
}
}
#endregion
}
}

View file

@ -12,7 +12,7 @@ namespace BMA.EHR.Recurit.Exam.Service.Controllers
[ApiController]
[Produces("application/json")]
[Authorize]
[SwaggerTag("จัดการข้อมูลคำนำหน้า เพื่อนำไปใช้งานในระบบ")]
[SwaggerTag("จัดการข้อมูลรอบการสอบ เพื่อนำไปใช้งานในระบบ")]
public class PeriodExamController : BaseController
{
#region " Fields "