From dc695030d6fd5e2afd251b9621341666821b1242 Mon Sep 17 00:00:00 2001 From: Tiger Date: Tue, 20 Jan 2026 08:45:50 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=AE=9E=E7=8E=B0=E6=8C=89=E7=89=A9?= =?UTF-8?q?=E8=B4=A8=E5=8C=B9=E9=85=8D=E5=8F=8D=E5=BA=94?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/routes/cards.py | 4 ++-- app/routes/matters.py | 10 +++++++--- app/routes/reactions.py | 4 ++-- app/services/__init__.py | 0 app/{services => utils}/assets.py | 0 app/{services => utils}/cards.py | 0 app/{services => utils}/matters.py | 16 +++++++++++++++- app/{services => utils}/reactions.py | 0 resources/reactions/match.json | 3 +++ 9 files changed, 29 insertions(+), 8 deletions(-) delete mode 100644 app/services/__init__.py rename app/{services => utils}/assets.py (100%) rename app/{services => utils}/cards.py (100%) rename app/{services => utils}/matters.py (53%) rename app/{services => utils}/reactions.py (100%) create mode 100644 resources/reactions/match.json diff --git a/app/routes/cards.py b/app/routes/cards.py index 802c275..db11aee 100644 --- a/app/routes/cards.py +++ b/app/routes/cards.py @@ -1,8 +1,8 @@ from flask import Blueprint -from ..services import cards +from ..utils import cards card_bp = Blueprint("card", __name__, "/card") -@card_bp.route("/") +@card_bp.route("/id/") def search_card(id): return cards.readCard(id) \ No newline at end of file diff --git a/app/routes/matters.py b/app/routes/matters.py index bfa13db..1edc06e 100644 --- a/app/routes/matters.py +++ b/app/routes/matters.py @@ -1,8 +1,12 @@ from flask import Blueprint -from ..services import matters +from ..utils import matters matter_bp = Blueprint("matter", __name__, "/matter") -@matter_bp.route("/") +@matter_bp.route("/id/") def search_matter(id): - return matters.readMatter(id) \ No newline at end of file + return matters.readMatter(id) + +@matter_bp.route("/match/") +def select_matter(id): + return id \ No newline at end of file diff --git a/app/routes/reactions.py b/app/routes/reactions.py index dee6fab..4579a27 100644 --- a/app/routes/reactions.py +++ b/app/routes/reactions.py @@ -1,8 +1,8 @@ from flask import Blueprint -from ..services import reactions +from ..utils import reactions reaction_bp = Blueprint("reaction", __name__, "/reaction") -@reaction_bp.route("/") +@reaction_bp.route("/id/") def search_reaction(id): return reactions.readReaction(id) \ No newline at end of file diff --git a/app/services/__init__.py b/app/services/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/app/services/assets.py b/app/utils/assets.py similarity index 100% rename from app/services/assets.py rename to app/utils/assets.py diff --git a/app/services/cards.py b/app/utils/cards.py similarity index 100% rename from app/services/cards.py rename to app/utils/cards.py diff --git a/app/services/matters.py b/app/utils/matters.py similarity index 53% rename from app/services/matters.py rename to app/utils/matters.py index 6f26ca2..4cac723 100644 --- a/app/services/matters.py +++ b/app/utils/matters.py @@ -7,6 +7,13 @@ def readMatterList() -> dict: 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): path = readMatterList().get(id, -1) if (path == -1): @@ -15,4 +22,11 @@ def readMatter(id: str): text = f.read() result = json.loads(text) - return {"message": "OK", "content": result} \ No newline at end of file + 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) \ No newline at end of file diff --git a/app/services/reactions.py b/app/utils/reactions.py similarity index 100% rename from app/services/reactions.py rename to app/utils/reactions.py diff --git a/resources/reactions/match.json b/resources/reactions/match.json new file mode 100644 index 0000000..9bc2f02 --- /dev/null +++ b/resources/reactions/match.json @@ -0,0 +1,3 @@ +{ + "Carbon-Oxygen-": "CarbonDioxide" +} \ No newline at end of file