feat: implement remaining API controllers for CRM and tax accounting
TaxBaik CI/CD / build-and-deploy (push) Successful in 50s
TaxBaik CI/CD / build-and-deploy (push) Successful in 50s
Phase 4 Complete: 4 remaining API Controllers
- TaxFilingScheduleController: schedule CRUD + upcoming dues + completion marking
- ConsultingActivityController: activity logging + pending followups + consultant tracking
- ContractController: contract lifecycle + active/expiring tracking + MRR endpoint
- RevenueTrackingController: invoice/payment tracking + pending payments + monthly/total revenue
All controllers follow RESTful patterns with:
- [Authorize] attribute for access control
- Proper error handling with ValidationException catching
- Record-based request/response DTOs
- Consistent HTTP status codes (201, 400, 404, 500)
Build Status: ✅ Success (0 errors, 3 warnings)
This commit is contained in:
@@ -0,0 +1,102 @@
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using TaxBaik.Application.Services;
|
||||
|
||||
namespace TaxBaik.Web.Controllers;
|
||||
|
||||
[ApiController]
|
||||
[Route("api/[controller]")]
|
||||
[Authorize]
|
||||
public class ContractController(ContractService service) : ControllerBase
|
||||
{
|
||||
[HttpPost]
|
||||
public async Task<IActionResult> Create([FromBody] CreateContractRequest request)
|
||||
{
|
||||
try
|
||||
{
|
||||
var id = await service.CreateAsync(request.ClientId, request.ContractNumber, request.ServiceType,
|
||||
request.StartDate, request.MonthlyFee, request.TotalAmount);
|
||||
return CreatedAtAction(nameof(GetById), new { id }, new { id });
|
||||
}
|
||||
catch (ValidationException ex)
|
||||
{
|
||||
return BadRequest(new { error = ex.Message });
|
||||
}
|
||||
}
|
||||
|
||||
[HttpGet("{id:int}")]
|
||||
public async Task<IActionResult> GetById(int id)
|
||||
{
|
||||
try
|
||||
{
|
||||
var contract = await service.GetByIdAsync(id);
|
||||
if (contract == null)
|
||||
return NotFound(new { error = "계약을 찾을 수 없습니다." });
|
||||
return Ok(contract);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return StatusCode(500, new { error = "조회 실패", message = ex.Message });
|
||||
}
|
||||
}
|
||||
|
||||
[HttpGet("client/{clientId:int}")]
|
||||
public async Task<IActionResult> GetByClientId(int clientId)
|
||||
{
|
||||
try
|
||||
{
|
||||
var contracts = await service.GetByClientIdAsync(clientId);
|
||||
return Ok(new { data = contracts });
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return StatusCode(500, new { error = "조회 실패", message = ex.Message });
|
||||
}
|
||||
}
|
||||
|
||||
[HttpGet("active")]
|
||||
public async Task<IActionResult> GetActiveContracts()
|
||||
{
|
||||
try
|
||||
{
|
||||
var contracts = await service.GetActiveContractsAsync();
|
||||
return Ok(new { data = contracts });
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return StatusCode(500, new { error = "조회 실패", message = ex.Message });
|
||||
}
|
||||
}
|
||||
|
||||
[HttpGet("expiring")]
|
||||
public async Task<IActionResult> GetExpiringContracts([FromQuery] int daysAhead = 30)
|
||||
{
|
||||
try
|
||||
{
|
||||
var contracts = await service.GetExpiringContractsAsync(daysAhead);
|
||||
return Ok(new { data = contracts, daysAhead });
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return StatusCode(500, new { error = "조회 실패", message = ex.Message });
|
||||
}
|
||||
}
|
||||
|
||||
[HttpGet("mrr")]
|
||||
public async Task<IActionResult> GetMonthlyRecurringRevenue()
|
||||
{
|
||||
try
|
||||
{
|
||||
var mrr = await service.GetMonthlyRecurringRevenueAsync();
|
||||
return Ok(new { mrr });
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return StatusCode(500, new { error = "조회 실패", message = ex.Message });
|
||||
}
|
||||
}
|
||||
|
||||
public record CreateContractRequest(
|
||||
int ClientId, string ContractNumber, string ServiceType, DateTime StartDate,
|
||||
decimal? MonthlyFee = null, decimal? TotalAmount = null);
|
||||
}
|
||||
Reference in New Issue
Block a user