admin: add common-code crud and business-day rules
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using TaxBaik.Application.Services;
|
||||
using TaxBaik.Domain.Entities;
|
||||
|
||||
namespace TaxBaik.Web.Controllers;
|
||||
|
||||
@@ -36,4 +37,44 @@ public class CommonCodeController(CommonCodeService commonCodeService) : Control
|
||||
return StatusCode(500, new { error = "그룹별 공통코드 조회 실패", message = ex.Message });
|
||||
}
|
||||
}
|
||||
|
||||
[HttpGet("groups")]
|
||||
public async Task<IActionResult> GetGroups()
|
||||
{
|
||||
try
|
||||
{
|
||||
var groups = await commonCodeService.GetAllGroupsAsync();
|
||||
return Ok(groups);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return StatusCode(500, new { error = "공통코드 그룹 조회 실패", message = ex.Message });
|
||||
}
|
||||
}
|
||||
|
||||
[HttpGet("{group}/{value}")]
|
||||
public async Task<IActionResult> Get(string group, string value)
|
||||
{
|
||||
var code = await commonCodeService.GetAsync(group, value);
|
||||
return code is null ? NotFound() : Ok(code);
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public async Task<IActionResult> Upsert([FromBody] CommonCode code)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(code.CodeGroup) || string.IsNullOrWhiteSpace(code.CodeValue) || string.IsNullOrWhiteSpace(code.CodeName))
|
||||
return BadRequest(new { error = "코드 그룹, 값, 이름은 필수입니다." });
|
||||
if (code.CodeValue.Contains(' '))
|
||||
return BadRequest(new { error = "code_value에는 공백을 사용할 수 없습니다." });
|
||||
|
||||
await commonCodeService.UpsertAsync(code);
|
||||
return Ok(code);
|
||||
}
|
||||
|
||||
[HttpDelete("{group}/{value}")]
|
||||
public async Task<IActionResult> Delete(string group, string value)
|
||||
{
|
||||
await commonCodeService.DeleteAsync(group, value);
|
||||
return NoContent();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user