diff --git a/.gitignore b/.gitignore index 8a8b253..de8d400 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,4 @@ backend/pyvenv.cfg backend/Include/ backend/Scripts/ +log/api.log diff --git a/backend/app/api/api_v1/routers/kintone.py b/backend/app/api/api_v1/routers/kintone.py index 5f91e21..e1c3ecc 100644 --- a/backend/app/api/api_v1/routers/kintone.py +++ b/backend/app/api/api_v1/routers/kintone.py @@ -3,6 +3,7 @@ from io import BytesIO import typing as t import pandas as pd import json +import base64 import httpx import deepdiff import app.core.config as config @@ -493,6 +494,17 @@ async def test(file:UploadFile= File(...),app:str=None): return test +@r.get("/group") +async def group(request:Request,kintoneurl:str,kintoneuser:str,kintonepwd:str): + try: + auth_value = base64.b64encode(bytes(f"{kintoneuser}:{kintonepwd}","utf-8")) + headers={config.API_V1_AUTH_KEY:auth_value} + url = f"{kintoneurl}/v1/user/groups.json?code={kintoneuser}" + r = httpx.get(url,headers=headers) + return r.json() + except Exception as e: + raise APIException('kintone:app',request.url._url, f"Error occurred while get app({env.DOMAIN_NAME}->{app}):",e) + @r.post("/download",) async def download(request:Request,key,c:config.KINTONE_ENV=Depends(getkintoneenv)): try: diff --git a/backend/app/core/operation.py b/backend/app/core/operation.py index 36eab3a..9bdfe87 100644 --- a/backend/app/core/operation.py +++ b/backend/app/core/operation.py @@ -13,10 +13,14 @@ import json class LoggingMiddleware(BaseHTTPMiddleware): async def dispatch(self, request: Request, call_next): if request.method in ("POST", "PUT", "PATCH","DELETE"): - try: - request.state.body = await request.json() - except json.JSONDecodeError: - request.state.body = await request.body() + content_type = request.headers.get('content-type', '') + if content_type.startswith('multipart/form-data'): + request.state.body = None + else: + try: + request.state.body = await request.json() + except json.JSONDecodeError: + request.state.body = await request.body() else: request.state.body = None diff --git a/backend/app/db/cruddb/dbapp.py b/backend/app/db/cruddb/dbapp.py index d741886..023d36d 100644 --- a/backend/app/db/cruddb/dbapp.py +++ b/backend/app/db/cruddb/dbapp.py @@ -1,6 +1,7 @@ from datetime import datetime from fastapi import HTTPException, status from sqlalchemy.orm import Session +from sqlalchemy.orm.attributes import flag_modified from sqlalchemy import select,and_ import typing as t @@ -202,6 +203,7 @@ class dbapp(crudbase): db_app = self.get_app(db, domainurl, flow.appid) if db_app and db_app.version > 0: db_app.is_saved = True + flag_modified(db_app, 'is_saved') db.add(db_app) db.commit() db.refresh(db_flow)