Configuracion final de back con serve
This commit is contained in:
24
Back_comercial_iko/services/Comercial_service.py
Normal file
24
Back_comercial_iko/services/Comercial_service.py
Normal file
@@ -0,0 +1,24 @@
|
||||
from Back_comercial_iko.database.Database import Database
|
||||
from Back_comercial_iko.models.Societe_model import SocieteModel
|
||||
from Back_comercial_iko.core.validators.Field_validator import FieldValidator
|
||||
from Back_comercial_iko.core.SocieteNotFoundException import SocieteNotFoundException
|
||||
|
||||
class ComercialService:
|
||||
|
||||
def __init__(self):
|
||||
self.conn = Database()
|
||||
self.db = self.conn.setConnection()
|
||||
|
||||
def create_project_commercial(self, data: dict):
|
||||
|
||||
FieldValidator.required(data.get("ex_societe"), "ex_societe")
|
||||
FieldValidator.required(data.get("nomUser"), "nomUser")
|
||||
nombre_soc = data.get("ex_societe")
|
||||
result_soc = (self.db.query(SocieteModel.ROWID, SocieteModel.NOM).filter(SocieteModel.NOM == nombre_soc).first())
|
||||
if not result_soc:
|
||||
raise SocieteNotFoundException()
|
||||
|
||||
return {
|
||||
"fk_soc": result_soc.ROWID,
|
||||
"nombre_soc": nombre_soc
|
||||
}
|
||||
Reference in New Issue
Block a user