You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
34 lines
781 B
34 lines
781 B
from fastapi import APIRouter
|
|
from pydantic import BaseModel
|
|
|
|
from helper import respond_to
|
|
from models.taboo import Taboo
|
|
|
|
router = APIRouter(prefix='/taboo')
|
|
|
|
|
|
class TabooCheck(BaseModel):
|
|
mine: str
|
|
othn: str
|
|
|
|
|
|
@router.get('', summary='禁忌下拉选项')
|
|
async def index():
|
|
"""
|
|
禁忌下拉选项
|
|
:return:
|
|
"""
|
|
taboos = await Taboo.all().values_list('name', 'mutex')
|
|
names_set = {i[0] for i in taboos}
|
|
mutex_set = {i[1] for i in taboos}
|
|
result = names_set | mutex_set
|
|
return respond_to(data=list(result))
|
|
|
|
|
|
@router.post('', summary='药剂禁忌')
|
|
async def create(item: TabooCheck):
|
|
trigger, desc = await Taboo.conflict(item.mine, item.othn)
|
|
if trigger:
|
|
return respond_to(code=409, desc=desc)
|
|
return respond_to()
|