12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152 |
- from fastapi import Depends, Header
- from sqlalchemy.orm import Session
- from fastapi import APIRouter
- from app.common.security.auth import verify_users
- from constants.constants import CONSTANTS
- from utils import *
- import app.crud as crud
- from app import get_db, schemas
- router = APIRouter(
- prefix="/jpt/constants",
- tags=["constants-常量管理"],
- )
- def format_constants(constants: dict):
- return [{'id': k, 'value': v} for k, v in constants.items()]
- @router.get("/datasources")
- @web_try()
- @sxtimeit
- def get_datasources(token_data: schemas.TokenData = Depends(verify_users)):
- return format_constants(CONSTANTS['DATASOURCES'])
- @router.get("/")
- @web_try()
- @sxtimeit
- def get_constants(type: str,token_data: schemas.TokenData = Depends(verify_users), db: Session = Depends(get_db)):
- return crud.get_constant_list(db, type)
- @router.delete("/")
- @web_try()
- @sxtimeit
- def delete_constants(type: str, value: str, token_data: schemas.TokenData = Depends(verify_users), db: Session = Depends(get_db)):
- return crud.delete_constant(db, type, value)
- @router.get("/task_images")
- @web_try()
- @sxtimeit
- def get_task_images(language: str, type: int, auth_token: str = Header(), token_data: schemas.TokenData = Depends(verify_users)):
- return crud.get_task_images(language, type, auth_token)
- @router.get("/image_version")
- @web_try()
- @sxtimeit
- def get_image_version(image_id: str, auth_token: str = Header(), token_data: schemas.TokenData = Depends(verify_users)):
- return crud.get_image_version(image_id,auth_token)
|