adding more stuff
All checks were successful
API and ETL Build / build_etl (push) Successful in 2s
API and ETL Build / build_api (push) Successful in 14s

This commit is contained in:
Jose Henrique 2025-05-31 14:43:37 -03:00
parent e00cabb840
commit 146495c07b
5 changed files with 46 additions and 0 deletions

View File

@ -1,4 +1,5 @@
using Microsoft.AspNetCore.Mvc;
using Microsoft.VisualBasic;
using OpenCand.API.Model;
using OpenCand.API.Services;
using OpenCand.Core.Models;
@ -37,5 +38,14 @@ namespace OpenCand.API.Controllers
{
return await openCandService.GetCandidatoRedeSocialById(id);
}
[HttpGet("{id}/reveal-cpf")]
public async Task<CpfRevealResult> GetCandidatoCpfById([FromRoute] Guid id)
{
var rnd = new Random();
var randomWait = rnd.Next(1000, 3000);
await Task.Delay(randomWait);
return await openCandService.GetCandidatoCpfById(id);
}
}
}

View File

@ -16,4 +16,9 @@ namespace OpenCand.API.Model
{
public List<RedeSocial> RedesSociais { get; set; }
}
public class CpfRevealResult
{
public string Cpf { get; set; }
}
}

View File

@ -25,4 +25,10 @@
</None>
</ItemGroup>
<ItemGroup>
<None Remove="fotos_cand.zip" />
<Content Remove="fotos_cand" />
</ItemGroup>
</Project>

View File

@ -36,6 +36,17 @@ namespace OpenCand.Repository
}
}
public async Task<string?> GetCandidatoCpfAsync(Guid idcandidato)
{
using (var connection = new NpgsqlConnection(ConnectionString))
{
return await connection.QueryFirstOrDefaultAsync<string>(@"
SELECT cpf FROM candidato
WHERE idcandidato = @idcandidato;",
new { idcandidato });
}
}
public async Task<List<CandidatoMapping>?> GetCandidatoMappingById(Guid idcandidato)
{
using (var connection = new NpgsqlConnection(ConnectionString))

View File

@ -94,5 +94,19 @@ namespace OpenCand.API.Services
RedesSociais = result.OrderByDescending(r => r.Ano).ToList()
};
}
public async Task<CpfRevealResult> GetCandidatoCpfById(Guid idcandidato)
{
var result = await candidatoRepository.GetCandidatoCpfAsync(idcandidato);
if (result == null)
{
return new CpfRevealResult();
}
return new CpfRevealResult()
{
Cpf = result
};
}
}
}