Skip to content

Commit

Permalink
加入渠道管理
Browse files Browse the repository at this point in the history
  • Loading branch information
duolabmeng6 committed Sep 16, 2024
1 parent b15b66c commit e84f088
Show file tree
Hide file tree
Showing 4 changed files with 132 additions and 0 deletions.
81 changes: 81 additions & 0 deletions app/public/pages/page-provider.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
{
"type": "page",
"title": "渠道管理",
"remark": null,
"name": "page-provider",
"body": [
{
"type": "crud",
"syncLocation": false,
"api": {
"method": "get",
"url": "/admin/provider",
"adaptor": "const uniqueProviders = [...new Set(payload.items.map(item => item.provider))]; const uniqueNames = [...new Set(payload.items.map(item => item.name))]; const uniqueOriginalModels = [...new Set(payload.items.map(item => item.original_model))]; const uniqueMappedModels = [...new Set(payload.items.map(item => item.mapped_model))]; return {\n ...payload,\n providerOptions: uniqueProviders.map(provider => ({\n label: provider,\n value: provider\n })),\n nameOptions: uniqueNames.map(name => ({\n label: name,\n value: name\n })),\n originalModelOptions: uniqueOriginalModels.map(model => ({\n label: model,\n value: model\n })),\n mappedModelOptions: uniqueMappedModels.map(model => ({\n label: model,\n value: model\n }))\n}"
},
"perPage": 100,
"loadDataOnce": true,
"columns": [
{
"name": "provider",
"label": "提供商",
"type": "text",
"searchable": {
"type": "select",
"name": "provider",
"label": "提供商",
"placeholder": "选择提供商",
"source": "${providerOptions}"
}
},
{
"name": "name",
"label": "名称",
"type": "text",
"searchable": {
"type": "select",
"name": "name",
"label": "名称",
"placeholder": "选择名称",
"source": "${nameOptions}"
}
},
{
"name": "original_model",
"label": "原始模型",
"type": "text",
"searchable": {
"type": "select",
"name": "original_model",
"label": "原始模型",
"placeholder": "选择原始模型",
"source": "${originalModelOptions}"
}
},
{
"name": "mapped_model",
"label": "映射模型",
"type": "text",
"searchable": {
"type": "select",
"name": "mapped_model",
"label": "映射模型",
"placeholder": "选择映射模型",
"source": "${mappedModelOptions}"
}
},
{
"name": "base_url",
"label": "基础URL",
"type": "text",
"searchable": true
},
{
"name": "weight",
"label": "权重",
"type": "number",
"sortable": true
}
]
}
]
}
10 changes: 10 additions & 0 deletions app/public/pages/site.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,16 @@
}
]
},
{
"children": [
{
"label": "渠道管理",
"url": "/pages/provider",
"icon": "fa fa-cube",
"schemaApi": "get:/pages/page-provider.json"
}
]
},
{
"children": [
{
Expand Down
39 changes: 39 additions & 0 deletions app/routers/provider.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
from fastapi import APIRouter, HTTPException, Query, Body, Path
from fastapi.responses import JSONResponse
from typing import List
from app.db.reqLogs import RequestLogger
from pydantic import BaseModel
import datetime

router = APIRouter()


from app.api_data import db, get_db


@router.get("/provider")
async def index(
):
pass
db = get_db()
data = db.get_all_provider()
return JSONResponse({
"items": data,
"total": 0
})

@router.post("/provider")
async def store():
pass

@router.get("/provider/{log_id}")
async def show():
pass

@router.put("/provider/{log_id}")
async def update():
pass

@router.delete("/provider/{log_id}")
async def destroy():
pass
2 changes: 2 additions & 0 deletions app/routers/router.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from app.routers import admin
from app.routers import statistics
from app.routers import systemConfig
from app.routers import provider
from app.routers.web_config import jwt_bearer

api_router = APIRouter()
Expand All @@ -16,6 +17,7 @@
api_router.include_router(page.router, prefix="/page", tags=["page"])
api_router.include_router(reqLogs.router, prefix="/admin", tags=["reqLogs"], dependencies=[Depends(jwt_bearer)])
api_router.include_router(reqCache.router, prefix="/admin", tags=["reqCache"], dependencies=[Depends(jwt_bearer)])
api_router.include_router(provider.router, prefix="/admin", tags=["provider"], dependencies=[Depends(jwt_bearer)])


api_router.include_router(systemConfig.router, prefix="/admin", tags=["SystemConfig"], dependencies=[Depends(jwt_bearer)])
Expand Down

0 comments on commit e84f088

Please sign in to comment.