[MVPTN-58] feat(AtualizacaoPut): Atualização PUT para todos os serviços e padronização c_caixa_item
This commit is contained in:
parent
d64cf8c70f
commit
9b100f830a
39 changed files with 4759 additions and 103 deletions
|
|
@ -1,7 +1,5 @@
|
|||
from packages.v1.administrativo.repositories.c_caixa_item.delete import \
|
||||
Delete
|
||||
from packages.v1.administrativo.schemas.c_caixa_item_schema import \
|
||||
CaixaItemSchema
|
||||
from packages.v1.administrativo.repositories.c_caixa_item.c_caixa_item_delete import Delete
|
||||
from packages.v1.administrativo.schemas.c_caixa_item_schema import CaixaItemSchema
|
||||
from abstracts.action import BaseAction
|
||||
|
||||
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
from packages.v1.administrativo.repositories.c_caixa_item.index import \
|
||||
from packages.v1.administrativo.repositories.c_caixa_item.c_caixa_item_index import \
|
||||
Index
|
||||
from packages.v1.administrativo.schemas.c_caixa_item_schema import \
|
||||
CaixaItemSearchSchema
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
from packages.v1.administrativo.repositories.c_caixa_item.save import Save
|
||||
from packages.v1.administrativo.repositories.c_caixa_item.c_caixa_item_save import Save
|
||||
from packages.v1.administrativo.schemas.c_caixa_item_schema import \
|
||||
CaixaItemSchema
|
||||
from abstracts.action import BaseAction
|
||||
|
|
@ -1,6 +1,5 @@
|
|||
from packages.v1.administrativo.repositories.c_caixa_item.show import Show
|
||||
from packages.v1.administrativo.schemas.c_caixa_item_schema import \
|
||||
CaixaItemSchema
|
||||
from packages.v1.administrativo.repositories.c_caixa_item.c_caixa_item_show import Show
|
||||
from packages.v1.administrativo.schemas.c_caixa_item_schema import CaixaItemSchema
|
||||
from abstracts.action import BaseAction
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,14 @@
|
|||
from packages.v1.administrativo.repositories.c_caixa_item.c_caixa_item_update_repository import UpdateRepository
|
||||
from packages.v1.administrativo.schemas.c_caixa_item_schema import CaixaItemSchema
|
||||
from abstracts.action import BaseAction
|
||||
|
||||
|
||||
class UpdateAction(BaseAction):
|
||||
|
||||
def execute(self, caixa_item_id : int, caixa_item_schema : CaixaItemSchema):
|
||||
|
||||
# Instância o repositório desejado
|
||||
update = UpdateRepository()
|
||||
|
||||
# Executa o respositório desejado
|
||||
return update.execute(caixa_item_id, caixa_item_schema)
|
||||
|
|
@ -4,8 +4,8 @@ from packages.v1.administrativo.repositories.c_caixa_servico.c_caixa_servico_upd
|
|||
|
||||
class UpdateAction:
|
||||
|
||||
def execute(self, c_caixa_servico_schema : CCaixaServicoUpdateSchema):
|
||||
def execute(self, caixa_servico_id : int, c_caixa_servico_schema : CCaixaServicoUpdateSchema):
|
||||
|
||||
save_repository = UpdateRepository()
|
||||
|
||||
return save_repository.execute(c_caixa_servico_schema)
|
||||
return save_repository.execute(caixa_servico_id, c_caixa_servico_schema)
|
||||
|
|
@ -4,8 +4,8 @@ from packages.v1.administrativo.repositories.g_usuario.g_usuario_update_reposito
|
|||
|
||||
class UpdateAction:
|
||||
|
||||
def execute(self, usuario_schema : GUsuarioUpdateSchema):
|
||||
def execute(self, usuario_id: int, usuario_schema : GUsuarioUpdateSchema):
|
||||
|
||||
save_repository = UpdateRepository()
|
||||
|
||||
return save_repository.execute(usuario_schema)
|
||||
return save_repository.execute(usuario_id, usuario_schema)
|
||||
|
|
@ -8,7 +8,7 @@ class UpdateAction:
|
|||
de um registro na tabela t_tb_reconhecimentotipo.
|
||||
"""
|
||||
|
||||
def execute(self, reconhecimentotipo_schema: TTbReconhecimentotipoUpdateSchema):
|
||||
def execute(self, tb_reconhecimentotipo_id : int, reconhecimentotipo_schema: TTbReconhecimentotipoUpdateSchema):
|
||||
"""
|
||||
Executa a operação de atualização.
|
||||
|
||||
|
|
@ -22,4 +22,4 @@ class UpdateAction:
|
|||
update_repository = UpdateRepository()
|
||||
|
||||
# Chama o método de execução do repositório para realizar a atualização
|
||||
return update_repository.execute(reconhecimentotipo_schema)
|
||||
return update_repository.execute(tb_reconhecimentotipo_id, reconhecimentotipo_schema)
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
# Importação de bibliotecas
|
||||
from packages.v1.administrativo.schemas.c_caixa_item_schema import (
|
||||
CaixaItemSchema, CaixaItemSearchSchema)
|
||||
from packages.v1.administrativo.schemas.c_caixa_item_schema import CaixaItemSchema
|
||||
from actions.dynamic_import.dynamic_import import DynamicImport
|
||||
|
||||
|
||||
|
|
@ -17,7 +16,7 @@ class CCaixaItemController:
|
|||
def index(self):
|
||||
|
||||
# Importação da classe desejad
|
||||
indexService = self.dynamic_import.service("index_service", "IndexService")
|
||||
indexService = self.dynamic_import.service("c_caixa_item_index_service", "IndexService")
|
||||
|
||||
# Intânciamento da classe service
|
||||
self.indexService = indexService()
|
||||
|
|
@ -31,7 +30,7 @@ class CCaixaItemController:
|
|||
def create(self, caixa_item_schema: CaixaItemSchema):
|
||||
|
||||
# Importação da classe desejada
|
||||
createService = self.dynamic_import.service("g_usuario_save_service", "GUsuarioSaveService")
|
||||
createService = self.dynamic_import.service("c_caixa_item_save_service", "SaveService")
|
||||
|
||||
# Intânciamento da classe service
|
||||
self.createService = createService()
|
||||
|
|
@ -42,9 +41,25 @@ class CCaixaItemController:
|
|||
'data': self.createService.execute(caixa_item_schema)
|
||||
}
|
||||
|
||||
|
||||
def update(self, caixa_item_id : int, caixa_item_schema: CaixaItemSchema):
|
||||
|
||||
# Importação da classe desejada
|
||||
updateService = self.dynamic_import.service("c_caixa_item_update_service", "UpdateService")
|
||||
|
||||
# Intânciamento da classe service
|
||||
self.updateService = updateService()
|
||||
|
||||
# Lista todos os produtos
|
||||
return {
|
||||
'message' : 'Registros cadastrado com sucesso',
|
||||
'data': self.updateService.execute(caixa_item_id, caixa_item_schema)
|
||||
}
|
||||
|
||||
|
||||
def show(self, caixa_item_schema: CaixaItemSchema):
|
||||
# Importação da classe desejad
|
||||
showService = self.dynamic_import.service("show_service", "ShowService")
|
||||
showService = self.dynamic_import.service("c_caixa_item_show_service", "ShowService")
|
||||
|
||||
# Intânciamento da classe service
|
||||
self.showService = showService()
|
||||
|
|
@ -57,7 +72,7 @@ class CCaixaItemController:
|
|||
|
||||
def delete(self, caixa_item_schema: CaixaItemSchema):
|
||||
# Importação da classe desejad
|
||||
deleteService = self.dynamic_import.service("delete_service", "DeleteService")
|
||||
deleteService = self.dynamic_import.service("c_caixa_item_delete_service", "DeleteService")
|
||||
|
||||
# Intânciamento da classe service
|
||||
self.deleteService = deleteService()
|
||||
|
|
|
|||
|
|
@ -83,7 +83,7 @@ class CCaixaServicoController:
|
|||
}
|
||||
|
||||
# Atualiza os dados de um usuário
|
||||
def update(self, caixa_servico_schema : CCaixaServicoUpdateSchema):
|
||||
def update(self, caixa_servico_id : int, caixa_servico_schema : CCaixaServicoUpdateSchema):
|
||||
|
||||
#Importação da classe desejada
|
||||
save_service = self.dynamic_import.service('c_caixa_servico_update_service', 'CCaixaServicoUpdateService')
|
||||
|
|
@ -94,7 +94,7 @@ class CCaixaServicoController:
|
|||
# Busca e retorna o usuário desejado
|
||||
return {
|
||||
'message' : 'Caixa Serviço atualizado com sucesso',
|
||||
'data': self.save_service.execute(caixa_servico_schema)
|
||||
'data': self.save_service.execute(caixa_servico_id, caixa_servico_schema)
|
||||
}
|
||||
|
||||
# Exclui um usuário
|
||||
|
|
|
|||
|
|
@ -149,7 +149,7 @@ class GUsuarioController:
|
|||
}
|
||||
|
||||
# Atualiza os dados de um usuário
|
||||
def update(self, usuario_schema : GUsuarioUpdateSchema):
|
||||
def update(self, usuario_id: int, usuario_schema : GUsuarioUpdateSchema):
|
||||
|
||||
#Importação da classe desejada
|
||||
save_service = self.dynamic_import.service('g_usuario_update_service', 'GUsuarioUpdateService')
|
||||
|
|
@ -160,7 +160,7 @@ class GUsuarioController:
|
|||
# Busca e retorna o usuário desejado
|
||||
return {
|
||||
'message' : 'Usuário atualizado com sucesso',
|
||||
'data': self.save_service.execute(usuario_schema)
|
||||
'data': self.save_service.execute(usuario_id, usuario_schema)
|
||||
}
|
||||
|
||||
# Exclui um usuário
|
||||
|
|
|
|||
|
|
@ -83,7 +83,7 @@ class TTbReconhecimentotipoController:
|
|||
}
|
||||
|
||||
# Atualiza os dados de um tipo de reconhecimento
|
||||
def update(self, reconhecimentotipo_schema : TTbReconhecimentotipoUpdateSchema):
|
||||
def update(self, tb_reconhecimentotipo_id : int, reconhecimentotipo_schema : TTbReconhecimentotipoUpdateSchema):
|
||||
|
||||
#Importação da classe desejada
|
||||
update_service = self.dynamic_import.service('t_tb_reconhecimentotipo_update_service', 'TTbReconhecimentotipoUpdateService')
|
||||
|
|
@ -94,7 +94,7 @@ class TTbReconhecimentotipoController:
|
|||
# Busca e retorna o tipo de reconhecimento desejado
|
||||
return {
|
||||
'message' : 'Tipo de reconhecimento atualizado com sucesso',
|
||||
'data': self.update_service.execute(reconhecimentotipo_schema)
|
||||
'data': self.update_service.execute(tb_reconhecimentotipo_id, reconhecimentotipo_schema)
|
||||
}
|
||||
|
||||
# Exclui um tipo de reconhecimento
|
||||
|
|
|
|||
|
|
@ -1,14 +1,9 @@
|
|||
# Importação de bibliotecas
|
||||
from typing import Optional
|
||||
|
||||
from fastapi import APIRouter, Body, Depends, status
|
||||
|
||||
from actions.jwt.get_current_user import get_current_user
|
||||
|
||||
from packages.v1.administrativo.controllers.c_caixa_item_controller import \
|
||||
CCaixaItemController
|
||||
from packages.v1.administrativo.schemas.c_caixa_item_schema import (
|
||||
CaixaItemSchema, CaixaItemSearchSchema)
|
||||
from packages.v1.administrativo.controllers.c_caixa_item_controller import CCaixaItemController
|
||||
from packages.v1.administrativo.schemas.c_caixa_item_schema import CaixaItemSchema, CaixaItemSearchSchema
|
||||
|
||||
# Inicializar o roteaodr para as rotas de produtos
|
||||
router = APIRouter()
|
||||
|
|
@ -39,6 +34,20 @@ async def save(caixa_item_schema: CaixaItemSchema, current_user : dict = Depends
|
|||
# Retorna a informação desejada
|
||||
return response
|
||||
|
||||
|
||||
@router.put('/{caixa_item_id}',
|
||||
status_code=status.HTTP_201_CREATED,
|
||||
summary="Atualiza uma nova receita ou despesa no sistema",
|
||||
response_description="Confirmação de atualização da receita ou despesa, incluindo detalhes do item criado.")
|
||||
async def save(caixa_item_id : int, caixa_item_schema: CaixaItemSchema, current_user : dict = Depends(get_current_user)):
|
||||
|
||||
# Salva o produto desejado
|
||||
response = cCaixaItemController.update(caixa_item_id, caixa_item_schema)
|
||||
|
||||
# Retorna a informação desejada
|
||||
return response
|
||||
|
||||
|
||||
@router.get('/{caixa_item_id}',
|
||||
status_code=status.HTTP_200_OK,
|
||||
summary="Busca um registro em específico",
|
||||
|
|
|
|||
|
|
@ -79,14 +79,14 @@ async def save(caixa_servico_schema : CCaixaServicoSaveSchema, current_user: dic
|
|||
|
||||
|
||||
# Atualiza os dados de caixa serviço
|
||||
@router.put('/',
|
||||
@router.put('/{caixa_servico_id}',
|
||||
status_code=status.HTTP_200_OK,
|
||||
summary='Atualiza um caixa serviço',
|
||||
response_description='Atualiza um serviço')
|
||||
async def update(caixa_servico_schema : CCaixaServicoUpdateSchema, current_user: dict = Depends(get_current_user)):
|
||||
async def update(caixa_servico_id : int, caixa_servico_schema : CCaixaServicoUpdateSchema, current_user: dict = Depends(get_current_user)):
|
||||
|
||||
# Efetua a atualização dos dados de usuário
|
||||
response = c_caixa_servico_controller.update(caixa_servico_schema)
|
||||
response = c_caixa_servico_controller.update(caixa_servico_id, caixa_servico_schema)
|
||||
|
||||
# Retorna os dados localizados
|
||||
return response
|
||||
|
|
|
|||
|
|
@ -139,14 +139,14 @@ async def save(usuario_schema : GUsuarioSaveSchema, current_user: dict = Depends
|
|||
return response
|
||||
|
||||
# Atualiza os dados de usuário
|
||||
@router.put('/',
|
||||
@router.put('/{usuario_id}',
|
||||
status_code=status.HTTP_200_OK,
|
||||
summary='Atualiza um usuário',
|
||||
response_description='Atualiza um usuário')
|
||||
async def update(usuario_schema : GUsuarioUpdateSchema, current_user: dict = Depends(get_current_user)):
|
||||
async def update(usuario_id : int, usuario_schema : GUsuarioUpdateSchema, current_user: dict = Depends(get_current_user)):
|
||||
|
||||
# Efetua a atualização dos dados de usuário
|
||||
response = g_usuario_controller.update(usuario_schema)
|
||||
response = g_usuario_controller.update(usuario_id, usuario_schema)
|
||||
|
||||
# Retorna os dados localizados
|
||||
return response
|
||||
|
|
|
|||
|
|
@ -79,14 +79,14 @@ async def save(reconhecimentotipo_schema : TTbReconhecimentotipoSaveSchema, curr
|
|||
|
||||
|
||||
# Atualiza os dados de um tipo de reconhecimento
|
||||
@router.put('/',
|
||||
@router.put('/{tb_reconhecimentotipo_id}',
|
||||
status_code=status.HTTP_200_OK,
|
||||
summary='Atualiza um tipo de reconhecimento',
|
||||
response_description='Atualiza um tipo de reconhecimento')
|
||||
async def update(reconhecimentotipo_schema : TTbReconhecimentotipoUpdateSchema, current_user: dict = Depends(get_current_user)):
|
||||
async def update(tb_reconhecimentotipo_id : int, reconhecimentotipo_schema : TTbReconhecimentotipoUpdateSchema, current_user: dict = Depends(get_current_user)):
|
||||
|
||||
# Efetua a atualização dos dados
|
||||
response = t_tb_reconhecimentotipo_controller.update(reconhecimentotipo_schema)
|
||||
response = t_tb_reconhecimentotipo_controller.update(tb_reconhecimentotipo_id, reconhecimentotipo_schema)
|
||||
|
||||
# Retorna os dados localizados
|
||||
return response
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
from packages.v1.administrativo.schemas.c_caixa_item_schema import \
|
||||
CaixaItemSchema
|
||||
from packages.v1.administrativo.schemas.c_caixa_item_schema import CaixaItemSchema
|
||||
from abstracts.repository import BaseRepository
|
||||
|
||||
|
||||
|
|
@ -1,5 +1,4 @@
|
|||
from packages.v1.administrativo.schemas.c_caixa_item_schema import \
|
||||
CaixaItemSearchSchema
|
||||
from packages.v1.administrativo.schemas.c_caixa_item_schema import CaixaItemSearchSchema
|
||||
from abstracts.repository import BaseRepository
|
||||
|
||||
|
||||
|
|
@ -1,6 +1,5 @@
|
|||
# Importação de bibliotecas
|
||||
from packages.v1.administrativo.schemas.c_caixa_item_schema import \
|
||||
CaixaItemSchema
|
||||
from packages.v1.administrativo.schemas.c_caixa_item_schema import CaixaItemSchema
|
||||
from abstracts.repository import BaseRepository
|
||||
|
||||
|
||||
|
|
@ -1,5 +1,4 @@
|
|||
from packages.v1.administrativo.schemas.c_caixa_item_schema import \
|
||||
CaixaItemSchema
|
||||
from packages.v1.administrativo.schemas.c_caixa_item_schema import CaixaItemSchema
|
||||
from abstracts.repository import BaseRepository
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,109 @@
|
|||
# Importação de bibliotecas
|
||||
from packages.v1.administrativo.schemas.c_caixa_item_schema import CaixaItemSchema
|
||||
from abstracts.repository import BaseRepository
|
||||
from fastapi import HTTPException, status
|
||||
|
||||
|
||||
class UpdateRepository(BaseRepository):
|
||||
|
||||
def execute(self, caixa_item_id : int, caixa_item_schema : CaixaItemSchema):
|
||||
|
||||
try:
|
||||
updates = []
|
||||
params = {}
|
||||
|
||||
if caixa_item_schema.especie_pagamento is not None:
|
||||
updates.append("ESPECIE_PAGAMENTO = :especie_pagamento")
|
||||
params["especie_pagamento"] = caixa_item_schema.especie_pagamento
|
||||
|
||||
if caixa_item_schema.caixa_item_id is not None:
|
||||
updates.append("CAIXA_ITEM_ID = :caixa_item_id")
|
||||
params["caixa_item_id"] = caixa_item_schema.caixa_item_id
|
||||
|
||||
if caixa_item_schema.caixa_servico_id is not None:
|
||||
updates.append("CAIXA_SERVICO_ID = :caixa_servico_id")
|
||||
params["caixa_servico_id"] = caixa_item_schema.caixa_servico_id
|
||||
|
||||
if caixa_item_schema.usuario_servico_id is not None:
|
||||
updates.append("USUARIO_SERVICO_ID = :usuario_servico_id")
|
||||
params["usuario_servico_id"] = caixa_item_schema.usuario_servico_id
|
||||
|
||||
if caixa_item_schema.usuario_caixa_id is not None:
|
||||
updates.append("USUARIO_CAIXA_ID = :usuario_caixa_id")
|
||||
params["usuario_caixa_id"] = caixa_item_schema.usuario_caixa_id
|
||||
|
||||
if caixa_item_schema.descricao is not None:
|
||||
updates.append("DESCRICAO = :descricao")
|
||||
params["descricao"] = caixa_item_schema.descricao
|
||||
|
||||
if caixa_item_schema.data_pagamento is not None:
|
||||
updates.append("DATA_PAGAMENTO = :data_pagamento")
|
||||
params["data_pagamento"] = caixa_item_schema.data_pagamento
|
||||
|
||||
if caixa_item_schema.situacao is not None:
|
||||
updates.append("SITUACAO = :situacao")
|
||||
params["situacao"] = caixa_item_schema.situacao
|
||||
|
||||
if caixa_item_schema.tipo_documento is not None:
|
||||
updates.append("TIPO_DOCUMENTO = :tipo_documento")
|
||||
params["tipo_documento"] = caixa_item_schema.tipo_documento
|
||||
|
||||
if caixa_item_schema.tipo_transacao is not None:
|
||||
updates.append("TIPO_TRANSACAO = :tipo_transacao")
|
||||
params["tipo_transacao"] = caixa_item_schema.tipo_transacao
|
||||
|
||||
if caixa_item_schema.valor_servico is not None:
|
||||
updates.append("VALOR_SERVICO = :valor_servico")
|
||||
params["valor_servico"] = caixa_item_schema.valor_servico
|
||||
|
||||
if caixa_item_schema.valor_pago is not None:
|
||||
updates.append("VALOR_PAGO = :valor_pago")
|
||||
params["valor_pago"] = caixa_item_schema.valor_pago
|
||||
|
||||
if caixa_item_schema.observacao is not None:
|
||||
updates.append("OBSERVACAO = :observacao")
|
||||
params["observacao"] = caixa_item_schema.observacao
|
||||
|
||||
if caixa_item_schema.hora_pagamento is not None:
|
||||
updates.append("HORA_PAGAMENTO = :hora_pagamento")
|
||||
params["hora_pagamento"] = caixa_item_schema.hora_pagamento
|
||||
|
||||
if caixa_item_schema.tipo_servico is not None:
|
||||
updates.append("TIPO_SERVICO = :tipo_servico")
|
||||
params["tipo_servico"] = caixa_item_schema.tipo_servico
|
||||
|
||||
if caixa_item_schema.registrado is not None:
|
||||
updates.append("REGISTRADO = :registrado")
|
||||
params["registrado"] = caixa_item_schema.registrado
|
||||
|
||||
|
||||
if not updates:
|
||||
return False
|
||||
|
||||
params["caixa_item_id"] = caixa_item_id
|
||||
sql = f"UPDATE C_CAIXA_ITEM SET {', '.join(updates)} WHERE caixa_item_id = :caixa_item_id RETURNING *;"
|
||||
|
||||
# Executa a query
|
||||
result = self.run_and_return(sql, params)
|
||||
|
||||
if not result.caixa_item_id:
|
||||
|
||||
# Informa que não existe usuário a ser modificado
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_422_UNPROCESSABLE_ENTITY,
|
||||
detail='Nenhum caixa serviço localizado para esta solicitação'
|
||||
)
|
||||
|
||||
# Verifica o resultado da execução
|
||||
if result:
|
||||
# Se houver um resultado, a atualização foi bem-sucedida
|
||||
return result
|
||||
|
||||
|
||||
except Exception as e:
|
||||
|
||||
# Informa que houve uma falha na atualização do usuário
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_422_UNPROCESSABLE_ENTITY,
|
||||
detail=f"Erro ao atualizar caixa serviço: {e}"
|
||||
)
|
||||
|
|
@ -4,7 +4,7 @@ from fastapi import HTTPException, status
|
|||
|
||||
class UpdateRepository(BaseRepository):
|
||||
|
||||
def execute(self, c_caixa_servico_schema: CCaixaServicoUpdateSchema):
|
||||
def execute(self, caixa_servico_id : int, c_caixa_servico_schema: CCaixaServicoUpdateSchema):
|
||||
|
||||
try:
|
||||
updates = []
|
||||
|
|
@ -50,7 +50,7 @@ class UpdateRepository(BaseRepository):
|
|||
if not updates:
|
||||
return False
|
||||
|
||||
params["caixa_servico_id"] = c_caixa_servico_schema.caixa_servico_id
|
||||
params["caixa_servico_id"] = caixa_servico_id
|
||||
sql = f"UPDATE C_CAIXA_SERVICO SET {', '.join(updates)} WHERE caixa_servico_id = :caixa_servico_id RETURNING *;"
|
||||
|
||||
# Executa a query
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ from fastapi import HTTPException, status
|
|||
|
||||
class UpdateRepository(BaseRepository):
|
||||
|
||||
def execute(self, usuario_schema: GUsuarioUpdateSchema):
|
||||
def execute(self, usuario_id: int, usuario_schema: GUsuarioUpdateSchema):
|
||||
try:
|
||||
updates = []
|
||||
params = {}
|
||||
|
|
@ -44,7 +44,7 @@ class UpdateRepository(BaseRepository):
|
|||
if not updates:
|
||||
return False
|
||||
|
||||
params["usuario_id"] = usuario_schema.usuario_id
|
||||
params["usuario_id"] = usuario_id
|
||||
sql = f"UPDATE G_USUARIO SET {', '.join(updates)} WHERE USUARIO_ID = :usuario_id RETURNING *;"
|
||||
|
||||
# Executa a query
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ class UpdateRepository(BaseRepository):
|
|||
Repositório para a operação de atualização na tabela T_TB_RECONHECIMENTOTIPO.
|
||||
"""
|
||||
|
||||
def execute(self, reconhecimentotipo_schema: TTbReconhecimentotipoUpdateSchema):
|
||||
def execute(self, tb_reconhecimentotipo_id : int, reconhecimentotipo_schema: TTbReconhecimentotipoUpdateSchema):
|
||||
"""
|
||||
Executa a atualização de um registro na tabela.
|
||||
|
||||
|
|
@ -35,7 +35,7 @@ class UpdateRepository(BaseRepository):
|
|||
if not updates:
|
||||
return False
|
||||
|
||||
params["tb_reconhecimentotipo_id"] = reconhecimentotipo_schema.tb_reconhecimentotipo_id
|
||||
params["tb_reconhecimentotipo_id"] = tb_reconhecimentotipo_id
|
||||
sql = f"UPDATE T_TB_RECONHECIMENTOTIPO SET {', '.join(updates)} WHERE tb_reconhecimentotipo_id = :tb_reconhecimentotipo_id RETURNING *;"
|
||||
|
||||
# Executa a query
|
||||
|
|
|
|||
|
|
@ -1,9 +1,7 @@
|
|||
from datetime import date, datetime
|
||||
from typing import Optional
|
||||
|
||||
from pydantic import BaseModel
|
||||
|
||||
|
||||
class CaixaItemSchema(BaseModel):
|
||||
especie_pagamento: Optional[str] = None
|
||||
caixa_item_id: Optional[int] = None
|
||||
|
|
|
|||
|
|
@ -121,7 +121,7 @@ class CCaixaServicoSaveSchema(BaseModel):
|
|||
# Schema para atualizar caixa serviço (PUT)
|
||||
# ----------------------------------------------------
|
||||
class CCaixaServicoUpdateSchema(BaseModel):
|
||||
caixa_servico_id: int
|
||||
|
||||
tipo_transacao: Optional[str] = None
|
||||
sistema_id: Optional[int] = None
|
||||
situacao: Optional[str] = None
|
||||
|
|
|
|||
|
|
@ -111,7 +111,6 @@ class GUsuarioIdSchema(BaseModel):
|
|||
# ----------------------------------------------------
|
||||
class GUsuarioSaveSchema(BaseModel):
|
||||
|
||||
usuario_id: Optional[int] = None
|
||||
trocarsenha: Optional[str] = None
|
||||
login: str
|
||||
situacao: str
|
||||
|
|
@ -186,7 +185,6 @@ class GUsuarioSaveSchema(BaseModel):
|
|||
# ----------------------------------------------------
|
||||
class GUsuarioUpdateSchema(BaseModel):
|
||||
|
||||
usuario_id: int
|
||||
trocarsenha: Optional[str] = None
|
||||
login: Optional[str] = None
|
||||
situacao: Optional[str] = None
|
||||
|
|
@ -213,10 +211,6 @@ class GUsuarioUpdateSchema(BaseModel):
|
|||
# Variavel responsavel em armaezar os erros
|
||||
errors = []
|
||||
|
||||
# Validação do usuario_id
|
||||
if not self.usuario_id or self.usuario_id == 0:
|
||||
errors.append({'input': 'usuario_id', 'message': 'O ID do usuário é obrigatório.'})
|
||||
|
||||
# Validação do login
|
||||
if not self.login or len(self.login.strip()) == 0:
|
||||
errors.append({'input': 'login', 'message': 'O login é obrigatório.'})
|
||||
|
|
|
|||
|
|
@ -78,7 +78,7 @@ class TTbReconhecimentotipoSaveSchema(BaseModel):
|
|||
# Schema para atualizar tipo (PUT)
|
||||
# ----------------------------------------------------
|
||||
class TTbReconhecimentotipoUpdateSchema(BaseModel):
|
||||
tb_reconhecimentotipo_id: int
|
||||
|
||||
descricao: Optional[str] = None
|
||||
situacao: Optional[str] = None
|
||||
|
||||
|
|
@ -94,9 +94,6 @@ class TTbReconhecimentotipoUpdateSchema(BaseModel):
|
|||
def validate_all_fields(self):
|
||||
errors = []
|
||||
|
||||
if not self.tb_reconhecimentotipo_id or self.tb_reconhecimentotipo_id == 0:
|
||||
errors.append({'input': 'tb_reconhecimentotipo_id', 'message': 'O ID do tipo é obrigatório.'})
|
||||
|
||||
if not self.descricao or len(self.descricao.strip()) == 0:
|
||||
errors.append({'input': 'descricao', 'message': 'A descrição é obrigatória.'})
|
||||
|
||||
|
|
|
|||
|
|
@ -1,11 +1,7 @@
|
|||
from fastapi import HTTPException, status
|
||||
|
||||
from packages.v1.administrativo.actions.c_caixa_item.delete_action import \
|
||||
DeleteAction
|
||||
from packages.v1.administrativo.actions.c_caixa_item.show_action import \
|
||||
ShowAction
|
||||
from packages.v1.administrativo.schemas.c_caixa_item_schema import \
|
||||
CaixaItemSchema
|
||||
from packages.v1.administrativo.actions.c_caixa_item.c_caixa_item_delete_action import DeleteAction
|
||||
from packages.v1.administrativo.actions.c_caixa_item.c_caixa_item_show_action import ShowAction
|
||||
from packages.v1.administrativo.schemas.c_caixa_item_schema import CaixaItemSchema
|
||||
|
||||
|
||||
class DeleteService:
|
||||
|
|
@ -1,7 +1,5 @@
|
|||
from packages.v1.administrativo.actions.c_caixa_item.index_action import \
|
||||
IndexAction
|
||||
from packages.v1.administrativo.schemas.c_caixa_item_schema import \
|
||||
CaixaItemSearchSchema
|
||||
from packages.v1.administrativo.actions.c_caixa_item.c_caixa_item_index_action import IndexAction
|
||||
from packages.v1.administrativo.schemas.c_caixa_item_schema import CaixaItemSearchSchema
|
||||
|
||||
|
||||
class IndexService:
|
||||
|
|
@ -1,11 +1,7 @@
|
|||
from packages.v1.administrativo.actions.c_caixa_item.save_action import \
|
||||
SaveAction
|
||||
from packages.v1.administrativo.schemas.c_caixa_item_schema import \
|
||||
CaixaItemSchema
|
||||
from packages.v1.administrativo.actions.c_caixa_item.c_caixa_item_save_action import SaveAction
|
||||
from packages.v1.administrativo.schemas.c_caixa_item_schema import CaixaItemSchema
|
||||
from packages.v1.sequencia.schemas.g_sequencia import GSequenciaSchema
|
||||
from packages.v1.sequencia.services.g_sequencia.generate_service import \
|
||||
GenerateService
|
||||
|
||||
from packages.v1.sequencia.services.g_sequencia.generate_service import GenerateService
|
||||
|
||||
class SaveService:
|
||||
|
||||
|
|
@ -1,10 +1,6 @@
|
|||
from fastapi import HTTPException, status
|
||||
|
||||
from packages.v1.administrativo.actions.c_caixa_item.show_action import \
|
||||
ShowAction
|
||||
from packages.v1.administrativo.schemas.c_caixa_item_schema import \
|
||||
CaixaItemSchema
|
||||
|
||||
from packages.v1.administrativo.actions.c_caixa_item.c_caixa_item_show_action import ShowAction
|
||||
from packages.v1.administrativo.schemas.c_caixa_item_schema import CaixaItemSchema
|
||||
|
||||
class ShowService:
|
||||
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
from packages.v1.administrativo.actions.c_caixa_item.c_caixa_item_update_action import UpdateAction
|
||||
from packages.v1.administrativo.schemas.c_caixa_item_schema import CaixaItemSchema
|
||||
|
||||
|
||||
class UpdateService:
|
||||
|
||||
def execute(self, caixa_item_id : int, caixa_item_schema: CaixaItemSchema):
|
||||
|
||||
# Instânciamento de ações
|
||||
updateAction = UpdateAction()
|
||||
|
||||
# Retorna todos produtos desejados
|
||||
return updateAction.execute(caixa_item_id, caixa_item_schema)
|
||||
|
|
@ -3,10 +3,10 @@ from packages.v1.administrativo.actions.c_caixa_servico.c_caixa_servico_update_a
|
|||
|
||||
class CCaixaServicoUpdateService:
|
||||
|
||||
def execute(self, caixa_servico_schema: CCaixaServicoUpdateSchema):
|
||||
def execute(self, caixa_servico_id : int, caixa_servico_schema: CCaixaServicoUpdateSchema):
|
||||
|
||||
# Instânciamento de ações
|
||||
updateAction = UpdateAction()
|
||||
|
||||
# Retorna todos produtos desejados
|
||||
return updateAction.execute(caixa_servico_schema)
|
||||
return updateAction.execute(caixa_servico_id, caixa_servico_schema)
|
||||
|
|
@ -3,10 +3,10 @@ from packages.v1.administrativo.actions.g_usuario.g_usuario_update_action import
|
|||
|
||||
class GUsuarioUpdateService:
|
||||
|
||||
def execute(self, usuario_schema: GUsuarioUpdateSchema):
|
||||
def execute(self, usuario_id: int, usuario_schema: GUsuarioUpdateSchema):
|
||||
|
||||
# Instânciamento de ações
|
||||
updateAction = UpdateAction()
|
||||
|
||||
# Retorna todos produtos desejados
|
||||
return updateAction.execute(usuario_schema)
|
||||
return updateAction.execute(usuario_id, usuario_schema)
|
||||
|
|
@ -6,7 +6,7 @@ class TTbReconhecimentotipoUpdateService:
|
|||
Serviço para a operação de atualização de um registro na tabela
|
||||
t_tb_reconhecimentotipo.
|
||||
"""
|
||||
def execute(self, reconhecimentotipo_schema: TTbReconhecimentotipoUpdateSchema):
|
||||
def execute(self, tb_reconhecimentotipo_id : int, reconhecimentotipo_schema: TTbReconhecimentotipoUpdateSchema):
|
||||
"""
|
||||
Executa a operação de atualização no banco de dados.
|
||||
|
||||
|
|
@ -20,4 +20,4 @@ class TTbReconhecimentotipoUpdateService:
|
|||
update_action = UpdateAction()
|
||||
|
||||
# Retorna o resultado da operação
|
||||
return update_action.execute(reconhecimentotipo_schema)
|
||||
return update_action.execute(tb_reconhecimentotipo_id, reconhecimentotipo_schema)
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ api_router = APIRouter()
|
|||
|
||||
# Inclui as rotas de caixa
|
||||
api_router.include_router(
|
||||
c_caixa_item_endpoint.router, prefix="/administrativo/caixa", tags=["Caixa"]
|
||||
c_caixa_item_endpoint.router, prefix="/administrativo/c_caixa_item", tags=["Caixa Item"]
|
||||
)
|
||||
|
||||
# Inclui as rotas de usuários
|
||||
|
|
|
|||
|
|
@ -889,5 +889,57 @@
|
|||
"storage/temp/validation_exception_handler.json",
|
||||
"storage/temp/validation_exception_handler.json",
|
||||
"storage/temp/http_exception_handler.json",
|
||||
"storage/temp/validation_exception_handler.json"
|
||||
"storage/temp/validation_exception_handler.json",
|
||||
"storage/temp/http_exception_handler.json",
|
||||
"storage/temp/http_exception_handler.json",
|
||||
"storage/temp/http_exception_handler.json",
|
||||
"storage/temp/http_exception_handler.json",
|
||||
"storage/temp/http_exception_handler.json",
|
||||
"storage/temp/http_exception_handler.json",
|
||||
"storage/temp/validation_exception_handler.json",
|
||||
"storage/temp/http_exception_handler.json",
|
||||
"storage/temp/validation_exception_handler.json",
|
||||
"storage/temp/http_exception_handler.json",
|
||||
"storage/temp/http_exception_handler.json",
|
||||
"storage/temp/http_exception_handler.json",
|
||||
"storage/temp/http_exception_handler.json",
|
||||
"storage/temp/http_exception_handler.json",
|
||||
"storage/temp/http_exception_handler.json",
|
||||
"storage/temp/http_exception_handler.json",
|
||||
"storage/temp/http_exception_handler.json",
|
||||
"storage/temp/validation_exception_handler.json",
|
||||
"storage/temp/http_exception_handler.json",
|
||||
"storage/temp/http_exception_handler.json",
|
||||
"storage/temp/http_exception_handler.json",
|
||||
"storage/temp/http_exception_handler.json",
|
||||
"storage/temp/http_exception_handler.json",
|
||||
"storage/temp/http_exception_handler.json",
|
||||
"storage/temp/validation_exception_handler.json",
|
||||
"storage/temp/validation_exception_handler.json",
|
||||
"storage/temp/validation_exception_handler.json",
|
||||
"storage/temp/http_exception_handler.json",
|
||||
"storage/temp/http_exception_handler.json",
|
||||
"storage/temp/http_exception_handler.json",
|
||||
"storage/temp/http_exception_handler.json",
|
||||
"storage/temp/validation_exception_handler.json",
|
||||
"storage/temp/http_exception_handler.json",
|
||||
"storage/temp/validation_exception_handler.json",
|
||||
"storage/temp/validation_exception_handler.json",
|
||||
"storage/temp/validation_exception_handler.json",
|
||||
"storage/temp/http_exception_handler.json",
|
||||
"storage/temp/http_exception_handler.json",
|
||||
"storage/temp/http_exception_handler.json",
|
||||
"storage/temp/http_exception_handler.json",
|
||||
"storage/temp/http_exception_handler.json",
|
||||
"storage/temp/validation_exception_handler.json",
|
||||
"storage/temp/validation_exception_handler.json",
|
||||
"storage/temp/validation_exception_handler.json",
|
||||
"storage/temp/validation_exception_handler.json",
|
||||
"storage/temp/http_exception_handler.json",
|
||||
"storage/temp/http_exception_handler.json",
|
||||
"storage/temp/http_exception_handler.json",
|
||||
"storage/temp/validation_exception_handler.json",
|
||||
"storage/temp/validation_exception_handler.json",
|
||||
"storage/temp/http_exception_handler.json",
|
||||
"storage/temp/http_exception_handler.json"
|
||||
]
|
||||
File diff suppressed because it is too large
Load diff
Loading…
Add table
Reference in a new issue