Initial commit: Purrse personal finance app
Self-hosted, plugin-extensible personal finance manager built with ASP.NET Core 9.0, Vue 3 + Vuetify 3, and PostgreSQL 17. Backend (8 .NET projects): - Core: 19 domain models, 6 enums, 14 DTOs, 12 service interfaces - Data: EF Core DbContext, 16 entity configurations, category seeder - API: 14 controllers, 15 services, JWT auth, SignalR, middleware - Plugins: Abstractions + OFX/CSV/QIF file parsers - Tests: 28 xUnit tests (fingerprinting, duplicate detection, parsers) Frontend (Vue 3 + Vuetify 3 + TypeScript): - 13 views, Pinia stores, Axios API services with JWT interceptors - Dashboard, accounts, transactions, categories, imports, and more Deployment: - Docker Compose (PostgreSQL 17 + .NET API + nginx frontend) - Auto-migration on startup Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,51 @@
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Purrse.Core.DTOs;
|
||||
using Purrse.Core.Interfaces.Services;
|
||||
using System.Security.Claims;
|
||||
|
||||
namespace Purrse.Api.Controllers;
|
||||
|
||||
[Authorize]
|
||||
[ApiController]
|
||||
[Route("api/[controller]")]
|
||||
public class CategoriesController : ControllerBase
|
||||
{
|
||||
private readonly ICategoryService _categoryService;
|
||||
private Guid UserId => Guid.Parse(User.FindFirstValue(ClaimTypes.NameIdentifier)!);
|
||||
|
||||
public CategoriesController(ICategoryService categoryService) => _categoryService = categoryService;
|
||||
|
||||
[HttpGet]
|
||||
public async Task<ActionResult<List<CategoryResponse>>> GetAll()
|
||||
=> Ok(await _categoryService.GetAllAsync(UserId));
|
||||
|
||||
[HttpGet("tree")]
|
||||
public async Task<ActionResult<List<CategoryTreeResponse>>> GetTree()
|
||||
=> Ok(await _categoryService.GetTreeAsync(UserId));
|
||||
|
||||
[HttpGet("{id}")]
|
||||
public async Task<ActionResult<CategoryResponse>> GetById(Guid id)
|
||||
{
|
||||
var cat = await _categoryService.GetByIdAsync(UserId, id);
|
||||
return cat == null ? NotFound() : Ok(cat);
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public async Task<ActionResult<CategoryResponse>> Create(CreateCategoryRequest request)
|
||||
{
|
||||
var cat = await _categoryService.CreateAsync(UserId, request);
|
||||
return CreatedAtAction(nameof(GetById), new { id = cat.Id }, cat);
|
||||
}
|
||||
|
||||
[HttpPut("{id}")]
|
||||
public async Task<ActionResult<CategoryResponse>> Update(Guid id, UpdateCategoryRequest request)
|
||||
=> Ok(await _categoryService.UpdateAsync(UserId, id, request));
|
||||
|
||||
[HttpDelete("{id}")]
|
||||
public async Task<ActionResult> Delete(Guid id)
|
||||
{
|
||||
await _categoryService.DeleteAsync(UserId, id);
|
||||
return NoContent();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user