199 lines
8.0 KiB
C#
199 lines
8.0 KiB
C#
using System.Globalization;
|
|
using Asp.Versioning;
|
|
using Microsoft.AspNetCore.Authorization;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
using Swashbuckle.AspNetCore.Annotations;
|
|
using UGQApiServer.Converter;
|
|
using UGQApiServer.Models;
|
|
using UGQApiServer.UGQData;
|
|
using UGQDataAccess;
|
|
using ServerCommon.UGQ;
|
|
using ServerCommon.UGQ.Models;
|
|
using ServerCommon;
|
|
using UGQApiServer.Auth;
|
|
using System.Collections.Generic;
|
|
using System.Text.Json;
|
|
using System.Text.Json.Serialization;
|
|
using UGQApiServer.Controllers.Common;
|
|
using MetaAssets;
|
|
using ServerBase;
|
|
|
|
|
|
namespace UGQApiServer.Controllers
|
|
{
|
|
[Authorize]
|
|
[ApiController]
|
|
[ApiVersion("1.0")]
|
|
[Route("api/v{version:apiVersion}/[controller]")]
|
|
[UGQWebApi]
|
|
[AllowWhenSingleLogin]
|
|
public class MetaDataController : ControllerBase
|
|
{
|
|
const int PAGE_SIZE = 30;
|
|
UGQMetaData _ugqMetaData;
|
|
DynamoDbClient _dynamoDbClient;
|
|
|
|
MetaDataApi _metaDataApi;
|
|
|
|
public MetaDataController(UGQMetaData ugqMetaData,
|
|
DynamoDbClient dynamoDbClient,
|
|
MetaDataApi metaDataApi)
|
|
{
|
|
_ugqMetaData = ugqMetaData;
|
|
_dynamoDbClient = dynamoDbClient;
|
|
_metaDataApi = metaDataApi;
|
|
}
|
|
|
|
string? userGuidFromToken()
|
|
{
|
|
return User.Claims.FirstOrDefault(c => c.Type == "Id")?.Value;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 사용가능한 시작 npc 가져오기
|
|
/// </summary>
|
|
/// <param name="pageNumber">페이지</param>
|
|
/// <param name="pageSize">pageSize (최대 100)</param>
|
|
[HttpGet]
|
|
[Route("assignable-npcs")]
|
|
[Produces("application/json")]
|
|
[SwaggerResponse(StatusCodes.Status200OK, Type = typeof(UGQNpcMetaDataList))]
|
|
[SwaggerResponse(StatusCodes.Status400BadRequest, Type = typeof(ApiErrorResponse))]
|
|
public async Task<IResult> getAssignableNpcs([FromQuery] int pageNumber, [FromQuery] int pageSize)
|
|
{
|
|
var userGuid = userGuidFromToken();
|
|
if (userGuid == null)
|
|
return Results.Unauthorized();
|
|
|
|
return await _metaDataApi.getAssignableNpcs(userGuid, pageNumber, pageSize);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 사용가능한 task action 가져오기
|
|
/// </summary>
|
|
/// <param name="pageNumber">페이지</param>
|
|
/// <param name="pageSize">pageSize (최대 100)</param>
|
|
[HttpGet]
|
|
[Route("available-task-actions")]
|
|
[Produces("application/json")]
|
|
[SwaggerResponse(StatusCodes.Status200OK, Type = typeof(TaskActionList))]
|
|
[SwaggerResponse(StatusCodes.Status400BadRequest, Type = typeof(ApiErrorResponse))]
|
|
public async Task<IResult> getAvailableTaskActions([FromQuery] int pageNumber, [FromQuery] int pageSize)
|
|
{
|
|
return await _metaDataApi.getAvailableTaskActions(pageNumber, pageSize);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 액션의 입력가능한 값 리스트 얻어오기
|
|
/// </summary>
|
|
/// <remarks>
|
|
/// Task Action이 의상장착인 경우에 사용
|
|
/// </remarks>
|
|
/// <param name="taskActionId">TaskAction의 아이디</param>
|
|
/// <param name="pageNumber">페이지</param>
|
|
/// <param name="pageSize">pageSize (최대 100)</param>
|
|
[HttpGet]
|
|
[Route("task-action-values")]
|
|
[Produces("application/json")]
|
|
[SwaggerResponse(StatusCodes.Status200OK, Type = typeof(TaskActionValueList))]
|
|
[SwaggerResponse(StatusCodes.Status400BadRequest, Type = typeof(ApiErrorResponse))]
|
|
public async Task<IResult> getActionValues([FromQuery] int taskActionId, [FromQuery] int pageNumber, [FromQuery] int pageSize)
|
|
{
|
|
var userGuid = userGuidFromToken();
|
|
if (userGuid == null)
|
|
return Results.Unauthorized();
|
|
|
|
return await _metaDataApi.getActionValues(userGuid, taskActionId, pageNumber, pageSize);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 사용가능한 dialog 유형 가져오기
|
|
/// </summary>
|
|
/// <param name="pageNumber">페이지</param>
|
|
/// <param name="pageSize">pageSize (최대 100)</param>
|
|
[HttpGet]
|
|
[Route("dialog-types")]
|
|
[Produces("application/json")]
|
|
[SwaggerResponse(StatusCodes.Status200OK, Type = typeof(DialogTypeList))]
|
|
[SwaggerResponse(StatusCodes.Status400BadRequest, Type = typeof(ApiErrorResponse))]
|
|
public async Task<IResult> getDialogTypes([FromQuery] int pageNumber, [FromQuery] int pageSize)
|
|
{
|
|
return await _metaDataApi.getDialogTypes(pageNumber, pageSize);
|
|
}
|
|
|
|
/// <summary>
|
|
/// dialog 유형에 따라 사용가능한 dialog 액션 가져오기
|
|
/// </summary>
|
|
/// <param name="dialogType">dialog 유형</param>
|
|
/// <param name="pageNumber">페이지</param>
|
|
/// <param name="pageSize">pageSize (최대 100)</param>
|
|
[HttpGet]
|
|
[Route("dialog-actions")]
|
|
[Produces("application/json")]
|
|
[SwaggerResponse(StatusCodes.Status200OK, Type = typeof(DialogActionList))]
|
|
[SwaggerResponse(StatusCodes.Status400BadRequest, Type = typeof(ApiErrorResponse))]
|
|
public async Task<IResult> getDialogActions([FromQuery] int dialogType, [FromQuery] int pageNumber, [FromQuery] int pageSize)
|
|
{
|
|
return await _metaDataApi.getDialogActions(dialogType, pageNumber, pageSize);
|
|
}
|
|
|
|
/// <summary>
|
|
/// dialog 액션에 따라 입력 가능한 값 가져오기
|
|
/// </summary>
|
|
/// <param name="dialogType">다이얼로그 타입</param>
|
|
/// <param name="dialogActionId">조건 종류</param>
|
|
/// <param name="pageNumber">페이지</param>
|
|
/// <param name="pageSize">pageSize (최대 100)</param>
|
|
[HttpGet]
|
|
[Route("dialog-action-values")]
|
|
[Produces("application/json")]
|
|
[SwaggerResponse(StatusCodes.Status200OK, Type = typeof(DialogActionValueList))]
|
|
[SwaggerResponse(StatusCodes.Status400BadRequest, Type = typeof(ApiErrorResponse))]
|
|
public async Task<IResult> getDialogConditionValues([FromQuery] int dialogType, [FromQuery] int dialogActionId, [FromQuery] int pageNumber, [FromQuery] int pageSize)
|
|
{
|
|
return await _metaDataApi.getDialogConditionValues(dialogType, dialogActionId, pageNumber, pageSize);
|
|
}
|
|
|
|
/// <summary>
|
|
/// NPC 연출 데이터 값 가져오기
|
|
/// </summary>
|
|
/// <param name="gender">npc gender</param>
|
|
/// <param name="pageNumber">페이지</param>
|
|
/// <param name="pageSize">pageSize (최대 100)</param>
|
|
[HttpGet]
|
|
[Route("npc-action-values")]
|
|
[Produces("application/json")]
|
|
[SwaggerResponse(StatusCodes.Status200OK, Type = typeof(NpcActionValueList))]
|
|
[SwaggerResponse(StatusCodes.Status400BadRequest, Type = typeof(ApiErrorResponse))]
|
|
public async Task<IResult> getNpcActionValues([FromQuery] EGenderType gender, [FromQuery] int pageNumber, [FromQuery] int pageSize)
|
|
{
|
|
return await _metaDataApi.getNpcActionValues(pageNumber, pageSize, gender);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Map 데이터 값 가져오기
|
|
/// </summary>
|
|
/// <param name="pageNumber">페이지</param>
|
|
/// <param name="pageSize">pageSize (최대 100)</param>
|
|
[HttpGet]
|
|
[Route("map-data-values")]
|
|
[Produces("application/json")]
|
|
[SwaggerResponse(StatusCodes.Status200OK, Type = typeof(MapDataValueList))]
|
|
[SwaggerResponse(StatusCodes.Status400BadRequest, Type = typeof(ApiErrorResponse))]
|
|
public async Task<IResult> getNpcActionValues([FromQuery] int pageNumber, [FromQuery] int pageSize)
|
|
{
|
|
return await _metaDataApi.getMapDataValues(pageNumber, pageSize);
|
|
}
|
|
|
|
[HttpGet]
|
|
[Route("preset-images")]
|
|
[Produces("application/json")]
|
|
[SwaggerResponse(StatusCodes.Status200OK, Type = typeof(DialogActionValueList))]
|
|
[SwaggerResponse(StatusCodes.Status400BadRequest, Type = typeof(ApiErrorResponse))]
|
|
public async Task<IResult> getPresetImages([FromQuery] PresetKind kind, [FromQuery] PresetCategory category)
|
|
{
|
|
return await _metaDataApi.getPresetImages(kind, category);
|
|
}
|
|
}
|
|
}
|