feat: 实现按物质匹配反应
This commit is contained in:
+2
-2
@@ -1,8 +1,8 @@
|
|||||||
from flask import Blueprint
|
from flask import Blueprint
|
||||||
from ..services import cards
|
from ..utils import cards
|
||||||
|
|
||||||
card_bp = Blueprint("card", __name__, "/card")
|
card_bp = Blueprint("card", __name__, "/card")
|
||||||
|
|
||||||
@card_bp.route("/<id>")
|
@card_bp.route("/id/<id>")
|
||||||
def search_card(id):
|
def search_card(id):
|
||||||
return cards.readCard(id)
|
return cards.readCard(id)
|
||||||
@@ -1,8 +1,12 @@
|
|||||||
from flask import Blueprint
|
from flask import Blueprint
|
||||||
from ..services import matters
|
from ..utils import matters
|
||||||
|
|
||||||
matter_bp = Blueprint("matter", __name__, "/matter")
|
matter_bp = Blueprint("matter", __name__, "/matter")
|
||||||
|
|
||||||
@matter_bp.route("/<id>")
|
@matter_bp.route("/id/<id>")
|
||||||
def search_matter(id):
|
def search_matter(id):
|
||||||
return matters.readMatter(id)
|
return matters.readMatter(id)
|
||||||
|
|
||||||
|
@matter_bp.route("/match/<id>")
|
||||||
|
def select_matter(id):
|
||||||
|
return id
|
||||||
@@ -1,8 +1,8 @@
|
|||||||
from flask import Blueprint
|
from flask import Blueprint
|
||||||
from ..services import reactions
|
from ..utils import reactions
|
||||||
|
|
||||||
reaction_bp = Blueprint("reaction", __name__, "/reaction")
|
reaction_bp = Blueprint("reaction", __name__, "/reaction")
|
||||||
|
|
||||||
@reaction_bp.route("/<id>")
|
@reaction_bp.route("/id/<id>")
|
||||||
def search_reaction(id):
|
def search_reaction(id):
|
||||||
return reactions.readReaction(id)
|
return reactions.readReaction(id)
|
||||||
@@ -7,6 +7,13 @@ def readMatterList() -> dict:
|
|||||||
|
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
def readMatchList() -> dict:
|
||||||
|
with open("resources/reactions/match.json", "r", encoding="utf8") as f:
|
||||||
|
text = f.read()
|
||||||
|
result = json.loads(text)
|
||||||
|
|
||||||
|
return result
|
||||||
|
|
||||||
def readMatter(id: str):
|
def readMatter(id: str):
|
||||||
path = readMatterList().get(id, -1)
|
path = readMatterList().get(id, -1)
|
||||||
if (path == -1):
|
if (path == -1):
|
||||||
@@ -16,3 +23,10 @@ def readMatter(id: str):
|
|||||||
result = json.loads(text)
|
result = json.loads(text)
|
||||||
|
|
||||||
return {"message": "OK", "content": result}
|
return {"message": "OK", "content": result}
|
||||||
|
|
||||||
|
def selectMatter(id: str):
|
||||||
|
matter_id = readMatchList().get(id, -1)
|
||||||
|
if (matter_id == -1):
|
||||||
|
return {"message": f"No Matter {id}"}
|
||||||
|
|
||||||
|
return readMatter(matter_id)
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
{
|
||||||
|
"Carbon-Oxygen-": "CarbonDioxide"
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user