JenkinsFile

This commit is contained in:
Marco Santos
2024-09-27 18:40:30 +01:00
parent f88eb65384
commit ba1130b65a
9 changed files with 94 additions and 28 deletions

View File

@@ -1 +1,4 @@
node_modules
node_modules
Dockerfile
.git
.gitignore

View File

@@ -1,9 +1,38 @@
using System.Net.NetworkInformation;
using System.ComponentModel;
using System.Net.NetworkInformation;
namespace GeradoresService
{
public class NIF
{
public enum NIFType
{
[Description("Pessoa singular (1)")]
PessoaSingular1 = 1,
[Description("Pessoa singular (2)")]
PessoaSingular2 = 2,
[Description("Pessoa singular (3; novo em 2019)")]
PessoaSingular3 = 3,
[Description("Pessoa colectiva (5)")]
PessoaColectiva = 5,
[Description("Pessoa colectiva pública (6)")]
PessoaColectivaPublica = 6,
[Description("Empresário em nome individual (8)")]
EmpresarioIndividual = 8,
[Description("Pessoa colectiva irregular ou número provisório (9)")]
PessoaColectivaIrregular = 9
}
/*public static GetNIFTypes(){
EnumHelper.GetEnumValuesAndDescriptions(NIFType);
}*/
public static string Generate(string? type)
{
return GenerateRandomNIF(type);
@@ -11,7 +40,7 @@ namespace GeradoresService
public static string GenerateRandomNIF(string? nifType)
{
var firstDigitValidate = new char[] { '1', '2','3', '5', '6', '8', '9' };
var firstDigitValidate = new char[] { '1', '2', '3', '5', '6', '8', '9' };
Random rnd = new Random();
char firstDigit;
@@ -20,10 +49,14 @@ namespace GeradoresService
// Gera o primeiro dígito aleatório dentro dos válidos
int firstDigitIndex = rnd.Next(0, 6); // Escolhe um índice de 0 a 5
firstDigit = firstDigitValidate[firstDigitIndex];
} else {
if (firstDigitValidate.Contains(nifType[0])){
}
else
{
if (firstDigitValidate.Contains(nifType[0]))
{
firstDigit = nifType[0];
}else
}
else
{
int firstDigitIndex = rnd.Next(0, 6); // Escolhe um índice de 0 a 5
firstDigit = firstDigitValidate[firstDigitIndex];
@@ -53,7 +86,6 @@ namespace GeradoresService
return randomNIF;
}
public static bool Validate(string nif)
{
// Verificar se o NIF tem 9 dígitos

18
GeradoresService/Utils.cs Normal file
View File

@@ -0,0 +1,18 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Reflection;
public static class EnumHelper
{
public static List<(T Value, string Description)> GetEnumValuesAndDescriptions<T>() where T : Enum
{
return typeof(T).GetFields()
.Select(field => (
Value: (T)field.GetValue(null),
Description: field.GetCustomAttribute<DescriptionAttribute>()?.Description ?? field.Name
))
.ToList();
}
}

View File

@@ -8,6 +8,13 @@ namespace GeradoresWS.Controllers
public class GenerateController : Controller
{
#region NIF
[HttpGet("GetNIFTypes")]
public List<NIF.NIFType> GetNIFTypes()
{
return new List<NIF.NIFType>();
}
[HttpGet("GenerateNIF")]
public string GenerateNIF(string? type)
{

14
Jenkinsfile vendored Normal file
View File

@@ -0,0 +1,14 @@
pipeline {
agent {
dockerfile {
filename 'Dockerfile' // Nome do Dockerfile (se for diferente, modifique aqui)
}
}
stages {
stage('Build') {
steps {
echo 'Construindo o projeto...'
}
}
}
}

View File

@@ -1,9 +1,9 @@
version: "3"
version: "3.8"
services:
geradoresws:
build: .
ports:
- "5000:8080"
- "5050:8080"
networks:
- app-network
@@ -14,7 +14,7 @@ services:
depends_on:
- geradoresws
environment:
- REACT_APP_API_URL=http://localhost:5000/
- REACT_APP_API_URL=http://localhost:5050/
networks:
- app-network

1
geradoresfe/.env Normal file
View File

@@ -0,0 +1 @@
REACT_APP_API_URL=http://localhost:5015/

View File

@@ -66,7 +66,7 @@ function ToggleCustomTheme({
);
}
function App() {
const [mode, setMode] = React.useState<PaletteMode>('light');
/*const [mode, setMode] = React.useState<PaletteMode>('light');
const [showCustomTheme, setShowCustomTheme] = React.useState(true);
const LPtheme = createTheme(getLPTheme(mode));
const defaultTheme = createTheme({ palette: { mode } });
@@ -77,7 +77,7 @@ function App() {
const toggleCustomTheme = () => {
setShowCustomTheme((prev) => !prev);
};
};*/
return (
<div className="App">
@@ -85,13 +85,12 @@ function App() {
<meta charSet="utf-8" />
<title>Geradores</title>
</Helmet>
<ThemeProvider theme={showCustomTheme ? LPtheme : defaultTheme}>
{ /*<ThemeProvider theme={showCustomTheme ? LPtheme : defaultTheme}></ThemeProvider>*/}
<div>
<CssBaseline />
<GeradorCC />
<Box sx={{ bgcolor: 'background.default' }}>
</Box>
</ThemeProvider>
</div>
</div>
);

View File

@@ -30,14 +30,6 @@ export default function GeradorNIF() {
return (
<Box
id="GeradorNIF"
sx={(theme) => ({
width: '100%',
backgroundImage:
theme.palette.mode === 'light'
? 'radial-gradient(ellipse 80% 50% at 50% -20%, hsl(210, 100%, 90%), transparent)'
: 'radial-gradient(ellipse 80% 50% at 50% -20%, hsl(210, 100%, 16%), transparent)',
backgroundRepeat: 'no-repeat',
})}
>
<Container
sx={{
@@ -56,9 +48,10 @@ export default function GeradorNIF() {
>
<Card sx={{ minWidth: 275 }}>
<CardContent>
<Typography sx={{ fontSize: 14 }} color="text.secondary" gutterBottom>
NIFC
<Typography variant='h4'>
NIF<Button size="small">copiar</Button>
</Typography>
<br />
<Typography sx={{ mb: 1.5 }} color="text.secondary">
{nif}
</Typography>
@@ -67,7 +60,6 @@ export default function GeradorNIF() {
<Button size="small" onClick={fetchNif}>Gerar</Button>
</CardActions>
</Card>
</Stack>
</Container>
</Box>