feat: 考虑到同样物质多种反应的情况
This commit is contained in:
@@ -64,7 +64,9 @@ backend/
|
|||||||
|
|
||||||
```json
|
```json
|
||||||
{
|
{
|
||||||
"Carbon-Oxygen-": "CarbonDioxide",
|
"Carbon-Oxygen-": [
|
||||||
|
"CarbonDioxide"
|
||||||
|
],
|
||||||
"...": "..."
|
"...": "..."
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|||||||
+1
-13
@@ -10,15 +10,10 @@ 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
|
|
||||||
|
|
||||||
matter_list = readMatterList()
|
matter_list = readMatterList()
|
||||||
match_list = readMatchList()
|
|
||||||
|
|
||||||
def readMatter(id: str):
|
def readMatter(id: str):
|
||||||
path = matter_list.get(id, -1)
|
path = matter_list.get(id, -1)
|
||||||
@@ -29,10 +24,3 @@ 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 = match_list.get(id, -1)
|
|
||||||
if (matter_id == -1):
|
|
||||||
return {"message": f"No Matter {id}"}
|
|
||||||
|
|
||||||
return readMatter(matter_id)
|
|
||||||
@@ -10,7 +10,15 @@ def readReactionList() -> 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
|
||||||
|
|
||||||
reaction_list = readReactionList()
|
reaction_list = readReactionList()
|
||||||
|
match_list = readMatchList()
|
||||||
|
|
||||||
def readReaction(id: str):
|
def readReaction(id: str):
|
||||||
path = reaction_list.get(id, -1)
|
path = reaction_list.get(id, -1)
|
||||||
@@ -21,3 +29,11 @@ def readReaction(id: str):
|
|||||||
result = json.loads(text)
|
result = json.loads(text)
|
||||||
|
|
||||||
return {"message": "OK", "content": result}
|
return {"message": "OK", "content": result}
|
||||||
|
|
||||||
|
|
||||||
|
def selectReaction(id: str):
|
||||||
|
matter_id = match_list.get(id, -1)
|
||||||
|
if (matter_id == -1):
|
||||||
|
return {"message": f"No Matter {id}"}
|
||||||
|
|
||||||
|
return matter_id
|
||||||
@@ -1,3 +1,5 @@
|
|||||||
{
|
{
|
||||||
"Carbon-Oxygen-": "CarbonDioxide"
|
"Carbon-Oxygen-": [
|
||||||
|
"CarbonDioxide"
|
||||||
|
]
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user