feat: 实现物质查询,调整项目结构

This commit is contained in:
2026-01-05 13:07:53 +08:00
parent 8810c969c2
commit 9eb42e8a9d
17 changed files with 25 additions and 7 deletions
+9 -2
View File
@@ -1,11 +1,18 @@
import json
def readMatterList() -> dict:
with open("matters/list.json", "r", encoding="utf8") as f:
with open("resources/matters/list.json", "r", encoding="utf8") as f:
text = f.read()
result = json.loads(text)
return result
def readMatter(id: str):
return readMatterList().get(id, -1)
path = readMatterList().get(id, -1)
if (path == -1):
return {"message": f"No Matter {id}"}
with open(f"resources/matters/{path}.json", "r", encoding="utf8") as f:
text = f.read()
result = json.loads(text)
return {"message": "OK", "content": result}