Browse Source

輔導團DB欄位調整

Mia Cheng 1 year ago
parent
commit
dcb42af80c
3 changed files with 81 additions and 15 deletions
  1. 52 10
      app/api/guidance.py
  2. 3 3
      app/api/news.py
  3. 26 2
      app/models/models.py

+ 52 - 10
app/api/guidance.py

@@ -36,8 +36,14 @@ async def get_guidance_group(
             "contact_person": news_obj.contact_person,
             "contact_phone" : news_obj.contact_phone,
             "line" : news_obj.line,
-            "online_meet" : news_obj.online_meet,
-            "remark" : news_obj.remark
+            "remark" : news_obj.remark,
+            "address" : news_obj.address,
+            "email" : news_obj.email,
+            "information" : news_obj.information,
+            "request" : news_obj.request,
+            "schedule": news_obj.schedule,
+            "result" : news_obj.result,
+            "person" : news_obj.person
         }
             news_objs.append(news_tmp)
 
@@ -51,8 +57,14 @@ async def insert_news(
     contact_person : str = Form(default=''),
     contact_phone :str = Form(default=''),
     line : int = Form(default=0),
-    online_meet : int = Form(default=0),
-    remark : str = Form(default='')
+    remark : str = Form(default=''),
+    address : str = Form(default=''),
+    email : str = Form(default=''),
+    information : str = Form(default=''),
+    request : str = Form(default=''),
+    schedule : str = Form(default=''),
+    result : str = Form(default=''),
+    person : str = Form(default='')
 ):
     try:
 
@@ -61,8 +73,14 @@ async def insert_news(
             contact_person=contact_person,
             contact_phone=contact_phone,
             line = line,
-            online_meet = online_meet,
-            remark =remark
+            email = email,
+            remark =remark,
+            address = address,
+            information = information,
+            request = request,
+            schedule = schedule ,
+            result = result,
+            person = person
         )
         
         return {"msg": "success", "code": 200, "new_Guidance_group": new_news.id}
@@ -76,8 +94,14 @@ async def update_news(
     contact_person : str = Form(default=''),
     contact_phone :str = Form(default=''),
     line : int = Form(default=None),
-    online_meet : int = Form(default=None),
-    remark : str = Form(default='')
+    remark : str = Form(default=''),
+    address : str = Form(default=''),
+    email : str = Form(default=''),
+    information : str = Form(default=''),
+    request : str = Form(default=''),
+    schedule : str = Form(default=''),
+    result : str = Form(default=''),
+    person : str = Form(default='')
 ):
     try:
         if not guidance_group_id :
@@ -97,11 +121,29 @@ async def update_news(
         if line != None:
             news_obj.line = line
 
-        if online_meet != None:
-            news_obj.online_meet = online_meet
+        if email != None:
+            news_obj.email = email
+
+        if information != None:
+            news_obj.information = information
+
+        if request != None:
+            news_obj.request = request
+
+        if schedule != None:
+            news_obj.schedule = schedule
+
+        if result != None:
+            news_obj.result = result
+
+        if person != None:
+            news_obj.person = person
 
         if remark.strip() != '':
             news_obj.remark = remark
+
+        if address.strip() != '':
+            news_obj.address = address
         
         await news_obj.save()
         

+ 3 - 3
app/api/news.py

@@ -76,7 +76,7 @@ async def insert_news(
     create_time :str = Form(default=datetime.now()),
     content : str = Form(default=''),
     URL :str = Form(default=''),
-    tags : str = Form(default=''),
+    tags : List[str] = Form(default=[]),
     files_url = Depends(create_upload_files)
 ):
     try:
@@ -103,7 +103,7 @@ async def update_news(
     create_time :str = Form(default=datetime.now()),
     content : str = Form(default=''),
     URL :str = Form(default=''),
-    tags : str = Form(default=''),
+    tags : List[str] = Form(default=[]),
     files_url = Depends(create_upload_files)
 ):
     try:
@@ -127,7 +127,7 @@ async def update_news(
         if URL.strip() != '':
             news_obj.URL = URL
 
-        if tags.strip() != '':
+        if tags != []:
             news_obj.tags = tags
         
         news_obj.files = str(files_url)

+ 26 - 2
app/models/models.py

@@ -2,6 +2,10 @@ from tortoise import fields
 from tortoise.models import Model
 from pydantic import BaseModel
 from datetime import datetime
+from tortoise import fields
+from tortoise.models import Model
+from pydantic import BaseModel
+from datetime import datetime
 class User(Model):
     id = fields.IntField(pk=True)
     username = fields.CharField(max_length=30, unique=True, description="帳號")
@@ -10,6 +14,19 @@ class User(Model):
     points = fields.IntField(description="點數")
     is_superuser = fields.IntField(description="超級使用者")
     is_gmail = fields.IntField(description="是否使用gmail登入")
+    token = fields.CharField(max_length=200)
+
+class UserPydantic(BaseModel):
+    id: int
+    username: str
+    password: str
+    email: str
+    points: int
+    is_superuser: int
+    is_gmail: int
+    token: str
+    class Config:
+        orm_mode = True
 
 #學校
 class Schools(Model):
@@ -120,5 +137,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="備註")
+