|
@@ -4,6 +4,9 @@ from dotenv import load_dotenv
|
|
|
import os
|
|
|
from datetime import datetime
|
|
|
from random import choice
|
|
|
+from openai import OpenAI
|
|
|
+
|
|
|
+client = OpenAI()
|
|
|
|
|
|
load_dotenv()
|
|
|
|
|
@@ -15,6 +18,8 @@ supabase: Client = create_client(url, key)
|
|
|
|
|
|
dbRouter = APIRouter()
|
|
|
|
|
|
+
|
|
|
+
|
|
|
@dbRouter.get("/click")
|
|
|
def add_click_time():
|
|
|
|
|
@@ -37,7 +42,7 @@ def add_click_time():
|
|
|
|
|
|
|
|
|
@dbRouter.get("/find_brand")
|
|
|
-def find_brand(keyword:str = None):
|
|
|
+def find_brand(keyword:str = None,language :str = "ch"):
|
|
|
|
|
|
if keyword is None :
|
|
|
return {"state":"fail","message" : "no keyword"}
|
|
@@ -45,6 +50,7 @@ def find_brand(keyword:str = None):
|
|
|
try :
|
|
|
data, count = supabase.table('101_brand')\
|
|
|
.select('*')\
|
|
|
+ .eq("language", language)\
|
|
|
.like('tags', f'%{keyword}%')\
|
|
|
.execute()
|
|
|
|
|
@@ -52,6 +58,7 @@ def find_brand(keyword:str = None):
|
|
|
|
|
|
for shop in data[1] :
|
|
|
|
|
|
+
|
|
|
json = {
|
|
|
"type" : shop["type"],
|
|
|
"info" : shop
|
|
@@ -123,7 +130,7 @@ async def static_tickets(is_Chinese : int = None):
|
|
|
return {"state":"fail","message" :str(e)}
|
|
|
|
|
|
@dbRouter.get("/ad/{type}")
|
|
|
-def read_root(type:str):
|
|
|
+def read_root(type:str,language :str = "ch"):
|
|
|
|
|
|
keyword1 :str
|
|
|
keyword2 :str
|
|
@@ -138,6 +145,7 @@ def read_root(type:str):
|
|
|
data, count = supabase.table('101_brand')\
|
|
|
.select('*')\
|
|
|
.eq("floor","館外")\
|
|
|
+ .eq("language", language)\
|
|
|
.or_(f"tags.ilike.%{keyword1}%,tags.ilike.%{keyword2}%")\
|
|
|
.execute()
|
|
|
|