35 lines
1.1 KiB
C#
35 lines
1.1 KiB
C#
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
|
|
});
|
|
}
|
|
}
|
|
} |