Swagger UI

This commit is contained in:
2025-04-09 00:11:45 +08:00
parent c39fdceeb6
commit e90357d153
5 changed files with 34 additions and 7 deletions

View File

@ -1,5 +1,6 @@
using System.ComponentModel.DataAnnotations;
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
namespace DysonNetwork.Sphere.Account;
@ -12,8 +13,8 @@ public class AccountController(AppDatabase db)
[ProducesResponseType(StatusCodes.Status404NotFound)]
public async Task<ActionResult<Account?>> GetByName(string name)
{
var account = await db.Accounts.FindAsync(name);
return account;
var account = await db.Accounts.Where(a => a.Name == name).FirstOrDefaultAsync();
return account is null ? new NotFoundResult() : account;
}
public class AccountCreateRequest
@ -32,9 +33,9 @@ public class AccountController(AppDatabase db)
{
Name = request.Name,
Nick = request.Nick,
Contacts = new List<AccountContact>()
Contacts = new List<AccountContact>
{
new AccountContact
new()
{
Type = AccountContactType.Email,
Content = request.Email