forked from AcaMate/AcaMate_API
[♻️] 푸시 API 예외 처리 수정
This commit is contained in:
parent
166fe3dd5d
commit
d537ad7a25
|
@ -37,6 +37,7 @@ public class PushController : ControllerBase
|
|||
public async Task<IActionResult> GetPush(string bid, string? pid, string? category)
|
||||
{
|
||||
string summary = String.Empty;
|
||||
|
||||
try
|
||||
{
|
||||
summary = _repositoryService.ReadSummary(typeof(PushController), "GetPush");
|
||||
|
@ -178,7 +179,7 @@ public class PushController : ControllerBase
|
|||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError($"[{summary}] : {ex.Message}");
|
||||
return StatusCode(500, APIResponse.UnknownError());
|
||||
return StatusCode(500, APIResponse.UnknownError(ex.Message));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -188,17 +189,19 @@ public class PushController : ControllerBase
|
|||
public async Task<IActionResult> SetPush(string token, string refresh, [FromBody] DBPayload request)
|
||||
{
|
||||
string uid = "";
|
||||
if (token == "System") uid = "System";
|
||||
else {
|
||||
if (string.IsNullOrEmpty(token) || string.IsNullOrEmpty(refresh)) return BadRequest(APIResponse.InvalidInputError());
|
||||
if(!ModelState.IsValid) return BadRequest(APIResponse.InvalidInputError());
|
||||
|
||||
var validateToken = await _repositoryService.ValidateToken(token, refresh);
|
||||
uid = validateToken.uid;
|
||||
}
|
||||
|
||||
string summary = String.Empty;
|
||||
|
||||
try {
|
||||
|
||||
if (token == "System") uid = "System";
|
||||
else {
|
||||
if (string.IsNullOrEmpty(token) || string.IsNullOrEmpty(refresh)) return BadRequest(APIResponse.InvalidInputError());
|
||||
if(!ModelState.IsValid) return BadRequest(APIResponse.InvalidInputError());
|
||||
|
||||
var validateToken = await _repositoryService.ValidateToken(token, refresh);
|
||||
uid = validateToken.uid;
|
||||
}
|
||||
|
||||
summary = _repositoryService.ReadSummary(typeof(PushController), "SetPush");
|
||||
var dbPayload = await _dbContext.DBPayload
|
||||
.FirstOrDefaultAsync(p => p.pid == request.pid && p.bid == request.bid);
|
||||
|
@ -236,7 +239,7 @@ public class PushController : ControllerBase
|
|||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError($"[{summary}] : {ex.Message}");
|
||||
return StatusCode(500, APIResponse.UnknownError());
|
||||
return StatusCode(500, APIResponse.UnknownError(ex.Message));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -246,25 +249,25 @@ public class PushController : ControllerBase
|
|||
public async Task<IActionResult> CreatePush(string token, string refresh, [FromBody] CreatePush request)
|
||||
{
|
||||
string uid = "";
|
||||
if (token == "System") uid = "System";
|
||||
else {
|
||||
if (string.IsNullOrEmpty(token) || string.IsNullOrEmpty(refresh)) return BadRequest(APIResponse.InvalidInputError());
|
||||
if(!ModelState.IsValid) return BadRequest(APIResponse.InvalidInputError());
|
||||
|
||||
var validateToken = await _repositoryService.ValidateToken(token, refresh);
|
||||
uid = validateToken.uid;
|
||||
}
|
||||
|
||||
string summary = String.Empty;
|
||||
|
||||
Func<string, int, string> randomLetter = (letters, count) => new string(Enumerable.Range(0, count).Select(_ => letters[new Random().Next(letters.Length)]).ToArray());
|
||||
var letters = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
|
||||
var digits = "0123456789";
|
||||
var frontLetters = $"{randomLetter(letters, 1)}{randomLetter(digits, 1)}{randomLetter(letters, 1)}";
|
||||
var afterLetters = $"{randomLetter(letters, 1)}{randomLetter(digits, 1)}{randomLetter(letters, 1)}";
|
||||
|
||||
|
||||
|
||||
string summary = String.Empty;
|
||||
try {
|
||||
|
||||
if (token == "System") uid = "System";
|
||||
else {
|
||||
if (string.IsNullOrEmpty(token) || string.IsNullOrEmpty(refresh)) return BadRequest(APIResponse.InvalidInputError());
|
||||
if(!ModelState.IsValid) return BadRequest(APIResponse.InvalidInputError());
|
||||
|
||||
var validateToken = await _repositoryService.ValidateToken(token, refresh);
|
||||
uid = validateToken.uid;
|
||||
}
|
||||
|
||||
summary = _repositoryService.ReadSummary(typeof(PushController), "CreatePush");
|
||||
|
||||
if (await _dbContext.Academy.AnyAsync(a => a.bid == request.bid))
|
||||
|
@ -327,19 +330,18 @@ public class PushController : ControllerBase
|
|||
public async Task<IActionResult> DeletePush(string token, string refresh, string bid, string pid)
|
||||
{
|
||||
string uid = "";
|
||||
if (token == "System") uid = "System";
|
||||
else {
|
||||
if (string.IsNullOrEmpty(token) || string.IsNullOrEmpty(refresh)) return BadRequest(APIResponse.InvalidInputError());
|
||||
if(!ModelState.IsValid) return BadRequest(APIResponse.InvalidInputError());
|
||||
|
||||
var validateToken = await _repositoryService.ValidateToken(token, refresh);
|
||||
uid = validateToken.uid;
|
||||
}
|
||||
|
||||
string summary = String.Empty;
|
||||
|
||||
try
|
||||
{
|
||||
if (token == "System") uid = "System";
|
||||
else {
|
||||
if (string.IsNullOrEmpty(token) || string.IsNullOrEmpty(refresh)) return BadRequest(APIResponse.InvalidInputError());
|
||||
if(!ModelState.IsValid) return BadRequest(APIResponse.InvalidInputError());
|
||||
|
||||
var validateToken = await _repositoryService.ValidateToken(token, refresh);
|
||||
uid = validateToken.uid;
|
||||
}
|
||||
summary = _repositoryService.ReadSummary(typeof(PushController), "DeletePush");
|
||||
|
||||
var payload = await _dbContext.DBPayload.FirstOrDefaultAsync(p => p.bid == bid && p.pid == pid);
|
||||
|
@ -364,7 +366,7 @@ public class PushController : ControllerBase
|
|||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError($"[{summary}] : {ex.Message}");
|
||||
return BadRequest(APIResponse.UnknownError());
|
||||
return BadRequest(APIResponse.UnknownError(ex.Message));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -375,19 +377,18 @@ public class PushController : ControllerBase
|
|||
public async Task<IActionResult> DeleteListPush(string token, string refresh, int id)
|
||||
{
|
||||
string uid = "";
|
||||
if (token == "System") uid = "System";
|
||||
else {
|
||||
if (string.IsNullOrEmpty(token) || string.IsNullOrEmpty(refresh)) return BadRequest(APIResponse.InvalidInputError());
|
||||
if(!ModelState.IsValid) return BadRequest(APIResponse.InvalidInputError());
|
||||
|
||||
var validateToken = await _repositoryService.ValidateToken(token, refresh);
|
||||
uid = validateToken.uid;
|
||||
}
|
||||
|
||||
string summary = String.Empty;
|
||||
|
||||
try
|
||||
{
|
||||
if (token == "System") uid = "System";
|
||||
else {
|
||||
if (string.IsNullOrEmpty(token) || string.IsNullOrEmpty(refresh)) return BadRequest(APIResponse.InvalidInputError());
|
||||
if(!ModelState.IsValid) return BadRequest(APIResponse.InvalidInputError());
|
||||
|
||||
var validateToken = await _repositoryService.ValidateToken(token, refresh);
|
||||
uid = validateToken.uid;
|
||||
}
|
||||
summary = _repositoryService.ReadSummary(typeof(PushController), "DeleteListPush");
|
||||
var cabinetPush = await _dbContext.PushCabinet.FirstOrDefaultAsync(c => c.id == id);
|
||||
if (cabinetPush == null) return Ok(APIResponse.Send("001", $"[{summary}], 삭제 할 PUSH 없음", Empty));
|
||||
|
@ -410,7 +411,7 @@ public class PushController : ControllerBase
|
|||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError($"[{summary}] : {ex.Message}");
|
||||
return BadRequest(APIResponse.UnknownError());
|
||||
return BadRequest(APIResponse.UnknownError(ex.Message));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -422,19 +423,19 @@ public class PushController : ControllerBase
|
|||
public async Task<IActionResult> SearchToUserPush(string token, string refresh, int size, [FromBody] PushCabinet? request)
|
||||
{
|
||||
string uid = "";
|
||||
if (token == "System") uid = "System";
|
||||
else {
|
||||
if (string.IsNullOrEmpty(token) || string.IsNullOrEmpty(refresh)) return BadRequest(APIResponse.InvalidInputError());
|
||||
if(!ModelState.IsValid) return BadRequest(APIResponse.InvalidInputError());
|
||||
|
||||
var validateToken = await _repositoryService.ValidateToken(token, refresh);
|
||||
uid = validateToken.uid;
|
||||
}
|
||||
|
||||
string summary = String.Empty;
|
||||
|
||||
try
|
||||
{
|
||||
if (token == "System") uid = "System";
|
||||
else {
|
||||
if (string.IsNullOrEmpty(token) || string.IsNullOrEmpty(refresh)) return BadRequest(APIResponse.InvalidInputError());
|
||||
if(!ModelState.IsValid) return BadRequest(APIResponse.InvalidInputError());
|
||||
|
||||
var validateToken = await _repositoryService.ValidateToken(token, refresh);
|
||||
uid = validateToken.uid;
|
||||
}
|
||||
|
||||
summary = _repositoryService.ReadSummary(typeof(PushController), "SearchToUserPush");
|
||||
if (request == null)
|
||||
{
|
||||
|
@ -458,7 +459,7 @@ public class PushController : ControllerBase
|
|||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError($"[{summary}] : {ex.Message}");
|
||||
return BadRequest(APIResponse.UnknownError());
|
||||
return BadRequest(APIResponse.UnknownError(ex.Message));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user