forked from AcaMate/AcaMate_API
68 lines
2.0 KiB
C#
68 lines
2.0 KiB
C#
using Microsoft.AspNetCore.Mvc;
|
|
using System.Text.Json;
|
|
using AcaMate.Common.Data;
|
|
using AcaMate.Common.Models;
|
|
using Microsoft.IdentityModel.Tokens;
|
|
using Version = AcaMate.V1.Models.Version;
|
|
|
|
namespace AcaMate.V1.Controllers;
|
|
|
|
[ApiController]
|
|
[Route("/api/v1/in/app")]
|
|
[ApiExplorerSettings(GroupName = "공통")]
|
|
public class AppController : ControllerBase
|
|
{
|
|
private readonly AppDbContext _dbContext;
|
|
|
|
public AppController(AppDbContext dbContext)
|
|
{
|
|
_dbContext = dbContext;
|
|
}
|
|
|
|
[HttpGet("version")]
|
|
[CustomOperation("앱 버전 확인","앱 버전을 확인해서 업데이트 여부 판단", "시스템")]
|
|
public IActionResult GetVersionData(string type)
|
|
{
|
|
if (string.IsNullOrEmpty(type))
|
|
{
|
|
return BadRequest(DefaultResponse.InvalidInputError);
|
|
}
|
|
|
|
try
|
|
{
|
|
var version = _dbContext.Version.FirstOrDefault(v => v.os_type == (type == "I" ? "VO01" : "VO02"));
|
|
|
|
if (version == null)
|
|
{
|
|
return NotFound(DefaultResponse.NotFoundError);
|
|
}
|
|
|
|
var response = new APIResponseStatus<Version>
|
|
{
|
|
status = new Status()
|
|
{
|
|
code = "000",
|
|
message = "정상"
|
|
},
|
|
data = new Version()
|
|
{
|
|
os_type = (version.os_type == "VO01" ? "I" : (version.os_type == "VO02" ? "A" : "W")),
|
|
final_ver = version.final_ver,
|
|
force_ver = version.force_ver,
|
|
dev_ver = version.dev_ver,
|
|
choice_update_yn = version.choice_update_yn
|
|
}
|
|
};
|
|
|
|
string jsonString = JsonSerializer.Serialize(response);
|
|
|
|
// return Ok(jsonString);
|
|
return Ok(response.JsonToString());
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
Console.WriteLine($"{ex.Message}\n{ex.StackTrace}");
|
|
return StatusCode(500, DefaultResponse.UnknownError);
|
|
}
|
|
}
|
|
} |