From 52628e57da8b6e02c9c1d76c5542901d8b282052 Mon Sep 17 00:00:00 2001 From: puz372fkg <2904171770@qq.com> Date: Fri, 15 Nov 2024 10:15:45 +0800 Subject: [PATCH 1/5] Initial commit --- README.md | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 README.md diff --git a/README.md b/README.md new file mode 100644 index 0000000..09e363e --- /dev/null +++ b/README.md @@ -0,0 +1,2 @@ +# LOVEGET + From ed28c3d5731e1e2769092f4aedb474a0c712a0d7 Mon Sep 17 00:00:00 2001 From: lsh <1622356900@qq.com> Date: Fri, 15 Nov 2024 10:26:51 +0800 Subject: [PATCH 2/5] =?UTF-8?q?=E6=A1=86=E6=9E=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- fast/1.py | 0 fast/__pycache__/database.cpython-312.pyc | Bin 0 -> 528 bytes fast/__pycache__/main.cpython-312.pyc | Bin 0 -> 3052 bytes fast/__pycache__/models.cpython-312.pyc | Bin 0 -> 656 bytes fast/database.py | 14 +++++ fast/main.py | 70 ++++++++++++++++++++++ fast/models.py | 11 ++++ vue/love | 1 + 8 files changed, 96 insertions(+) create mode 100644 fast/1.py create mode 100644 fast/__pycache__/database.cpython-312.pyc create mode 100644 fast/__pycache__/main.cpython-312.pyc create mode 100644 fast/__pycache__/models.cpython-312.pyc create mode 100644 fast/database.py create mode 100644 fast/main.py create mode 100644 fast/models.py create mode 160000 vue/love diff --git a/fast/1.py b/fast/1.py new file mode 100644 index 0000000..e69de29 diff --git a/fast/__pycache__/database.cpython-312.pyc b/fast/__pycache__/database.cpython-312.pyc new file mode 100644 index 0000000000000000000000000000000000000000..fee397d7aa9f58b721414a2247cfee57f66280bd GIT binary patch literal 528 zcmX@j%ge<81ZKxf(>F6RFgylvV1O0M_#6RbOlL@8NMX!j$YqRTWCXF9a+q?NqnLA9 zqF8`@<|tMshE&E>*402$Kp=_@$Y)MrNnuH4Tf@4V87j&S6lGZr;V?vTRI+KZzXb6# z8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database.py @@ -0,0 +1,14 @@ +from sqlalchemy import create_engine +from sqlalchemy.orm import sessionmaker, declarative_base + +# 数据库连接字符串 +SQLALCHEMY_DATABASE_URL = "mysql+pymysql://root:mypassword12@127.0.0.1:3306/lianai" + +# 创建数据库引擎 +engine = create_engine(SQLALCHEMY_DATABASE_URL) + +# 创建会话本地类 +SessionLocal = sessionmaker(autocommit=False, autoflush=False, bind=engine) + +# 声明基类 +Base = declarative_base() \ No newline at end of file diff --git a/fast/main.py b/fast/main.py new file mode 100644 index 0000000..60d07ae --- /dev/null +++ b/fast/main.py @@ -0,0 +1,70 @@ +from fastapi import FastAPI, Depends, HTTPException, Request +from database import engine, SessionLocal +from models import User +from sqlalchemy.orm import Session +import uvicorn +from models import User + + +app = FastAPI() + +# 创建所有表 +User.metadata.create_all(bind=engine) + +# 依赖注入:获取数据库会话 +def get_db(): + db = SessionLocal() + try: + yield db + finally: + db.close() + + +@app.post("/login") +async def login(request: Request, db: Session = Depends(get_db)): + user_data =await request.json() + print(user_data) + user=db.query(User).filter(User.username==user_data['username']).first() + if user: + if user.password==user_data['password']: + return {"code":200,"msg":"登录成功"} + else: + return {"code":400,"msg":"密码错误"} + return {"code":501,"msg":"账号不存在"} + +@app.post("/register") +async def register(request: Request, db: Session = Depends(get_db)): + user_data =await request.json() + users=db.query(User).filter(User.username==user_data['username']).first() + if users: + return {"code":501,"msg":"账号已存在"} + else: + new_user=User(username=user_data['username'],password=user_data['password']) + db.add(new_user) + db.commit() + db.refresh(new_user) + print(new_user) + return {"code":200,"msg":"注册成功"} + + + + + + + + + + +from fastapi.middleware.cors import CORSMiddleware + +app.add_middleware( + CORSMiddleware, + allow_origins=["*"], + allow_credentials=True, + allow_methods=["*"], + allow_headers=["*"], +) + +if __name__ == '__main__': + # 运行fastapi程序 + uvicorn.run(app="main:app", host="127.0.0.1", port=8000, reload=True) diff --git a/fast/models.py b/fast/models.py new file mode 100644 index 0000000..b9cbbdc --- /dev/null +++ b/fast/models.py @@ -0,0 +1,11 @@ +from sqlalchemy import Column, Integer, String +from database import Base + + + +class User(Base): + __tablename__ = "users" + username = Column(String(30),index=True,primary_key=True) + password = Column(String(100), index=True,nullable=False) + + diff --git a/vue/love b/vue/love new file mode 160000 index 0000000..0bf8e95 --- /dev/null +++ b/vue/love @@ -0,0 +1 @@ +Subproject commit 0bf8e959dd6756c7fe7341ffc11bfa6dbcc23f5a From 82b4cfa4a985c4b84b2cfeeb1c21c74bcfd2bf3e Mon Sep 17 00:00:00 2001 From: lsh <1622356900@qq.com> Date: Fri, 15 Nov 2024 10:35:54 +0800 Subject: [PATCH 3/5] delete --- vue/love | 1 - 1 file changed, 1 deletion(-) delete mode 160000 vue/love diff --git a/vue/love b/vue/love deleted file mode 160000 index 0bf8e95..0000000 --- a/vue/love +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 0bf8e959dd6756c7fe7341ffc11bfa6dbcc23f5a From c88234a7dec98b9db0b539f535855c6616b256e4 Mon Sep 17 00:00:00 2001 From: lsh <1622356900@qq.com> Date: Fri, 15 Nov 2024 11:15:05 +0800 Subject: [PATCH 4/5] vue --- vue | 1 + 1 file changed, 1 insertion(+) create mode 160000 vue diff --git a/vue b/vue new file mode 160000 index 0000000..0bf8e95 --- /dev/null +++ b/vue @@ -0,0 +1 @@ +Subproject commit 0bf8e959dd6756c7fe7341ffc11bfa6dbcc23f5a From 0bf63ff580d6dcfb68318420b7b8db9932cdeb37 Mon Sep 17 00:00:00 2001 From: lsh <1622356900@qq.com> Date: Sat, 16 Nov 2024 14:06:32 +0800 Subject: [PATCH 5/5] delete1 --- vue | 1 - 1 file changed, 1 deletion(-) delete mode 160000 vue diff --git a/vue b/vue deleted file mode 160000 index 0bf8e95..0000000 --- a/vue +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 0bf8e959dd6756c7fe7341ffc11bfa6dbcc23f5a