forked from AcaMate/AcaMate_API
[✨] 푸시 내용 변경 API 생성
This commit is contained in:
parent
76d989a4fa
commit
ecddaa2575
|
@ -7,6 +7,7 @@ using Microsoft.EntityFrameworkCore.Update.Internal;
|
|||
|
||||
using AcaMate.Common.Data;
|
||||
using AcaMate.V1.Services;
|
||||
using Microsoft.AspNetCore.Http.HttpResults;
|
||||
|
||||
namespace AcaMate.V1.Controllers;
|
||||
|
||||
|
@ -47,7 +48,7 @@ public class PushController : ControllerBase
|
|||
/// <response code="500">Internal server error occurred.</response>
|
||||
/// <response code="999">Service unavailable.</response>
|
||||
[HttpPost("send")]
|
||||
[CustomOperation("푸시전송", "저장된 양식으로, 사용자에게 푸시를 전송한다.(로컬 테스트 불가)", "푸시")]
|
||||
[CustomOperation("푸시전송", "저장된 양식으로, 사용자에게 푸시를 전송한다.", "푸시")]
|
||||
[ProducesResponseType(StatusCodes.Status200OK, Type = typeof(APIResponseStatus<object>))]
|
||||
public async Task<IActionResult> SendPush([FromBody] PushRequest pushRequest)
|
||||
{
|
||||
|
@ -118,7 +119,41 @@ public class PushController : ControllerBase
|
|||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
[HttpPost("set")]
|
||||
[CustomOperation("푸시내용 변경", "저장된 양식을 변경한다.", "푸시")]
|
||||
[ProducesResponseType(StatusCodes.Status200OK, Type = typeof(APIResponseStatus<object>))]
|
||||
public async Task<IActionResult> SetPush([FromBody] DBPayload request)
|
||||
{
|
||||
if (!ModelState.IsValid) return BadRequest(APIResponse.InvalidInputError());
|
||||
|
||||
try
|
||||
{
|
||||
var dbPayload = await _dbContext.DBPayload
|
||||
.FirstOrDefaultAsync(p => p.pid == request.pid);
|
||||
|
||||
if (dbPayload != null)
|
||||
{
|
||||
if (dbPayload.title != request.title && request.title != "") dbPayload.title = request.title;
|
||||
if (dbPayload.body != request.body && request.body != "") dbPayload.body = request.body;
|
||||
if (dbPayload.subtitle != request.subtitle) dbPayload.subtitle = request.subtitle;
|
||||
if (dbPayload.alert_yn != request.alert_yn) dbPayload.alert_yn = request.alert_yn;
|
||||
if (dbPayload.category != request.category && request.category != "") dbPayload.category = request.category;
|
||||
if (dbPayload.content != request.content) dbPayload.content = request.content;
|
||||
if (await _repositoryService.SaveData<DBPayload, string>(dbPayload, p => p.pid))
|
||||
return Ok(APIResponse.Send("000", "PUSH 정보 변경 완료", Empty));
|
||||
}
|
||||
return Ok(APIResponse.Send("100", "PID 또는 Cabinet 오류", Empty));
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError($"[푸시] {ex.Message}");
|
||||
return StatusCode(500, APIResponse.UnknownError());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}// END PUSH CONTROLLER
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -83,7 +83,7 @@ public class DBPayload
|
|||
public string body {get; set;}
|
||||
public bool alert_yn {get; set;}
|
||||
public string category {get; set;}
|
||||
public string content {get; set;}
|
||||
public string? content {get; set;}
|
||||
}
|
||||
|
||||
[Table("push_cabinet")]
|
||||
|
|
Loading…
Reference in New Issue
Block a user