e22cfb1ac5
TaxBaik CI/CD / build-and-deploy (push) Failing after 43s
4개 API 컨트롤러 구현: ✅ AuthController: POST /api/auth/login ✅ BlogController: GET/POST/PUT/DELETE /api/blog ✅ CategoryController: GET/POST/PUT/DELETE /api/category ✅ InquiryController: POST/GET/PUT /api/inquiry 아키텍처 개선: - Application 서비스 레이어 확장 (CategoryService 추가) - Repository 인터페이스 CRUD 지원 추가 - Program.cs에 MapControllers() 추가 - 비즈니스 로직과 UI 완전 분리 장점: - 향후 UI 리뉴얼 시 API 변경 불필요 - 모바일 앱, 데스크톱 클라이언트 추가 가능 - 테스트 가능한 API 엔드포인트 테스트 결과: ✅ 블로그 API: 5개 포스트 조회 ✅ 카테고리 API: 5개 카테고리 조회 ✅ 문의 API: 문의 제출 성공 ⚠️ 인증 API: 예정된 수정 대기 Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
75 lines
2.4 KiB
C#
75 lines
2.4 KiB
C#
using Microsoft.AspNetCore.Authorization;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
using TaxBaik.Application.Services;
|
|
using TaxBaik.Domain.Interfaces;
|
|
|
|
namespace TaxBaik.Web.Controllers;
|
|
|
|
[ApiController]
|
|
[Route("api/[controller]")]
|
|
public class InquiryController : ControllerBase
|
|
{
|
|
private readonly InquiryService _inquiryService;
|
|
private readonly IInquiryRepository _inquiryRepository;
|
|
|
|
public InquiryController(InquiryService inquiryService, IInquiryRepository inquiryRepository)
|
|
{
|
|
_inquiryService = inquiryService;
|
|
_inquiryRepository = inquiryRepository;
|
|
}
|
|
|
|
[HttpPost]
|
|
public async Task<IActionResult> Submit([FromBody] SubmitInquiryRequest request)
|
|
{
|
|
if (string.IsNullOrWhiteSpace(request.Name) || string.IsNullOrWhiteSpace(request.Phone))
|
|
return BadRequest(new { message = "Name and phone are required" });
|
|
|
|
await _inquiryService.SubmitAsync(request.Name, request.Phone, request.ServiceType, request.Message);
|
|
return Ok(new { message = "Inquiry submitted successfully" });
|
|
}
|
|
|
|
[HttpGet]
|
|
[Authorize]
|
|
public async Task<IActionResult> GetPaged([FromQuery] int page = 1, [FromQuery] int pageSize = 20)
|
|
{
|
|
var (inquiries, total) = await _inquiryRepository.GetPagedAsync(page, pageSize);
|
|
return Ok(new { data = inquiries, total, page, pageSize });
|
|
}
|
|
|
|
[HttpGet("{id}")]
|
|
[Authorize]
|
|
public async Task<IActionResult> GetById(int id)
|
|
{
|
|
var inquiry = await _inquiryRepository.GetByIdAsync(id);
|
|
if (inquiry == null)
|
|
return NotFound(new { message = "Inquiry not found" });
|
|
return Ok(inquiry);
|
|
}
|
|
|
|
[HttpPut("{id}/status")]
|
|
[Authorize]
|
|
public async Task<IActionResult> UpdateStatus(int id, [FromBody] UpdateStatusRequest request)
|
|
{
|
|
var inquiry = await _inquiryRepository.GetByIdAsync(id);
|
|
if (inquiry == null)
|
|
return NotFound(new { message = "Inquiry not found" });
|
|
|
|
await _inquiryRepository.UpdateStatusAsync(id, request.Status);
|
|
return Ok(new { message = "Status updated" });
|
|
}
|
|
}
|
|
|
|
public class SubmitInquiryRequest
|
|
{
|
|
public string Name { get; set; } = string.Empty;
|
|
public string Phone { get; set; } = string.Empty;
|
|
public string? Email { get; set; }
|
|
public string ServiceType { get; set; } = string.Empty;
|
|
public string Message { get; set; } = string.Empty;
|
|
}
|
|
|
|
public class UpdateStatusRequest
|
|
{
|
|
public string Status { get; set; } = string.Empty;
|
|
}
|