libretificacaotjcore 0.1.25__py3-none-any.whl → 0.1.26__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of libretificacaotjcore might be problematic. Click here for more details.
- libretificacaotjcore/dtos/solicitacao_dto.py +13 -0
- libretificacaotjcore/enums/e_eventos.py +1 -1
- libretificacaotjcore/services/rabbitmq_publisher.py +52 -0
- {libretificacaotjcore-0.1.25.dist-info → libretificacaotjcore-0.1.26.dist-info}/METADATA +1 -1
- {libretificacaotjcore-0.1.25.dist-info → libretificacaotjcore-0.1.26.dist-info}/RECORD +7 -6
- {libretificacaotjcore-0.1.25.dist-info → libretificacaotjcore-0.1.26.dist-info}/WHEEL +0 -0
- {libretificacaotjcore-0.1.25.dist-info → libretificacaotjcore-0.1.26.dist-info}/top_level.txt +0 -0
|
@@ -3,6 +3,8 @@ from datetime import date, datetime, timedelta
|
|
|
3
3
|
|
|
4
4
|
from pydantic import BaseModel, Field, field_validator
|
|
5
5
|
|
|
6
|
+
from libretificacaotjcore.enums.e_eventos import EEventos
|
|
7
|
+
|
|
6
8
|
|
|
7
9
|
class SolicitacaoDTO(BaseModel):
|
|
8
10
|
SolicitacaoId: int = Field(..., description="ID da solicitação")
|
|
@@ -10,6 +12,7 @@ class SolicitacaoDTO(BaseModel):
|
|
|
10
12
|
DataInicio: date = Field(..., description="Data de início no formato YYYY-MM-DD")
|
|
11
13
|
DataFim: date = Field(..., description="Data de fim no formato YYYY-MM-DD")
|
|
12
14
|
CertificadoId: int = Field(..., description="ID do certificado")
|
|
15
|
+
Evento: str | None = Field(None, description="Evento de retificação")
|
|
13
16
|
|
|
14
17
|
@field_validator("SolicitacaoId")
|
|
15
18
|
@classmethod
|
|
@@ -54,3 +57,13 @@ class SolicitacaoDTO(BaseModel):
|
|
|
54
57
|
else:
|
|
55
58
|
proximo_mes = datetime(ano, mes + 1, 1)
|
|
56
59
|
return (proximo_mes - timedelta(days=1)).date()
|
|
60
|
+
|
|
61
|
+
@field_validator("Evento")
|
|
62
|
+
@classmethod
|
|
63
|
+
def validar_eventos(cls, v: str) -> str | None:
|
|
64
|
+
if v is None:
|
|
65
|
+
return v
|
|
66
|
+
|
|
67
|
+
if v not in EEventos:
|
|
68
|
+
raise ValueError(f"Evento '{v}' não é válido.")
|
|
69
|
+
return v
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import pika
|
|
2
|
+
import json
|
|
3
|
+
|
|
4
|
+
class RabbitMQPublisher:
|
|
5
|
+
def __init__(
|
|
6
|
+
self,
|
|
7
|
+
host,
|
|
8
|
+
queue,
|
|
9
|
+
username,
|
|
10
|
+
password,
|
|
11
|
+
vhost="/",
|
|
12
|
+
):
|
|
13
|
+
self.host = host
|
|
14
|
+
self.queue = queue
|
|
15
|
+
self.username = username
|
|
16
|
+
self.password = password
|
|
17
|
+
self.vhost = vhost
|
|
18
|
+
self.connection = None
|
|
19
|
+
self.channel = None
|
|
20
|
+
|
|
21
|
+
def connect(self):
|
|
22
|
+
credentials = pika.PlainCredentials(self.username, self.password)
|
|
23
|
+
parameters = pika.ConnectionParameters(
|
|
24
|
+
host=self.host,
|
|
25
|
+
credentials=credentials,
|
|
26
|
+
virtual_host=self.vhost,
|
|
27
|
+
heartbeat=60,
|
|
28
|
+
blocked_connection_timeout=300,
|
|
29
|
+
)
|
|
30
|
+
|
|
31
|
+
self.connection = pika.BlockingConnection(parameters)
|
|
32
|
+
self.channel = self.connection.channel()
|
|
33
|
+
self.channel.queue_declare(queue=self.queue, durable=True)
|
|
34
|
+
|
|
35
|
+
def publish(self, message: dict):
|
|
36
|
+
if not self.channel:
|
|
37
|
+
raise RuntimeError("❌ Canal RabbitMQ não conectado. Chame connect() antes.")
|
|
38
|
+
|
|
39
|
+
body = json.dumps(message)
|
|
40
|
+
self.channel.basic_publish(
|
|
41
|
+
exchange="",
|
|
42
|
+
routing_key=self.queue,
|
|
43
|
+
body=body,
|
|
44
|
+
properties=pika.BasicProperties(
|
|
45
|
+
delivery_mode=2 # torna a mensagem persistente
|
|
46
|
+
)
|
|
47
|
+
)
|
|
48
|
+
print(f"✅ Mensagem publicada na fila '{self.queue}': {message}")
|
|
49
|
+
|
|
50
|
+
def close(self):
|
|
51
|
+
if self.connection:
|
|
52
|
+
self.connection.close()
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: libretificacaotjcore
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.26
|
|
4
4
|
Summary: Biblioteca para centralizar conexao com filas no rabbit e banco de dados no mongodb para os servicos de retificacao da TJ
|
|
5
5
|
Author-email: Jhonatan Azevedo <dev.azevedo@outlook.com>
|
|
6
6
|
Project-URL: Homepage, https://github.com/seu-usuario/libretificacaotjcore
|
|
@@ -6,15 +6,16 @@ libretificacaotjcore/database/config_db.py,sha256=1SNpQV6GcrS0aZGX12wXmxhmLb8oc3
|
|
|
6
6
|
libretificacaotjcore/database/protocolo_repository.py,sha256=kb-mXxiOYDPbrPbYMhOb9xDZHknUdVSfVlmQ_Cn0l1s,3788
|
|
7
7
|
libretificacaotjcore/dtos/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
8
8
|
libretificacaotjcore/dtos/arquivo_dto.py,sha256=D4LLJZf-Z0XhJmOvu7nAcBq0j70m9TFtbgxI9ikHXQ0,1045
|
|
9
|
-
libretificacaotjcore/dtos/solicitacao_dto.py,sha256=
|
|
9
|
+
libretificacaotjcore/dtos/solicitacao_dto.py,sha256=7Ex9zlaphHVhaU0D2ubH46KmnqmR6TS0_O3__c1sn4A,2564
|
|
10
10
|
libretificacaotjcore/enums/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
11
|
-
libretificacaotjcore/enums/e_eventos.py,sha256=
|
|
11
|
+
libretificacaotjcore/enums/e_eventos.py,sha256=EClyRpHtL21t_s1b_26bbBKpvd6QgOtIe87FmSzh34E,185
|
|
12
12
|
libretificacaotjcore/services/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
13
13
|
libretificacaotjcore/services/crypto_pass_service.py,sha256=9D0vyjan6f_8AfNxGkLpGdvyMpojsJq_AAySpv_zKMc,740
|
|
14
14
|
libretificacaotjcore/services/file_service.py,sha256=14CJokBbrsryQGmL0_unH2QKZpnteEAfxf5CPFdv6cE,2075
|
|
15
15
|
libretificacaotjcore/services/rabbitmq_consumer.py,sha256=a25mRHjbkgO3lkdCJ5NpJfWAGHhVkQDCRDR2t8hMNAI,1710
|
|
16
|
+
libretificacaotjcore/services/rabbitmq_publisher.py,sha256=nhPJLGPt0D0omN51vrRcu_Pioof_Q8whlwH7I1DreWU,1546
|
|
16
17
|
libretificacaotjcore/services/s3_service.py,sha256=HKR_jt2H3XdV1PCzo5R5bnhmoQ3I46Yn5IqAvVPhsjs,2946
|
|
17
|
-
libretificacaotjcore-0.1.
|
|
18
|
-
libretificacaotjcore-0.1.
|
|
19
|
-
libretificacaotjcore-0.1.
|
|
20
|
-
libretificacaotjcore-0.1.
|
|
18
|
+
libretificacaotjcore-0.1.26.dist-info/METADATA,sha256=bmTLrJEnqRRdLd2fRKKb4yZCeK4llqPcE0pp8GfCSjk,2502
|
|
19
|
+
libretificacaotjcore-0.1.26.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
20
|
+
libretificacaotjcore-0.1.26.dist-info/top_level.txt,sha256=J9vnz_X9OUnxC-eXHiAzlc9xIrWBwZ5bgnIDQIIFY4c,21
|
|
21
|
+
libretificacaotjcore-0.1.26.dist-info/RECORD,,
|
|
File without changes
|
{libretificacaotjcore-0.1.25.dist-info → libretificacaotjcore-0.1.26.dist-info}/top_level.txt
RENAMED
|
File without changes
|