42 lines
1.0 KiB
C#
42 lines
1.0 KiB
C#
using License.Api.Data;
|
|
using License.Api.DTOs;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
using Microsoft.EntityFrameworkCore;
|
|
|
|
namespace License.Api.Controllers;
|
|
|
|
[ApiController]
|
|
[Route("api/config")]
|
|
public class PublicConfigController : ControllerBase
|
|
{
|
|
private readonly AppDbContext _db;
|
|
|
|
public PublicConfigController(AppDbContext db)
|
|
{
|
|
_db = db;
|
|
}
|
|
|
|
[HttpGet("public")]
|
|
public async Task<IActionResult> GetPublicConfigs()
|
|
{
|
|
var configs = await _db.SystemConfigs
|
|
.AsNoTracking()
|
|
.Where(c => c.IsPublic)
|
|
.OrderBy(c => c.Category)
|
|
.ThenBy(c => c.ConfigKey)
|
|
.Select(c => new
|
|
{
|
|
key = c.ConfigKey,
|
|
value = c.ConfigValue,
|
|
valueType = c.ValueType,
|
|
category = c.Category,
|
|
displayName = c.DisplayName,
|
|
description = c.Description,
|
|
options = c.Options
|
|
})
|
|
.ToListAsync();
|
|
|
|
return Ok(ApiResponse<object>.Ok(configs));
|
|
}
|
|
}
|