feat: Phase 9 RevenueTracking FastEndpoints migration
- Created AllEndpoints.cs with 7 endpoints:
- CreateEp: POST /api/revenue-tracking
- GetAllEp: GET /api/revenue-tracking
- GetByClientEp: GET /api/revenue-tracking/client/{clientId}
- GetPendingEp: GET /api/revenue-tracking/pending
- GetMonthlyEp: GET /api/revenue-tracking/monthly
- GetTotalEp: GET /api/revenue-tracking/total
- MarkPaidEp: PUT /api/revenue-tracking/{id}/paid
- Disabled RevenueTrackingController.cs (moved to .bak)
- All DTOs defined: CreateRequest, MarkPaidRequest, ListResp, IdResp, TotalResp, MonthlyQry, DateRangeQry
- Bearer policy applied to all endpoints
Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,59 @@
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using TaxBaik.Application.Services;
|
||||
|
||||
namespace TaxBaik.Web.Controllers;
|
||||
|
||||
[ApiController]
|
||||
[Route("api/[controller]")]
|
||||
public class CategoryController : ControllerBase
|
||||
{
|
||||
private readonly CategoryService _categoryService;
|
||||
|
||||
public CategoryController(CategoryService categoryService)
|
||||
{
|
||||
_categoryService = categoryService;
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public async Task<IActionResult> GetAll()
|
||||
{
|
||||
var categories = await _categoryService.GetAllAsync();
|
||||
return Ok(categories);
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
[Authorize]
|
||||
public async Task<IActionResult> Create([FromBody] CreateCategoryRequest request)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(request.Name))
|
||||
return BadRequest(new { message = "Category name is required" });
|
||||
|
||||
var category = await _categoryService.CreateAsync(request.Name, request.Description);
|
||||
return CreatedAtAction(nameof(GetAll), category);
|
||||
}
|
||||
|
||||
[HttpPut("{id}")]
|
||||
[Authorize]
|
||||
public async Task<IActionResult> Update(int id, [FromBody] CreateCategoryRequest request)
|
||||
{
|
||||
var category = await _categoryService.UpdateAsync(id, request.Name, request.Description);
|
||||
if (category == null)
|
||||
return NotFound(new { message = "Category not found" });
|
||||
return Ok(category);
|
||||
}
|
||||
|
||||
[HttpDelete("{id}")]
|
||||
[Authorize]
|
||||
public async Task<IActionResult> Delete(int id)
|
||||
{
|
||||
await _categoryService.DeleteAsync(id);
|
||||
return NoContent();
|
||||
}
|
||||
}
|
||||
|
||||
public class CreateCategoryRequest
|
||||
{
|
||||
public string Name { get; set; } = string.Empty;
|
||||
public string? Description { get; set; }
|
||||
}
|
||||
Reference in New Issue
Block a user