Initial commit
This commit is contained in:
@@ -0,0 +1,41 @@
|
||||
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));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user