Skip to content

Commit 538a054

Browse files
authored
Merge pull request #13 from DermAlert/development
refactor: rename arquivo_url to arquivo_path for consistency in model…
2 parents 9fae01a + 8da683e commit 538a054

File tree

5 files changed

+10
-21
lines changed

5 files changed

+10
-21
lines changed

project/app/api/routes/atendimento_routes.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ async def cadastrar_termo_consentimento(
152152
arquivo_metadata = await upload_to_minio(file, folder_name="termos-consentimento")
153153

154154
new_termo = models.TermoConsentimento(
155-
arquivo_url=arquivo_metadata["url"],
155+
arquivo_path=arquivo_metadata["url"],
156156
)
157157

158158
db.add(new_termo)
@@ -168,7 +168,7 @@ async def cadastrar_termo_consentimento(
168168
"message": "Termo de Consentimento cadastrado com sucesso!",
169169
"termo_consentimento": {
170170
"id": new_termo.id,
171-
"arquivo_url": arquivo_metadata["url"]
171+
"arquivo_path": arquivo_metadata["url"]
172172
}
173173
}
174174

@@ -432,7 +432,7 @@ async def cadastrar_lesao(
432432

433433
# Cria o registro da imagem no banco
434434
new_imagem = models.RegistroLesoesImagens(
435-
arquivo_url=arquivo_metadata["url"], # Just use the URL string, not the entire dict
435+
arquivo_path=arquivo_metadata["url"], # Just use the URL string, not the entire dict
436436
registro_lesoes_id=new_lesao.id
437437
)
438438
db.add(new_imagem)
@@ -496,7 +496,7 @@ async def listar_lesoes(
496496
"local_lesao_id": lesao.local_lesao_id,
497497
"local_lesao_nome": local_lesao_name,
498498
"descricao_lesao": lesao.descricao_lesao,
499-
"imagens": [imagem.arquivo_url for imagem in imagens]
499+
"imagens": [imagem.arquivo_path for imagem in imagens]
500500
})
501501

502502
return lesoes_list

project/app/database/models.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ class RegistroLesoes(Base):
9191
class RegistroLesoesImagens(Base):
9292
__tablename__ = 'registroLesoesImagens'
9393
id = Column(Integer, primary_key=True, index=True)
94-
arquivo_url = Column(String(400), nullable=False)
94+
arquivo_path = Column(String(300), nullable=False)
9595
registro_lesoes_id = Column(Integer, ForeignKey('registroLesoes.id'))
9696
registro_lesoes = relationship('RegistroLesoes')
9797

@@ -118,7 +118,7 @@ class Paciente(AuditMixin, Base):
118118
class TermoConsentimento(Base):
119119
__tablename__ = 'termoConsentimento'
120120
id = Column(Integer, primary_key=True, index=True)
121-
arquivo_url = Column(String(400), nullable=False)
121+
arquivo_path = Column(String(300), nullable=False)
122122
data_acordo = Column(TIMESTAMP, server_default=func.now())
123123

124124
class SaudeGeral(Base):

project/app/database/populate_db.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ async def populate_db():
233233

234234
# Cria um TermoConsentimento
235235
termo = TermoConsentimento(
236-
arquivo_url=f"http://exemplo.com/consentimento_{i+1}.pdf"
236+
arquivo_path=f"http://exemplo.com/consentimento_{i+1}.pdf"
237237
)
238238
session.add(termo)
239239
await session.commit()
@@ -363,7 +363,7 @@ async def populate_db():
363363

364364
# Cria uma imagem associada a este registro de lesão
365365
imagem = RegistroLesoesImagens(
366-
arquivo_url=f"http://exemplo.com/imagens/lesao_{paciente.id}_{j+1}.jpg",
366+
arquivo_path=f"http://exemplo.com/imagens/lesao_{paciente.id}_{j+1}.jpg",
367367
registro_lesoes_id=registro_lesao.id
368368
)
369369
session.add(imagem)

project/app/database/schemas.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ class PacienteCreateSchema(BaseModel):
124124
autoriza_pesquisa: bool
125125

126126
class TermoConsentimentoCreateSchema(BaseModel):
127-
arquivo_url: str
127+
arquivo_path: str
128128

129129
class FrequenciaAtividadeFisicaEnum(str, Enum):
130130
diaria = "Diária"

project/app/utils/minio.py

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -67,22 +67,11 @@ async def upload_to_minio(file, folder_name, allowed_types=None, max_size_mb=50)
6767
content_type=file.content_type
6868
)
6969

70-
# Gera URL assinada para acesso temporário (7 dias)
71-
url = client.presigned_get_object(
72-
bucket_name=minio_bucket,
73-
object_name=object_name,
74-
expires=timedelta(days=7)
75-
)
76-
7770
# Reposiciona o ponteiro do arquivo para o início (caso precise usar novamente)
7871
await file.seek(0)
7972

8073
return {
81-
"url": url,
82-
"object_name": object_name,
83-
"bucket": minio_bucket,
84-
"content_type": file.content_type,
85-
"size": file_size
74+
"url": object_name
8675
}
8776

8877
except S3Error as e:

0 commit comments

Comments
 (0)