Ver Fonte

更換 上傳資料路徑

Mia Cheng há 1 ano atrás
pai
commit
f2a52cbf23
4 ficheiros alterados com 16 adições e 7 exclusões
  1. 13 5
      app/api/article.py
  2. 1 1
      app/api/classes.py
  3. 1 1
      app/api/news.py
  4. 1 0
      app/models/models.py

+ 13 - 5
app/api/article.py

@@ -18,7 +18,7 @@ from fastapi.responses import HTMLResponse
 
 article = APIRouter()
 
-IMAGEDIR = "/var/www/html/ntcri/assets/article_files/"
+IMAGEDIR = "/var/www/ntcri/ntcri/assets/article_files/"
 IMAGEDIR_short = "assets/article_files/"
 
 async def create_upload_files(files:Optional[List[UploadFile]] = File(None)):
@@ -86,7 +86,8 @@ async def get_article(
             "files" : article_obj.files,
             "vedio_url" : article_obj.vedio_url,
             "tags" : article_obj.tags,
-            "cover_img": article_obj.cover_img
+            "cover_img": article_obj.cover_img,
+            "url" : article_obj.url
             }
             if page_num and page_amount:
                 if count < page_num*page_amount and count >= (page_num-1)*page_amount :
@@ -124,7 +125,8 @@ async def insert_article(
     content : str = Form(default=''),
     depiction :str = Form(default=''),
     vedio_url :str = Form(default=''),
-    cover_img_file:UploadFile = File(default='')
+    cover_img_file:UploadFile = File(default=''),
+    url : str = Form(default='')
 ):
     try:
         cover_img = ''
@@ -154,7 +156,8 @@ async def insert_article(
             cover_img = cover_img,
             click_time = 0,
             is_del = 0,
-            files = ""
+            url = url ,
+            files = str({})
         )
         
         return {"msg": "success", "code": 200, "new_article": new_article.id}
@@ -173,6 +176,7 @@ async def update_article(
     content : str = Form(default=''),
     depiction :str = Form(default=''),
     vedio_url :str = Form(default=''),
+    url :str = Form(default=''),
     cover_img_file:UploadFile = File(default='')
 ):
     try:
@@ -209,6 +213,9 @@ async def update_article(
         if tags != '[]':
             article_obj.tags = tags
 
+        if url != '[]':
+            article_obj.url = url
+
         
         if cover_img_file != '':
             contents = await cover_img_file.read()
@@ -262,7 +269,8 @@ async def search_article_like(keyword: str,page_num : Optional[int] = None,
             "files" : article_obj.files,
             "vedio_url" : article_obj.vedio_url,
             "tags" : article_obj.tags,
-            "cover_img": article_obj.cover_img
+            "cover_img": article_obj.cover_img,
+            "url" : article_obj.url
         }
             if page_num and page_amount:
                 if count < page_num*page_amount and count >= (page_num-1)*page_amount :

+ 1 - 1
app/api/classes.py

@@ -35,7 +35,7 @@ async def check_token(access_token: str):
 
     return user_id
 
-IMAGEDIR = "/var/www/html/ntcri/assets/"
+IMAGEDIR = "/var/www/ntcri/ntcri/assets/"
 IMAGEDIR_short = "assets/"
 
 async def update_location_time(location_id: int):

+ 1 - 1
app/api/news.py

@@ -18,7 +18,7 @@ from fastapi.responses import HTMLResponse
 
 news = APIRouter()
 
-IMAGEDIR = "/var/www/html/ntcri/assets/news_files/"
+IMAGEDIR = "/var/www/ntcri/ntcri/assets/news_files/"
 IMAGEDIR_short = "assets/news_files/"
 
 @news.get("/get_news")

+ 1 - 0
app/models/models.py

@@ -134,6 +134,7 @@ class Article_list(Model):
     content = fields.TextField(description="內容")
     is_del = fields.IntField(description="是否刪除")
     files = fields.TextField(description="附件")
+    url = fields.TextField(description="文章連結")
 
 class Online_course(Model):
     id = fields.IntField(pk=True)