|
|
@ -1,4 +1,4 @@ |
|
|
|
from fastapi import FastAPI, APIRouter, Request |
|
|
|
from fastapi import FastAPI, APIRouter, Request, HTTPException |
|
|
|
from fastapi.middleware.cors import CORSMiddleware |
|
|
|
from fastapi.responses import ORJSONResponse, HTMLResponse |
|
|
|
from sqlmodel import create_engine, Field, SQLModel, UUID, DateTime, func, Column, text, bindparam |
|
|
@ -72,16 +72,18 @@ async def get_ageement(id_account: Optional[UUID] = None) -> Sequence[Agreement] |
|
|
|
|
|
|
|
@router.delete("/") |
|
|
|
async def delete_pk(acc_list: Sequence[UUID]): |
|
|
|
if acc_list: |
|
|
|
with db_engine.begin() as con: |
|
|
|
stmt = text("DELETE agreement WHERE id_account IN :acc_list") |
|
|
|
params = {"acc_list":acc_list} |
|
|
|
stmt = stmt.bindparams(bindparam('acc_list', expanding=True)) |
|
|
|
con.execute(stmt, params) |
|
|
|
return {"msg":"has deleted"} |
|
|
|
|
|
|
|
raise HTTPException(405,"list is empty") |
|
|
|
|
|
|
|
@router.post("/") |
|
|
|
async def add_agreement(agrees: Sequence[AgreementCreate]): |
|
|
|
if acc_list: |
|
|
|
with db_engine.begin() as con: |
|
|
|
dict_list=[] |
|
|
|
acc_list = [] |
|
|
@ -96,7 +98,7 @@ async def add_agreement(agrees: Sequence[AgreementCreate]): |
|
|
|
con.execute(stmt) |
|
|
|
con.commit() |
|
|
|
return {"msg": "added succesfully"} |
|
|
|
|
|
|
|
raise HTTPException(405,"list is empty") |
|
|
|
app.include_router(router) |
|
|
|
|
|
|
|
if __name__ == "__main__": |
|
|
|