[👷] 로그 정리 및 swagger 설명 정리
This commit is contained in:
parent
9acda11556
commit
012e7231db
|
@ -33,49 +33,35 @@ public class PushController : ControllerBase
|
||||||
|
|
||||||
[HttpGet()]
|
[HttpGet()]
|
||||||
[CustomOperation("푸시 확인", "저장된 양식을 확인 할 수 있다.", "푸시")]
|
[CustomOperation("푸시 확인", "저장된 양식을 확인 할 수 있다.", "푸시")]
|
||||||
|
[ProducesResponseType(StatusCodes.Status200OK, Type = typeof(APIResponseStatus<object>))]
|
||||||
public async Task<IActionResult> GetPush(string bid, string? pid, string? category)
|
public async Task<IActionResult> GetPush(string bid, string? pid, string? category)
|
||||||
{
|
{
|
||||||
if (!(await _dbContext.Academy.AnyAsync(a=>a.bid == bid)))
|
string summary = String.Empty;
|
||||||
return Ok(APIResponse.Send("100", "존재하지 않는 BID", Empty));
|
|
||||||
|
|
||||||
List<DBPayload> pushData = new List<DBPayload>();
|
|
||||||
|
|
||||||
if (pid == null && category == null)
|
|
||||||
{
|
|
||||||
pushData = await _dbContext.DBPayload
|
|
||||||
.Where(p => p.bid == bid)
|
|
||||||
.ToListAsync();
|
|
||||||
}
|
|
||||||
else if (pid != null && category == null)
|
|
||||||
{
|
|
||||||
pushData = await _dbContext.DBPayload
|
|
||||||
.Where(p => p.bid == bid && p.pid == pid)
|
|
||||||
.ToListAsync();
|
|
||||||
}
|
|
||||||
else if (pid == null && category != null)
|
|
||||||
{
|
|
||||||
pushData = await _dbContext.DBPayload
|
|
||||||
.Where(p => p.bid == bid && p.category == category)
|
|
||||||
.ToListAsync();
|
|
||||||
}
|
|
||||||
else //if (pid != null && category != null)
|
|
||||||
{
|
|
||||||
pushData = await _dbContext.DBPayload
|
|
||||||
.Where(p => p.bid == bid && p.pid == pid && p.category == category)
|
|
||||||
.ToListAsync();
|
|
||||||
}
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
summary = _repositoryService.ReadSummary(typeof(PushController), "GetPush");
|
||||||
|
|
||||||
|
if (!(await _dbContext.Academy.AnyAsync(a=>a.bid == bid)))
|
||||||
|
return Ok(APIResponse.Send("100", $"[{summary}], 존재하지 않는 BID", Empty));
|
||||||
|
|
||||||
|
List<DBPayload> pushData = new List<DBPayload>();
|
||||||
|
var pushQuery = _dbContext.DBPayload.Where(p => p.bid == bid);
|
||||||
|
if (pid != null)
|
||||||
|
pushQuery = pushQuery.Where(p=>p.pid == pid);
|
||||||
|
if (category != null)
|
||||||
|
pushQuery = pushQuery.Where(p=>p.category == category);
|
||||||
|
pushData = await pushQuery.ToListAsync();
|
||||||
|
|
||||||
if (pushData.Count > 0)
|
if (pushData.Count > 0)
|
||||||
{
|
{
|
||||||
return Ok(APIResponse.Send("000", "정상", pushData));
|
return Ok(APIResponse.Send("000", $"[{summary}, 정상", pushData));
|
||||||
}
|
}
|
||||||
|
|
||||||
return Ok(APIResponse.Send("001", "PUSH 데이터가 없음", Empty));
|
return Ok(APIResponse.Send("001", $"[{summary}], PUSH 데이터 없음", Empty));
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
_logger.LogError($"[푸시] {ex.Message}");
|
_logger.LogError($"[{summary}] : {ex.Message}");
|
||||||
return StatusCode(500, APIResponse.UnknownError());
|
return StatusCode(500, APIResponse.UnknownError());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -180,33 +166,30 @@ public class PushController : ControllerBase
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
return Ok(APIResponse.Send("000", $"[{summary}], 정상", Empty));
|
||||||
return Ok(APIResponse.Send("000", "정상", Empty));
|
|
||||||
|
|
||||||
}
|
}
|
||||||
catch (PushInvalidException ex)
|
catch (PushInvalidException ex)
|
||||||
{
|
{
|
||||||
_logger.LogError(ex.Message);
|
_logger.LogError($"[{summary}] : {ex.Message}");
|
||||||
return Ok(APIResponse.Send("001", $"[{summary}]: 푸시 송신 중 문제 발생",Empty));
|
return Ok(APIResponse.Send("001", $"[{summary}], 푸시 송신 중 문제 발생",Empty));
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
_logger.LogError($"[푸시] {ex.Message}");
|
_logger.LogError($"[{summary}] : {ex.Message}");
|
||||||
return StatusCode(500, APIResponse.UnknownError());
|
return StatusCode(500, APIResponse.UnknownError());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpPost("set")]
|
[HttpPost("set")]
|
||||||
[CustomOperation("[푸시 변경]", "저장된 양식을 변경한다.", "푸시")]
|
[CustomOperation("푸시 변경", "저장된 양식을 변경한다.", "푸시")]
|
||||||
[ProducesResponseType(StatusCodes.Status200OK, Type = typeof(APIResponseStatus<object>))]
|
[ProducesResponseType(StatusCodes.Status200OK, Type = typeof(APIResponseStatus<object>))]
|
||||||
public async Task<IActionResult> SetPush([FromBody] DBPayload request)
|
public async Task<IActionResult> SetPush([FromBody] DBPayload request)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
if (!ModelState.IsValid) return BadRequest(APIResponse.InvalidInputError());
|
if (!ModelState.IsValid) return BadRequest(APIResponse.InvalidInputError());
|
||||||
|
|
||||||
try
|
string summary = String.Empty;
|
||||||
{
|
try {
|
||||||
|
summary = _repositoryService.ReadSummary(typeof(PushController), "SetPush");
|
||||||
var dbPayload = await _dbContext.DBPayload
|
var dbPayload = await _dbContext.DBPayload
|
||||||
.FirstOrDefaultAsync(p => p.pid == request.pid && p.bid == request.bid);
|
.FirstOrDefaultAsync(p => p.pid == request.pid && p.bid == request.bid);
|
||||||
|
|
||||||
|
@ -218,16 +201,16 @@ public class PushController : ControllerBase
|
||||||
if (dbPayload.alert_yn != request.alert_yn) dbPayload.alert_yn = request.alert_yn;
|
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.category != request.category && request.category != "") dbPayload.category = request.category;
|
||||||
if (dbPayload.content != request.content) dbPayload.content = request.content;
|
if (dbPayload.content != request.content) dbPayload.content = request.content;
|
||||||
// if (await _repositoryService.SaveData<DBPayload, string>(dbPayload, p => p.pid))
|
|
||||||
if (await _repositoryService.SaveData<DBPayload>(dbPayload))
|
if (await _repositoryService.SaveData<DBPayload>(dbPayload))
|
||||||
return Ok(APIResponse.Send("000", "[푸시 변경] : PUSH 정보 변경 완료", Empty));
|
return Ok(APIResponse.Send("000", $"[{summary}], 정상", Empty));
|
||||||
|
// TODO - 로그 추가
|
||||||
}
|
}
|
||||||
|
|
||||||
return Ok(APIResponse.Send("100", "PID, BID 또는 Cabinet 오류", Empty));
|
return Ok(APIResponse.Send("100", $"[{summary}], PID, BID 또는 Cabinet 오류", Empty));
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
_logger.LogError($"[푸시] {ex.Message}");
|
_logger.LogError($"[{summary}] : {ex.Message}");
|
||||||
return StatusCode(500, APIResponse.UnknownError());
|
return StatusCode(500, APIResponse.UnknownError());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -277,32 +260,32 @@ public class PushController : ControllerBase
|
||||||
pid = payload.pid,
|
pid = payload.pid,
|
||||||
create_uid = uid,
|
create_uid = uid,
|
||||||
create_date = DateTime.Now,
|
create_date = DateTime.Now,
|
||||||
log = $"[{summary}] {payload.pid} 최초 생성 - {uid}"
|
log = $"[{summary}] : {payload.pid} 최초 생성 - {uid}"
|
||||||
};
|
};
|
||||||
|
|
||||||
// 로그를 이제 만들어서 추가를 해야 합니다.
|
// 로그를 이제 만들어서 추가를 해야 합니다.
|
||||||
if (await _repositoryService.SaveData<LogPush>(logPush))
|
if (await _repositoryService.SaveData<LogPush>(logPush))
|
||||||
_logger.LogInformation("[푸시 생성] 로그 추가");
|
_logger.LogInformation($"[{summary}] : 로그 추가");
|
||||||
|
|
||||||
return Ok(APIResponse.Send("000", "정상, push 저장 완료", Empty));
|
return Ok(APIResponse.Send("000", $"[{summary}], 정상", Empty));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
return Ok(APIResponse.Send("100", "학원 정보(BID) 확인 불가", Empty));
|
return Ok(APIResponse.Send("100", $"[{summary}], 학원 정보(BID) 확인 불가", Empty));
|
||||||
}
|
}
|
||||||
catch (TokenException tokenEx)
|
catch (TokenException tokenEx)
|
||||||
{
|
{
|
||||||
_logger.LogInformation($"[푸시 생성] : {tokenEx}");
|
_logger.LogInformation($"[{summary}] : {tokenEx}");
|
||||||
return Ok(APIResponse.Send("001", "[푸시 생성] : 토큰에 문제가 있음",Empty));
|
return Ok(APIResponse.Send("001", $"[{summary}], 토큰에 문제가 있음",Empty));
|
||||||
}
|
}
|
||||||
catch (RefreshRevokeException refreshEx)
|
catch (RefreshRevokeException refreshEx)
|
||||||
{
|
{
|
||||||
_logger.LogInformation($"[푸시 생성] : {refreshEx}");
|
_logger.LogInformation($"[{summary}] : {refreshEx}");
|
||||||
return Ok(APIResponse.Send("001", "[푸시 생성] : 폐기된 리프레시 토큰",Empty));
|
return Ok(APIResponse.Send("001", $"[{summary}], 폐기된 리프레시 토큰",Empty));
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
_logger.LogError($"[푸시] {ex.Message}");
|
_logger.LogError($"[{summary}] : {ex.Message}");
|
||||||
return StatusCode(500, APIResponse.UnknownError());
|
return StatusCode(500, APIResponse.UnknownError());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user