Browse Source

調整add的錯誤

zooey 1 năm trước cách đây
mục cha
commit
370ee3b259
2 tập tin đã thay đổi với 19 bổ sung5 xóa
  1. 9 3
      app/api/users.py
  2. 10 2
      app/models/models.py

+ 9 - 3
app/api/users.py

@@ -47,7 +47,7 @@ async def query_user(user_id: str):
     return result
 
 
-@manager.user_loader()
+#@manager.user_loader()
 async def query_user_username(user_id: str):
     """
     Get a user from the db
@@ -153,7 +153,7 @@ async def add(username: str = Form(default=''), password: str = Form(default='')
         else:
             if password == re_password:
                 hashed_password = bcrypt.hashpw(password.encode('utf-8'), bcrypt.gensalt()).decode('utf-8')
-                u = await User.create(username=username, password=hashed_password, email=email,is_superuser=0,is_gmail=0)
+                u = await User.create(username=username, password=hashed_password, email=email,is_superuser=0,is_gmail=0,token='')
                 if u:
                     message = '註冊成功'
                     subject = '註冊信'
@@ -316,4 +316,10 @@ async def delete(id: int):
 @users.get("/information")
 async def get_information(email:str,is_gmail:int):
     result = await User.filter(email=email, is_gmail=is_gmail).first()
-    return {"msg":result, "code":200}
+    return {"msg":result, "code":200}
+
+@users.get("/protect")    
+def protected_route(user=Depends(manager)):
+    if user is None:
+        return {'message': "no access"}
+    return {'user': user}

+ 10 - 2
app/models/models.py

@@ -91,6 +91,7 @@ class News(Model):
     files = fields.TextField(description="附加檔案")
     URL = fields.TextField(description="外部連結")
     tags = fields.TextField(description="標籤")
+    cover_img = fields.CharField(max_length=255, description="封面圖片")
 
 class Favorite_course(Model):
     id = fields.IntField(pk=True)
@@ -132,5 +133,12 @@ class Guidance_group(Model):
     contact_person = fields.CharField(max_length=125, description="聯絡人")
     contact_phone = fields.CharField(max_length=125, description="聯絡電話")
     line = fields.IntField(description="LINE (0:沒有、1:有)")
-    online_meet = fields.IntField(description="線上會議 (0:沒有、1:有)")
-    remark = fields.TextField(description="備註")
+    address = fields.TextField(description="地址")
+    email = fields.CharField(max_length=125, description="信箱")
+    information = fields.TextField(description="開課資訊")
+    request = fields.TextField(description="需求")
+    schedule = fields.CharField(max_length=45, description="處理進度")
+    result = fields.CharField(max_length=125, description="處理結果")
+    person = fields.CharField(max_length=45, description="輔導人員")
+    remark = fields.TextField(description="備註")
+