libretificacaotjcore 0.1.10__tar.gz → 0.1.12__tar.gz
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-0.1.10 → libretificacaotjcore-0.1.12}/PKG-INFO +1 -1
- libretificacaotjcore-0.1.12/libretificacaotjcore/database/certificado_repository.py +39 -0
- {libretificacaotjcore-0.1.10 → libretificacaotjcore-0.1.12}/libretificacaotjcore/database/config_db.py +8 -1
- {libretificacaotjcore-0.1.10 → libretificacaotjcore-0.1.12}/libretificacaotjcore/dtos/solicitacao_dto.py +16 -1
- libretificacaotjcore-0.1.12/libretificacaotjcore/enums/e_eventos.py +10 -0
- libretificacaotjcore-0.1.12/libretificacaotjcore/services/crypto_pass_service.py +18 -0
- {libretificacaotjcore-0.1.10 → libretificacaotjcore-0.1.12}/libretificacaotjcore.egg-info/PKG-INFO +1 -1
- {libretificacaotjcore-0.1.10 → libretificacaotjcore-0.1.12}/libretificacaotjcore.egg-info/SOURCES.txt +2 -0
- {libretificacaotjcore-0.1.10 → libretificacaotjcore-0.1.12}/pyproject.toml +1 -1
- libretificacaotjcore-0.1.10/libretificacaotjcore/services/crypto_pass_service.py +0 -11
- {libretificacaotjcore-0.1.10 → libretificacaotjcore-0.1.12}/README.md +0 -0
- {libretificacaotjcore-0.1.10 → libretificacaotjcore-0.1.12}/libretificacaotjcore/__init__.py +0 -0
- {libretificacaotjcore-0.1.10 → libretificacaotjcore-0.1.12}/libretificacaotjcore/database/__init__.py +0 -0
- {libretificacaotjcore-0.1.10 → libretificacaotjcore-0.1.12}/libretificacaotjcore/database/arquivo_repository.py +0 -0
- {libretificacaotjcore-0.1.10 → libretificacaotjcore-0.1.12}/libretificacaotjcore/services/__init__.py +0 -0
- {libretificacaotjcore-0.1.10 → libretificacaotjcore-0.1.12}/libretificacaotjcore/services/file_service.py +0 -0
- {libretificacaotjcore-0.1.10 → libretificacaotjcore-0.1.12}/libretificacaotjcore/services/rabbitmq_consumer.py +0 -0
- {libretificacaotjcore-0.1.10 → libretificacaotjcore-0.1.12}/libretificacaotjcore/services/s3_service.py +0 -0
- {libretificacaotjcore-0.1.10 → libretificacaotjcore-0.1.12}/libretificacaotjcore.egg-info/dependency_links.txt +0 -0
- {libretificacaotjcore-0.1.10 → libretificacaotjcore-0.1.12}/libretificacaotjcore.egg-info/requires.txt +0 -0
- {libretificacaotjcore-0.1.10 → libretificacaotjcore-0.1.12}/libretificacaotjcore.egg-info/top_level.txt +0 -0
- {libretificacaotjcore-0.1.10 → libretificacaotjcore-0.1.12}/setup.cfg +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: libretificacaotjcore
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.12
|
|
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
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
from pymongo.errors import BulkWriteError
|
|
2
|
+
|
|
3
|
+
class CertificadoRepository:
|
|
4
|
+
def __init__(self, db):
|
|
5
|
+
self.__db = db
|
|
6
|
+
|
|
7
|
+
async def inserir_certificado(self, certificado: dict) -> bool:
|
|
8
|
+
try:
|
|
9
|
+
certificado_no_db = await self.__db.certificado.find_one(
|
|
10
|
+
{"cnpj": certificado["cnpj"]}
|
|
11
|
+
)
|
|
12
|
+
|
|
13
|
+
if certificado_no_db is None:
|
|
14
|
+
await self.__db.certificado.insert_one(certificado)
|
|
15
|
+
return True
|
|
16
|
+
|
|
17
|
+
await self.__db.certificado.delete_one(
|
|
18
|
+
{"cnpj": certificado["cnpj"]}
|
|
19
|
+
)
|
|
20
|
+
await self.__db.certificado.insert_one(certificado)
|
|
21
|
+
return True
|
|
22
|
+
except Exception as e:
|
|
23
|
+
print(f"❌ Erro ao inserir o arquivo: {e}")
|
|
24
|
+
return False
|
|
25
|
+
|
|
26
|
+
async def remover_certificado(self, cnpj: str) -> bool:
|
|
27
|
+
try:
|
|
28
|
+
await self.__db.certificado.delete_many({"cnpj": cnpj})
|
|
29
|
+
return True
|
|
30
|
+
except Exception as e:
|
|
31
|
+
print(f"❌ Erro ao remover o certificado: {e}")
|
|
32
|
+
return False
|
|
33
|
+
|
|
34
|
+
async def buscar_certificado_por_cnpj(self, cnpj: str) -> list[dict]:
|
|
35
|
+
try:
|
|
36
|
+
return await self.__db.certificado.find({"cnpj": cnpj}).to_list(length=None)
|
|
37
|
+
except Exception as e:
|
|
38
|
+
print(f"❌ Erro ao buscar certificado: {e}")
|
|
39
|
+
return []
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
+
from enum import unique
|
|
1
2
|
import motor.motor_asyncio
|
|
2
|
-
from bson import ObjectId
|
|
3
3
|
from datetime import datetime
|
|
4
4
|
|
|
5
5
|
class ConfigDb:
|
|
@@ -29,6 +29,13 @@ class ConfigDb:
|
|
|
29
29
|
await self.__db.arquivos.create_index([("SolicitacaoId", 1), ("cpf", 1)], unique=True)
|
|
30
30
|
self.db_initialized = True
|
|
31
31
|
|
|
32
|
+
if "certificados" not in (await self.__db.list_collection_names()):
|
|
33
|
+
await self.__db.create_collection("certificados")
|
|
34
|
+
|
|
35
|
+
await self.__db.certificados.create_index([("cnpj", 1)], unique=True)
|
|
36
|
+
await self.__db.arquivos.create_index([("id", 1)], unique=True)
|
|
37
|
+
self.db_initialized = True
|
|
38
|
+
|
|
32
39
|
async def get_db(self):
|
|
33
40
|
await self.criar_schema()
|
|
34
41
|
return self.__db
|
|
@@ -2,6 +2,8 @@ from datetime import datetime, date, timedelta
|
|
|
2
2
|
import re
|
|
3
3
|
from pydantic import BaseModel, Field, field_validator
|
|
4
4
|
|
|
5
|
+
from libretificacaotjcore.enums.e_eventos import EEventos
|
|
6
|
+
|
|
5
7
|
|
|
6
8
|
class SolicitacaoDTO(BaseModel):
|
|
7
9
|
solicitacaoId: int = Field(..., description="ID da solicitação")
|
|
@@ -9,7 +11,7 @@ class SolicitacaoDTO(BaseModel):
|
|
|
9
11
|
dataInicio: date = Field(..., description="Data de início no formato YYYY-MM-DD")
|
|
10
12
|
dataFim: date = Field(..., description="Data de fim no formato YYYY-MM-DD")
|
|
11
13
|
certificadoId: int = Field(..., description="ID do certificado")
|
|
12
|
-
|
|
14
|
+
eventos: list[EEventos] | None = Field(..., description="Lista de eventos")
|
|
13
15
|
|
|
14
16
|
# Validar e transformar solicitacaoId
|
|
15
17
|
@field_validator('solicitacaoId')
|
|
@@ -60,4 +62,17 @@ class SolicitacaoDTO(BaseModel):
|
|
|
60
62
|
return (proximo_mes - timedelta(days=1)).date()
|
|
61
63
|
except Exception:
|
|
62
64
|
raise ValueError("A dataFim deve estar no formato YYYY-MM-DD e conter um mês válido.")
|
|
65
|
+
|
|
66
|
+
@field_validator('eventos')
|
|
67
|
+
@classmethod
|
|
68
|
+
def validar_eventos(cls, v: list[EEventos] | None) -> str | None:
|
|
69
|
+
if v is None:
|
|
70
|
+
return
|
|
71
|
+
|
|
72
|
+
eventos_unicos = set(v)
|
|
73
|
+
if len(eventos_unicos) != len(v):
|
|
74
|
+
raise ValueError("Há eventos duplicados na lista")
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
|
|
63
78
|
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
from cryptography.fernet import Fernet
|
|
2
|
+
|
|
3
|
+
class CryptoPassService:
|
|
4
|
+
def __init__(self, key: bytes | None = None):
|
|
5
|
+
# Se a chave não for passada, gera uma nova
|
|
6
|
+
self.key = key or Fernet.generate_key()
|
|
7
|
+
self.cipher = Fernet(self.key)
|
|
8
|
+
|
|
9
|
+
def encrypt_password(self, password: str) -> bytes:
|
|
10
|
+
# Recebe a senha em texto e retorna a senha criptografada em bytes
|
|
11
|
+
password_bytes = password.encode()
|
|
12
|
+
encrypted = self.cipher.encrypt(password_bytes)
|
|
13
|
+
return encrypted
|
|
14
|
+
|
|
15
|
+
def decrypt_password(self, token: bytes) -> str:
|
|
16
|
+
# Recebe o token criptografado e retorna a senha em texto
|
|
17
|
+
decrypted_bytes = self.cipher.decrypt(token)
|
|
18
|
+
return decrypted_bytes.decode()
|
{libretificacaotjcore-0.1.10 → libretificacaotjcore-0.1.12}/libretificacaotjcore.egg-info/PKG-INFO
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: libretificacaotjcore
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.12
|
|
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
|
|
@@ -8,8 +8,10 @@ libretificacaotjcore.egg-info/requires.txt
|
|
|
8
8
|
libretificacaotjcore.egg-info/top_level.txt
|
|
9
9
|
libretificacaotjcore/database/__init__.py
|
|
10
10
|
libretificacaotjcore/database/arquivo_repository.py
|
|
11
|
+
libretificacaotjcore/database/certificado_repository.py
|
|
11
12
|
libretificacaotjcore/database/config_db.py
|
|
12
13
|
libretificacaotjcore/dtos/solicitacao_dto.py
|
|
14
|
+
libretificacaotjcore/enums/e_eventos.py
|
|
13
15
|
libretificacaotjcore/services/__init__.py
|
|
14
16
|
libretificacaotjcore/services/crypto_pass_service.py
|
|
15
17
|
libretificacaotjcore/services/file_service.py
|
|
@@ -11,7 +11,7 @@ keywords = ["tj", "tributo justo", "retificação", "automação", "pydantic", "
|
|
|
11
11
|
name = "libretificacaotjcore"
|
|
12
12
|
readme = "README.md"
|
|
13
13
|
requires-python = ">=3.12"
|
|
14
|
-
version = "0.1.
|
|
14
|
+
version = "0.1.12"
|
|
15
15
|
|
|
16
16
|
classifiers = [
|
|
17
17
|
"Development Status :: 3 - Alpha",
|
|
File without changes
|
{libretificacaotjcore-0.1.10 → libretificacaotjcore-0.1.12}/libretificacaotjcore/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|