flow domainid->domainurl add app flowhistory
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
from fastapi import Query, Request,Depends, APIRouter, UploadFile,HTTPException,File
|
||||
from app.core.operation import log_operation
|
||||
from app.db import Base,engine
|
||||
from app.db.session import get_db
|
||||
from app.db.crud import *
|
||||
@@ -7,6 +8,9 @@ from typing import List, Optional
|
||||
from app.core.auth import get_current_active_user,get_current_user
|
||||
from app.core.apiexception import APIException
|
||||
|
||||
import httpx
|
||||
import app.core.config as config
|
||||
|
||||
platform_router = r = APIRouter()
|
||||
|
||||
|
||||
@@ -17,11 +21,40 @@ platform_router = r = APIRouter()
|
||||
)
|
||||
async def apps_list(
|
||||
request: Request,
|
||||
user = Depends(get_current_user),
|
||||
db=Depends(get_db),
|
||||
):
|
||||
try:
|
||||
app = get_apps(db)
|
||||
return app
|
||||
platformapps = get_apps(db)
|
||||
domain = get_activedomain(db, user.id)
|
||||
|
||||
kintoneevn = config.KINTONE_ENV(domain)
|
||||
headers={config.API_V1_AUTH_KEY:kintoneevn.API_V1_AUTH_VALUE}
|
||||
url = f"{kintoneevn.BASE_URL}{config.API_V1_STR}/apps.json"
|
||||
offset = 0
|
||||
limit = 100
|
||||
all_apps = []
|
||||
|
||||
while True:
|
||||
r = httpx.get(f"{url}?limit={limit}&offset={offset}", headers=headers)
|
||||
json_data = r.json()
|
||||
apps = json_data.get("apps",[])
|
||||
all_apps.extend(apps)
|
||||
if len(apps)<limit:
|
||||
break
|
||||
offset += limit
|
||||
|
||||
tempapps = platformapps.copy()
|
||||
for papp in tempapps:
|
||||
exist = False
|
||||
for kapp in all_apps:
|
||||
if kapp['appId'] == papp.appid:
|
||||
exist = True
|
||||
break
|
||||
if not exist:
|
||||
platformapps.remove(papp)
|
||||
|
||||
return platformapps
|
||||
except Exception as e:
|
||||
raise APIException('platform:apps',request.url._url,f"Error occurred while get apps:",e)
|
||||
|
||||
@@ -158,7 +191,7 @@ async def flow_list(
|
||||
try:
|
||||
domain = get_activedomain(db, user.id)
|
||||
print("domain=>",domain)
|
||||
flows = get_flows_by_app(db, domain.id, appid)
|
||||
flows = get_flows_by_app(db, domain.url, appid)
|
||||
return flows
|
||||
except Exception as e:
|
||||
raise APIException('platform:flow',request.url._url,f"Error occurred while get flow by appid:",e)
|
||||
@@ -173,7 +206,7 @@ async def flow_create(
|
||||
):
|
||||
try:
|
||||
domain = get_activedomain(db, user.id)
|
||||
return create_flow(db, domain.id, flow)
|
||||
return create_flow(db, domain.url, flow)
|
||||
except Exception as e:
|
||||
raise APIException('platform:flow',request.url._url,f"Error occurred while create flow:",e)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user