82 lines
2.6 KiB
C#
82 lines
2.6 KiB
C#
|
|
using Microsoft.AspNetCore.Authorization;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
using Microsoft.Extensions.Hosting;
|
|
using System.Diagnostics;
|
|
using System.Security.Claims;
|
|
using UserCenter.Model;
|
|
using VideoAnalysisCore.Common;
|
|
using VideoAnalysisCore.Controllers.Dto;
|
|
|
|
namespace VideoAnalysisCore.Controllers
|
|
{
|
|
/// <summary>
|
|
/// 通用接口
|
|
/// </summary>
|
|
[Route("api/[controller]")]
|
|
public class PublicController : ControllerBase
|
|
{
|
|
private readonly IHostEnvironment _environment;
|
|
public PublicController(Repository<School> baseService, IHostEnvironment environment)
|
|
{
|
|
_environment = environment;
|
|
}
|
|
|
|
/// <summary>
|
|
/// App.EntityDto.Enum 枚举转下拉列表
|
|
/// </summary>
|
|
/// <param name="type">枚举名称 例子type='ExamStatusEnum'</param>
|
|
/// <returns></returns>
|
|
[HttpGet, Route("enum/{type}")]
|
|
[ResponseCache(Duration = 5)]
|
|
public IActionResult GetExamStatusData(string type)
|
|
{
|
|
if (!AppCommon.EnumType.ContainsKey(type))
|
|
return BadRequest("无效类型");
|
|
return Ok( Enum.GetValues(AppCommon.EnumType[type]).Cast<object>()
|
|
.Select(enumValue => new ComboModel() { Text = enumValue.ToString(), Value = (int)enumValue }).ToList());
|
|
}
|
|
/// <summary>
|
|
/// App.EntityDto.Enum 枚举转下拉列表
|
|
/// </summary>
|
|
/// <param name="type">枚举名称 例子type='ExamStatusEnum'</param>
|
|
/// <returns></returns>
|
|
[HttpGet, Route("enum/{type}/Dic")]
|
|
[ResponseCache(Duration = 5)]
|
|
public IActionResult GetExamStatusDictionary(string type)
|
|
{
|
|
if (!AppCommon.EnumType.ContainsKey(type))
|
|
return BadRequest("无效类型");
|
|
return Ok(Enum.GetValues(AppCommon.EnumType[type]).Cast<object>()
|
|
.ToDictionary(s => (int)s, s => s.ToString()));
|
|
}
|
|
# if DEBUG
|
|
/// <summary>
|
|
/// 获取当前环境变量,配置文件
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
[HttpGet]
|
|
public IActionResult NewENV()
|
|
{
|
|
var envName = _environment.EnvironmentName;
|
|
var env = "无配置";
|
|
if (_environment.IsDevelopment())
|
|
env = "开发环境";
|
|
else if (_environment.IsStaging())
|
|
env = "测试/预发布环境";
|
|
else if (_environment.IsProduction())
|
|
env = "生产环境";
|
|
|
|
return Ok(new
|
|
{
|
|
envName,
|
|
env,
|
|
AppCommon.Config
|
|
});
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
|
}
|