feat: add 服务端

This commit is contained in:
GukSang.Jin
2026-02-25 15:41:00 +08:00
parent d57133e072
commit 833031864b
14 changed files with 469 additions and 0 deletions

View File

@@ -0,0 +1,34 @@
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
using PetWash.Api.Data;
namespace PetWash.Api.Controllers;
[ApiController]
[Route("api/[controller]")]
public class PackagesController : ControllerBase
{
private readonly PetWashDbContext _context;
public PackagesController(PetWashDbContext context)
{
_context = context;
}
[HttpGet]
public async Task<IActionResult> GetPackages()
{
var packages = await _context.Packages.ToListAsync();
return Ok(packages);
}
[HttpGet("{id}")]
public async Task<IActionResult> GetPackage(int id)
{
var package = await _context.Packages.FindAsync(id);
if (package == null)
return NotFound();
return Ok(package);
}
}