2022-12-22 15:34:49 +08:00
|
|
|
from fastapi import APIRouter
|
|
|
|
from pydantic import BaseModel
|
|
|
|
|
|
|
|
|
|
|
|
INDEX = "所有者权益(亿元)"
|
|
|
|
|
|
|
|
router = APIRouter()
|
|
|
|
|
|
|
|
|
|
|
|
class Params(BaseModel):
|
2023-01-04 09:27:12 +08:00
|
|
|
所有者权益: float
|
2022-12-22 15:34:49 +08:00
|
|
|
|
|
|
|
|
|
|
|
@router.post("/{}".format(INDEX))
|
|
|
|
def func(p: Params):
|
|
|
|
try:
|
2023-01-04 09:27:12 +08:00
|
|
|
result = p.所有者权益 / 100000000
|
2023-01-04 14:52:23 +08:00
|
|
|
return round(result, 2)
|
2022-12-22 15:34:49 +08:00
|
|
|
|
|
|
|
except ZeroDivisionError:
|
|
|
|
return "算式无意义"
|
|
|
|
except Exception:
|
|
|
|
return "计算错误"
|