commit eb3ba958cd05e68d6acb2ab99205110c4a6f49ba
Author: wangsiyuan <2392948297@qq.com>
Date: Fri Jan 5 19:04:00 2024 +0800
first commit
diff --git a/.DS_Store b/.DS_Store
new file mode 100644
index 0000000..a7518a4
Binary files /dev/null and b/.DS_Store differ
diff --git a/.idea/.gitignore b/.idea/.gitignore
new file mode 100644
index 0000000..35410ca
--- /dev/null
+++ b/.idea/.gitignore
@@ -0,0 +1,8 @@
+# 默认忽略的文件
+/shelf/
+/workspace.xml
+# 基于编辑器的 HTTP 客户端请求
+/httpRequests/
+# Datasource local storage ignored files
+/dataSources/
+/dataSources.local.xml
diff --git a/.idea/fastApiTest.iml b/.idea/fastApiTest.iml
new file mode 100644
index 0000000..74d515a
--- /dev/null
+++ b/.idea/fastApiTest.iml
@@ -0,0 +1,10 @@
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/inspectionProfiles/Project_Default.xml b/.idea/inspectionProfiles/Project_Default.xml
new file mode 100644
index 0000000..4524d39
--- /dev/null
+++ b/.idea/inspectionProfiles/Project_Default.xml
@@ -0,0 +1,30 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/inspectionProfiles/profiles_settings.xml b/.idea/inspectionProfiles/profiles_settings.xml
new file mode 100644
index 0000000..105ce2d
--- /dev/null
+++ b/.idea/inspectionProfiles/profiles_settings.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/misc.xml b/.idea/misc.xml
new file mode 100644
index 0000000..70f8923
--- /dev/null
+++ b/.idea/misc.xml
@@ -0,0 +1,4 @@
+
+
+
+
\ No newline at end of file
diff --git a/.idea/modules.xml b/.idea/modules.xml
new file mode 100644
index 0000000..d8cc8fd
--- /dev/null
+++ b/.idea/modules.xml
@@ -0,0 +1,8 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/vcs.xml b/.idea/vcs.xml
new file mode 100644
index 0000000..94a25f7
--- /dev/null
+++ b/.idea/vcs.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/__pycache__/main.cpython-311.pyc b/__pycache__/main.cpython-311.pyc
new file mode 100644
index 0000000..2ea37fa
Binary files /dev/null and b/__pycache__/main.cpython-311.pyc differ
diff --git a/assets/.DS_Store b/assets/.DS_Store
new file mode 100644
index 0000000..4295258
Binary files /dev/null and b/assets/.DS_Store differ
diff --git a/assets/images/.DS_Store b/assets/images/.DS_Store
new file mode 100644
index 0000000..2eec8a5
Binary files /dev/null and b/assets/images/.DS_Store differ
diff --git a/assets/images/icon/.DS_Store b/assets/images/icon/.DS_Store
new file mode 100644
index 0000000..5008ddf
Binary files /dev/null and b/assets/images/icon/.DS_Store differ
diff --git a/assets/images/icon/Phone.svg b/assets/images/icon/Phone.svg
new file mode 100644
index 0000000..262b15a
--- /dev/null
+++ b/assets/images/icon/Phone.svg
@@ -0,0 +1 @@
+
\ No newline at end of file
diff --git a/assets/images/icon/eye.svg b/assets/images/icon/eye.svg
new file mode 100644
index 0000000..dad70d0
--- /dev/null
+++ b/assets/images/icon/eye.svg
@@ -0,0 +1 @@
+
\ No newline at end of file
diff --git a/assets/images/icon/home-off.png b/assets/images/icon/home-off.png
new file mode 100644
index 0000000..b2376d6
Binary files /dev/null and b/assets/images/icon/home-off.png differ
diff --git a/assets/images/icon/home-on.png b/assets/images/icon/home-on.png
new file mode 100644
index 0000000..be05a02
Binary files /dev/null and b/assets/images/icon/home-on.png differ
diff --git a/assets/images/icon/password.svg b/assets/images/icon/password.svg
new file mode 100644
index 0000000..9794a34
--- /dev/null
+++ b/assets/images/icon/password.svg
@@ -0,0 +1 @@
+
\ No newline at end of file
diff --git a/assets/images/icon/personal-off.png b/assets/images/icon/personal-off.png
new file mode 100644
index 0000000..463447a
Binary files /dev/null and b/assets/images/icon/personal-off.png differ
diff --git a/assets/images/icon/personal-on.png b/assets/images/icon/personal-on.png
new file mode 100644
index 0000000..0270329
Binary files /dev/null and b/assets/images/icon/personal-on.png differ
diff --git a/assets/images/icon/weixin.svg b/assets/images/icon/weixin.svg
new file mode 100644
index 0000000..3adc187
--- /dev/null
+++ b/assets/images/icon/weixin.svg
@@ -0,0 +1 @@
+
\ No newline at end of file
diff --git a/assets/images/icon/招聘.png b/assets/images/icon/招聘.png
new file mode 100644
index 0000000..911ef68
Binary files /dev/null and b/assets/images/icon/招聘.png differ
diff --git a/assets/images/icon/政策解读.png b/assets/images/icon/政策解读.png
new file mode 100644
index 0000000..8bdfe3b
Binary files /dev/null and b/assets/images/icon/政策解读.png differ
diff --git a/assets/images/icon/群众信息管理.png b/assets/images/icon/群众信息管理.png
new file mode 100644
index 0000000..680e048
Binary files /dev/null and b/assets/images/icon/群众信息管理.png differ
diff --git a/assets/images/icon/问答.png b/assets/images/icon/问答.png
new file mode 100644
index 0000000..86357c8
Binary files /dev/null and b/assets/images/icon/问答.png differ
diff --git a/assets/images/pictures/.DS_Store b/assets/images/pictures/.DS_Store
new file mode 100644
index 0000000..5008ddf
Binary files /dev/null and b/assets/images/pictures/.DS_Store differ
diff --git a/assets/images/pictures/1.png b/assets/images/pictures/1.png
new file mode 100644
index 0000000..6ac5560
Binary files /dev/null and b/assets/images/pictures/1.png differ
diff --git a/assets/images/pictures/2.png b/assets/images/pictures/2.png
new file mode 100644
index 0000000..7755bc8
Binary files /dev/null and b/assets/images/pictures/2.png differ
diff --git a/assets/images/pictures/3.png b/assets/images/pictures/3.png
new file mode 100644
index 0000000..50b3a8a
Binary files /dev/null and b/assets/images/pictures/3.png differ
diff --git a/main.py b/main.py
new file mode 100644
index 0000000..653c708
--- /dev/null
+++ b/main.py
@@ -0,0 +1,94 @@
+from fastapi import FastAPI, HTTPException, Request
+from fastapi.responses import FileResponse
+import base64
+import os
+
+app = FastAPI()
+
+
+@app.get("/")
+async def root():
+ return {"message": "Hello World"}
+
+
+@app.get("/hello/{name}")
+async def say_hello(name: str):
+ return {"message": f"Hello {name}"}
+
+
+@app.post("/user/login")
+async def login(request: Request):
+ print(request)
+ data = await request.json()
+ username = data.get("username")
+ password = data.get("password")
+ print(f"username: {username},password: {password}")
+ # Replace with your actual validation logic
+ if username == "1" and password == "1":
+ data1 = None
+ return {"code": "0", "msg": "ok", "data": data1}
+ else:
+ data2 = None
+ return {"code": "-1", "msg": "账号或密码错误", "data": data2}
+
+
+@app.get("/api/get-menu")
+async def get_menu():
+ pic_list = [
+ {id: 1, "menu_name": "政策查询", "url": "/pages/policy/policy", "path": "assets/images/icon/政策解读.png"},
+ {id: 2, "menu_name": "问答", "url": "/pages/qa/qa", "path": "assets/images/icon/问答.png"},
+ {id: 3, "menu_name": "信息管理", "url": "/pages/assist/assist", "path": "assets/images/icon/群众信息管理.png"},
+ {id: 4, "menu_name": "招聘", "url": "/pages/recruit/recruit", "path": "assets/images/icon/招聘.png"}
+ ]
+ data = []
+ for item in pic_list:
+ with open(item['path'], "rb") as image_file:
+ encoded_string = base64.b64encode(image_file.read()).decode()
+ data.append({
+ "id": item[id],
+ "menu_name": item['menu_name'],
+ "url": item['url'],
+ "base64EncodedImage": encoded_string
+ })
+
+ return {
+ "code": 0,
+ "msg": "ok",
+ "data": data
+ }
+
+
+@app.get("/api/get-swiper-list")
+async def get_swiper_list():
+ # 设置图片所在的目录
+ directory = "assets/images/pictures"
+ base_url = "http://127.0.0.1:8000/api/swiper-image/"
+
+ # 列出目录下所有文件
+ files = os.listdir(directory)
+ for i in files:
+ if i == '.DS_Store':
+ files.remove(i)
+ print(files)
+ # 生成包含完整路径的图片列表
+ swiper_list = [{"id": i + 1, "path": base_url + file} for i, file in enumerate(files)]
+
+ return {
+ "code": 0,
+ "msg": "ok",
+ "data": swiper_list
+ }
+
+
+@app.get("/api/swiper-image/{image_id}.png")
+async def get_swiper_image(image_id: str):
+ base_image_path = "assets/images/pictures"
+ # 构造图片文件的完整路径
+ image_path = f"{base_image_path}/{image_id}.png" # 假设图片格式为png,根据需要修改
+ print(image_path)
+ try:
+ # 返回图片文件的响应
+ return FileResponse(image_path)
+ except FileNotFoundError:
+ # 如果文件没有找到,返回404错误
+ raise HTTPException(status_code=404, detail="Image not found")
\ No newline at end of file
diff --git a/test_main.http b/test_main.http
new file mode 100644
index 0000000..a2d81a9
--- /dev/null
+++ b/test_main.http
@@ -0,0 +1,11 @@
+# Test your FastAPI endpoints
+
+GET http://127.0.0.1:8000/
+Accept: application/json
+
+###
+
+GET http://127.0.0.1:8000/hello/User
+Accept: application/json
+
+###