26 lines
523 B
Python
26 lines
523 B
Python
|
from fastapi import APIRouter
|
||
|
from pydantic import BaseModel
|
||
|
|
||
|
|
||
|
INDEX = "CFO/总债务(倍)"
|
||
|
|
||
|
router = APIRouter()
|
||
|
|
||
|
|
||
|
class Params(BaseModel):
|
||
|
短期借款: float
|
||
|
长期借款: float
|
||
|
经营性现金流净额: float
|
||
|
|
||
|
|
||
|
@router.post("/{}".format(INDEX))
|
||
|
def func(p: Params):
|
||
|
try:
|
||
|
result = p.经营性现金流净额 / (p.短期借款 + p.长期借款)
|
||
|
return round(result, 6)
|
||
|
|
||
|
except ZeroDivisionError:
|
||
|
return "算式无意义"
|
||
|
except Exception:
|
||
|
return "计算错误"
|