Add Razor customer CRUD shell
TaxBaik CI/CD / build-and-deploy (push) Failing after 2m23s

This commit is contained in:
2026-07-09 11:14:12 +09:00
parent 83c0c70adc
commit fb8a90fa6b
12 changed files with 442 additions and 0 deletions
@@ -0,0 +1,66 @@
@page
@model TaxBaik.Web.Pages.Admin.Customers.CreateModel
@{
ViewData["Title"] = "고객 등록";
}
<section class="container py-4 py-lg-5">
<div class="mb-4">
<p class="text-uppercase text-muted small mb-2">Customer Management</p>
<h1 class="h2 fw-bold mb-1">고객 등록</h1>
</div>
<form method="post" class="card shadow-sm border-0">
<div class="card-body">
<div asp-validation-summary="All" class="alert alert-danger"></div>
<div class="row g-3">
<div class="col-md-6">
<label asp-for="Input.Name" class="form-label"></label>
<input asp-for="Input.Name" class="form-control" />
<span asp-validation-for="Input.Name" class="text-danger small"></span>
</div>
<div class="col-md-6">
<label asp-for="Input.CompanyName" class="form-label"></label>
<input asp-for="Input.CompanyName" class="form-control" />
<span asp-validation-for="Input.CompanyName" class="text-danger small"></span>
</div>
<div class="col-md-6">
<label asp-for="Input.Phone" class="form-label"></label>
<input asp-for="Input.Phone" class="form-control" />
<span asp-validation-for="Input.Phone" class="text-danger small"></span>
</div>
<div class="col-md-6">
<label asp-for="Input.Email" class="form-label"></label>
<input asp-for="Input.Email" class="form-control" />
<span asp-validation-for="Input.Email" class="text-danger small"></span>
</div>
<div class="col-md-4">
<label asp-for="Input.Status" class="form-label"></label>
<input asp-for="Input.Status" class="form-control" />
<span asp-validation-for="Input.Status" class="text-danger small"></span>
</div>
<div class="col-md-4">
<label asp-for="Input.ServiceType" class="form-label"></label>
<input asp-for="Input.ServiceType" class="form-control" />
</div>
<div class="col-md-4">
<label asp-for="Input.TaxType" class="form-label"></label>
<input asp-for="Input.TaxType" class="form-control" />
</div>
<div class="col-12">
<label asp-for="Input.Source" class="form-label"></label>
<input asp-for="Input.Source" class="form-control" />
</div>
<div class="col-12">
<label asp-for="Input.Memo" class="form-label"></label>
<textarea asp-for="Input.Memo" class="form-control" rows="5"></textarea>
</div>
</div>
</div>
<div class="card-footer bg-white d-flex justify-content-end gap-2">
<a class="btn btn-outline-secondary" href="/admin/customers">취소</a>
<button class="btn btn-dark" type="submit">저장</button>
</div>
</form>
</section>
@@ -0,0 +1,27 @@
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.RazorPages;
using TaxBaik.Application.DTOs;
using TaxBaik.Application.Services;
using TaxBaik.Web.Services;
namespace TaxBaik.Web.Pages.Admin.Customers;
[Authorize(AuthenticationSchemes = AdminAuthDefaults.Scheme)]
public class CreateModel(ClientService clientService) : PageModel
{
[BindProperty]
public CreateClientDto Input { get; set; } = new();
public IActionResult OnGet() => Page();
public async Task<IActionResult> OnPostAsync(CancellationToken ct)
{
if (!ModelState.IsValid)
return Page();
await clientService.CreateAsync(Input, ct);
return RedirectToPage("/Admin/Customers/Index");
}
}
@@ -0,0 +1,44 @@
@page "{id:int}"
@model TaxBaik.Web.Pages.Admin.Customers.DetailModel
@{
ViewData["Title"] = "고객 상세";
}
<section class="container py-4 py-lg-5">
@if (Model.Client is null)
{
<div class="alert alert-warning">고객을 찾을 수 없습니다.</div>
}
else
{
<div class="d-flex flex-wrap justify-content-between align-items-end gap-3 mb-4">
<div>
<p class="text-uppercase text-muted small mb-2">Customer Management</p>
<h1 class="h2 fw-bold mb-1">@Model.Client.Name</h1>
<p class="text-muted mb-0">고객 기본 정보와 변경 이력을 확인합니다.</p>
</div>
<div class="d-flex gap-2">
<a class="btn btn-outline-secondary" href="/admin/customers/@Model.Client.Id/edit">수정</a>
<a class="btn btn-dark" href="/admin/customers">목록</a>
</div>
</div>
<div class="card shadow-sm border-0">
<div class="card-body">
<dl class="row mb-0">
<dt class="col-sm-3">회사명</dt><dd class="col-sm-9">@Model.Client.CompanyName</dd>
<dt class="col-sm-3">전화</dt><dd class="col-sm-9">@Model.Client.Phone</dd>
<dt class="col-sm-3">이메일</dt><dd class="col-sm-9">@Model.Client.Email</dd>
<dt class="col-sm-3">상태</dt><dd class="col-sm-9">@Model.Client.Status</dd>
<dt class="col-sm-3">서비스 유형</dt><dd class="col-sm-9">@Model.Client.ServiceType</dd>
<dt class="col-sm-3">세금 유형</dt><dd class="col-sm-9">@Model.Client.TaxType</dd>
<dt class="col-sm-3">유입 경로</dt><dd class="col-sm-9">@Model.Client.Source</dd>
<dt class="col-sm-3">메모</dt><dd class="col-sm-9">@Model.Client.Memo</dd>
<dt class="col-sm-3">생성일</dt><dd class="col-sm-9">@Model.Client.CreatedAt.ToString("yyyy-MM-dd HH:mm")</dd>
<dt class="col-sm-3">수정일</dt><dd class="col-sm-9">@Model.Client.UpdatedAt.ToString("yyyy-MM-dd HH:mm")</dd>
</dl>
</div>
</div>
}
</section>
@@ -0,0 +1,17 @@
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc.RazorPages;
using TaxBaik.Application.Services;
using TaxBaik.Web.Services;
namespace TaxBaik.Web.Pages.Admin.Customers;
[Authorize(AuthenticationSchemes = AdminAuthDefaults.Scheme)]
public class DetailModel(ClientService clientService) : PageModel
{
public TaxBaik.Domain.Entities.Client? Client { get; private set; }
public async Task OnGetAsync(int id, CancellationToken ct)
{
Client = await clientService.GetByIdAsync(id, ct);
}
}
@@ -0,0 +1,65 @@
@page "{id:int}"
@model TaxBaik.Web.Pages.Admin.Customers.EditModel
@{
ViewData["Title"] = "고객 수정";
}
<section class="container py-4 py-lg-5">
<div class="mb-4">
<p class="text-uppercase text-muted small mb-2">Customer Management</p>
<h1 class="h2 fw-bold mb-1">고객 수정</h1>
</div>
<form method="post" class="card shadow-sm border-0">
<div class="card-body">
<div asp-validation-summary="All" class="alert alert-danger"></div>
<input type="hidden" asp-for="Id" />
<div class="row g-3">
<div class="col-md-6">
<label asp-for="Input.Name" class="form-label"></label>
<input asp-for="Input.Name" class="form-control" />
<span asp-validation-for="Input.Name" class="text-danger small"></span>
</div>
<div class="col-md-6">
<label asp-for="Input.CompanyName" class="form-label"></label>
<input asp-for="Input.CompanyName" class="form-control" />
</div>
<div class="col-md-6">
<label asp-for="Input.Phone" class="form-label"></label>
<input asp-for="Input.Phone" class="form-control" />
</div>
<div class="col-md-6">
<label asp-for="Input.Email" class="form-label"></label>
<input asp-for="Input.Email" class="form-control" />
</div>
<div class="col-md-4">
<label asp-for="Input.Status" class="form-label"></label>
<input asp-for="Input.Status" class="form-control" />
</div>
<div class="col-md-4">
<label asp-for="Input.ServiceType" class="form-label"></label>
<input asp-for="Input.ServiceType" class="form-control" />
</div>
<div class="col-md-4">
<label asp-for="Input.TaxType" class="form-label"></label>
<input asp-for="Input.TaxType" class="form-control" />
</div>
<div class="col-12">
<label asp-for="Input.Source" class="form-label"></label>
<input asp-for="Input.Source" class="form-control" />
</div>
<div class="col-12">
<label asp-for="Input.Memo" class="form-label"></label>
<textarea asp-for="Input.Memo" class="form-control" rows="5"></textarea>
</div>
</div>
</div>
<div class="card-footer bg-white d-flex justify-content-between gap-2">
<div class="d-flex gap-2">
<button class="btn btn-outline-danger" type="submit" formaction="?handler=Delete" formmethod="post" onclick="return confirm('삭제하시겠습니까?');">삭제</button>
<a class="btn btn-outline-secondary" href="/admin/customers/@Model.Id">취소</a>
<button class="btn btn-dark" type="submit">저장</button>
</div>
</div>
</form>
</section>
@@ -0,0 +1,56 @@
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.RazorPages;
using TaxBaik.Application.DTOs;
using TaxBaik.Application.Services;
using TaxBaik.Web.Services;
namespace TaxBaik.Web.Pages.Admin.Customers;
[Authorize(AuthenticationSchemes = AdminAuthDefaults.Scheme)]
public class EditModel(ClientService clientService) : PageModel
{
[BindProperty(SupportsGet = true)]
public int Id { get; set; }
[BindProperty]
public CreateClientDto Input { get; set; } = new();
public async Task<IActionResult> OnGetAsync(CancellationToken ct)
{
var client = await clientService.GetByIdAsync(Id, ct);
if (client is null)
return NotFound();
Input = new CreateClientDto
{
Name = client.Name,
CompanyName = client.CompanyName,
Phone = client.Phone,
Email = client.Email,
ServiceType = client.ServiceType,
TaxType = client.TaxType,
Status = client.Status,
Source = client.Source,
Memo = client.Memo
};
return Page();
}
public async Task<IActionResult> OnPostAsync(CancellationToken ct)
{
if (!ModelState.IsValid)
return Page();
await clientService.UpdateAsync(Id, Input, ct);
return RedirectToPage("/Admin/Customers/Detail", new { id = Id });
}
public async Task<IActionResult> OnPostDeleteAsync(CancellationToken ct)
{
await clientService.DeleteAsync(Id, ct);
return RedirectToPage("/Admin/Customers/Index");
}
}
@@ -0,0 +1,90 @@
@page
@model TaxBaik.Web.Pages.Admin.Customers.IndexModel
@{
ViewData["Title"] = "고객 목록";
}
<section class="container py-4 py-lg-5">
<div class="d-flex flex-wrap justify-content-between align-items-end gap-3 mb-4">
<div>
<p class="text-uppercase text-muted small mb-2">Customer Management</p>
<h1 class="h2 fw-bold mb-1">고객 목록</h1>
<p class="text-muted mb-0">검색, 상태 필터, 페이지네이션 기준의 고객 목록입니다.</p>
</div>
<a class="btn btn-dark" href="/admin/customers/create">고객 등록</a>
</div>
<form method="get" class="card shadow-sm border-0 mb-4">
<div class="card-body">
<div class="row g-3 align-items-end">
<div class="col-md-4">
<label class="form-label" for="Search">검색</label>
<input class="form-control" id="Search" name="Search" value="@Model.Search" placeholder="이름, 전화, 회사명" />
</div>
<div class="col-md-3">
<label class="form-label" for="Status">상태</label>
<select class="form-select" id="Status" name="Status">
<option value="" selected="@(string.IsNullOrWhiteSpace(Model.Status))">전체</option>
<option value="active" selected="@(Model.Status == "active")">active</option>
<option value="inactive" selected="@(Model.Status == "inactive")">inactive</option>
</select>
</div>
<div class="col-md-2">
<label class="form-label" for="PageSize">페이지 크기</label>
<select class="form-select" id="PageSize" name="PageSize">
<option value="10" selected="@(Model.PageSize == 10)">10</option>
<option value="20" selected="@(Model.PageSize == 20)">20</option>
<option value="50" selected="@(Model.PageSize == 50)">50</option>
</select>
</div>
<div class="col-md-3 d-grid d-sm-flex gap-2">
<button class="btn btn-dark" type="submit">검색</button>
<a class="btn btn-outline-secondary" href="/admin/customers">초기화</a>
</div>
</div>
</div>
</form>
<div class="card shadow-sm border-0">
<div class="table-responsive">
<table class="table table-hover align-middle mb-0">
<thead class="table-light">
<tr>
<th>고객명</th>
<th>회사명</th>
<th>전화</th>
<th>상태</th>
<th>등록일</th>
<th class="text-end">작업</th>
</tr>
</thead>
<tbody>
@if (Model.Items.Count == 0)
{
<tr>
<td colspan="6" class="text-center text-muted py-5">고객 데이터가 없습니다.</td>
</tr>
}
else
{
foreach (var item in Model.Items)
{
<tr>
<td class="fw-semibold">@item.Name</td>
<td>@item.CompanyName</td>
<td>@item.Phone</td>
<td><span class="badge text-bg-secondary">@item.Status</span></td>
<td>@item.CreatedAt.ToString("yyyy-MM-dd")</td>
<td class="text-end">
<a class="btn btn-sm btn-outline-secondary" href="/admin/customers/@item.Id">상세</a>
<a class="btn btn-sm btn-outline-primary" href="/admin/customers/@item.Id/edit">수정</a>
</td>
</tr>
}
}
</tbody>
</table>
</div>
</div>
</section>
@@ -0,0 +1,26 @@
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc.RazorPages;
using TaxBaik.Application.Services;
using TaxBaik.Web.Services;
namespace TaxBaik.Web.Pages.Admin.Customers;
[Authorize(AuthenticationSchemes = AdminAuthDefaults.Scheme)]
public class IndexModel(ClientService clientService) : PageModel
{
public List<TaxBaik.Domain.Entities.Client> Items { get; private set; } = [];
public string? Search { get; set; }
public string? Status { get; set; }
public int PageSize { get; set; } = 10;
public async Task OnGetAsync(string? search, string? status, int pageSize = 10, CancellationToken ct = default)
{
Search = search;
Status = status;
PageSize = pageSize;
var (items, _) = await clientService.GetPagedAsync(1, pageSize, status, search, ct);
Items = items.ToList();
}
}