add holiday
This commit is contained in:
parent
9eae970ff3
commit
aa904079a2
8 changed files with 1230 additions and 5 deletions
190
BMA.EHR.Placement.Service/Controllers/MessageController.cs
Normal file
190
BMA.EHR.Placement.Service/Controllers/MessageController.cs
Normal file
|
|
@ -0,0 +1,190 @@
|
|||
using BMA.EHR.Application.Repositories.MessageQueue;
|
||||
using BMA.EHR.Domain.Common;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Swashbuckle.AspNetCore.Annotations;
|
||||
|
||||
namespace BMA.EHR.Placement.Service.Controllers
|
||||
{
|
||||
[Route("api/v{version:apiVersion}/placement/message")]
|
||||
[ApiVersion("1.0")]
|
||||
[ApiController]
|
||||
[Produces("application/json")]
|
||||
[Authorize]
|
||||
[SwaggerTag("API ระบบ Inbox และ Notification")]
|
||||
public class MessageController : BaseController
|
||||
{
|
||||
#region " Fields "
|
||||
|
||||
private readonly InboxRepository _inboxRepository;
|
||||
private readonly NotificationRepository _notificationRepository;
|
||||
|
||||
#endregion
|
||||
|
||||
#region " Constuctor and Destructor "
|
||||
|
||||
public MessageController(InboxRepository inboxRepository,
|
||||
NotificationRepository notificationRepository)
|
||||
{
|
||||
_inboxRepository = inboxRepository;
|
||||
_notificationRepository = notificationRepository;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region " Methods "
|
||||
|
||||
/// <summary>
|
||||
/// แสดงข้อมูล Inbox ของ user ที่ Login
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
/// <response code="200">เมื่อทำการอ่านข้อมูลจาก Relational Database สำเร็จ</response>
|
||||
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
||||
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
||||
[HttpGet("my-inboxes")]
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
||||
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||
public async Task<ActionResult<ResponseObject>> GetMyInboxAsync(int page = 1, int pageSize = 20)
|
||||
{
|
||||
try
|
||||
{
|
||||
var inboxes = await _inboxRepository.GetMyInboxAsync(page, pageSize);
|
||||
|
||||
return Success(inboxes);
|
||||
}
|
||||
catch
|
||||
{
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// ดูข้อมูล Inbox ของ user ที่ Login
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
/// <response code="200">เมื่อทำการอ่านข้อมูลจาก Relational Database สำเร็จ</response>
|
||||
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
||||
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
||||
[HttpGet("my-inboxes/{id:length(36)}")]
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
||||
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||
public async Task<ActionResult<ResponseObject>> GetByIdMyInboxAsync(Guid id)
|
||||
{
|
||||
try
|
||||
{
|
||||
await _inboxRepository.GetByIdMyInboxAsync(id);
|
||||
|
||||
return Success();
|
||||
}
|
||||
catch
|
||||
{
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// ลบข้อมูล Inbox ของ user ที่ Login
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
/// <response code="200">เมื่อทำการอ่านข้อมูลจาก Relational Database สำเร็จ</response>
|
||||
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
||||
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
||||
[HttpDelete("my-inboxes/{id:length(36)}")]
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
||||
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||
public async Task<ActionResult<ResponseObject>> DeleteMyInboxAsync(Guid id)
|
||||
{
|
||||
try
|
||||
{
|
||||
await _inboxRepository.DeleteMyInboxAsync(id);
|
||||
|
||||
return Success();
|
||||
}
|
||||
catch
|
||||
{
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// แสดงข้อมูล Notification ของ user ที่ Login
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
/// <response code="200">เมื่อทำการอ่านข้อมูลจาก Relational Database สำเร็จ</response>
|
||||
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
||||
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
||||
[HttpGet("my-notifications")]
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
||||
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||
public async Task<ActionResult<ResponseObject>> GetMyNotificationAsync(int page = 1, int pageSize = 20)
|
||||
{
|
||||
try
|
||||
{
|
||||
var noti = await _notificationRepository.GetMyNotificationAsync(page, pageSize);
|
||||
|
||||
return Success(noti);
|
||||
}
|
||||
catch
|
||||
{
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// แสดงข้อมูล Notification ของ user ที่ Login ที่ยังไม่ได้อ่าน
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
/// <response code="200">เมื่อทำการอ่านข้อมูลจาก Relational Database สำเร็จ</response>
|
||||
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
||||
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
||||
[HttpGet("my-notifications/noread")]
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
||||
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||
public async Task<ActionResult<ResponseObject>> GetMyNotificationAsyncNoread()
|
||||
{
|
||||
try
|
||||
{
|
||||
var noti = await _notificationRepository.GetMyNotificationAsyncNoread();
|
||||
|
||||
return Success(noti);
|
||||
}
|
||||
catch
|
||||
{
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// ลบข้อมูล Notification ของ user ที่ Login
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
/// <response code="200">เมื่อทำการอ่านข้อมูลจาก Relational Database สำเร็จ</response>
|
||||
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
||||
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
||||
[HttpDelete("my-notifications/{id:length(36)}")]
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
||||
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||
public async Task<ActionResult<ResponseObject>> DeleteMyNotificationAsync(Guid id)
|
||||
{
|
||||
try
|
||||
{
|
||||
await _notificationRepository.DeleteMyNotificationAsync(id);
|
||||
|
||||
return Success();
|
||||
}
|
||||
catch
|
||||
{
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue