Init Commit

This commit is contained in:
2026-02-09 18:19:44 -03:00
commit 7222728591
33 changed files with 5641 additions and 0 deletions

View File

@@ -0,0 +1,66 @@
using Microsoft.AspNetCore.Mvc;
using System;
using System.IO;
using System.Threading.Tasks;
using WhatsappPromo.Core.Models;
using WhatsappPromo.Core.Services;
namespace WhatsappPromo.Worker.Controllers
{
[ApiController]
[Route("api/[controller]")]
public class ConfigController : ControllerBase
{
private readonly IConfigService _configService;
public ConfigController(IConfigService configService)
{
_configService = configService;
}
[HttpGet]
public async Task<IActionResult> GetConfig()
{
var config = await _configService.GetConfigAsync();
return Ok(config);
}
[HttpPost]
public async Task<IActionResult> UpdateConfig([FromBody] SystemConfig config)
{
// Validar ruta
if (!string.IsNullOrEmpty(config.DownloadPath))
{
try
{
Directory.CreateDirectory(config.DownloadPath);
}
catch (Exception ex)
{
return BadRequest($"Ruta inválida: {ex.Message}");
}
}
await _configService.UpdateConfigAsync(config);
return Ok(config);
}
[HttpPost("start")]
public async Task<IActionResult> Start()
{
var config = await _configService.GetConfigAsync();
config.IsActive = true;
await _configService.UpdateConfigAsync(config);
return Ok(new { status = "Starting" });
}
[HttpPost("stop")]
public async Task<IActionResult> Stop()
{
var config = await _configService.GetConfigAsync();
config.IsActive = false;
await _configService.UpdateConfigAsync(config);
return Ok(new { status = "Stopping" });
}
}
}