Genesis Game Server Project Setup
This commit is contained in:
35
GameServer/Controllers/CharacterController.cs
Normal file
35
GameServer/Controllers/CharacterController.cs
Normal file
@@ -0,0 +1,35 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using GameServer.Data; // DbContext가 있는 폴더
|
||||
using GameServer.Models; // Model이 있는 폴더
|
||||
|
||||
namespace GameServer.Controllers
|
||||
{
|
||||
[ApiController]
|
||||
[Route("myGame")] // 접속 주소: /myGame
|
||||
public class CharacterController : ControllerBase
|
||||
{
|
||||
private readonly AppDbContext _context;
|
||||
|
||||
// DB 연결 도구(Context)를 가져옵니다.
|
||||
public CharacterController(AppDbContext context)
|
||||
{
|
||||
_context = context;
|
||||
}
|
||||
|
||||
// 플레이어블 캐릭터 목록
|
||||
[HttpGet("playableCharacters")]
|
||||
public async Task<IActionResult> GetPlayableCharacters()
|
||||
{
|
||||
List<CharacterModel> list = await _context.Characters
|
||||
.Where(x => x.CharacterType == "PLAYABLE")
|
||||
.ToListAsync();
|
||||
|
||||
return Ok(new ApiResponse<List<CharacterModel>>
|
||||
{
|
||||
Data = list,
|
||||
Count = list.Count
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user