Spaces:
Sleeping
Sleeping
Delete controller
Browse files- controller/CallbackController.py +0 -156
- controller/ChatController.py +0 -99
- controller/GroupOrderController.py +0 -25
- controller/RecommendController.py +0 -25
- controller/RedirectController.py +0 -95
- controller/__init__.py +0 -0
- controller/__pycache__/CallbackController.cpython-311.pyc +0 -0
- controller/__pycache__/ChatController.cpython-311.pyc +0 -0
- controller/__pycache__/GroupOrderController.cpython-311.pyc +0 -0
- controller/__pycache__/RecommendController.cpython-311.pyc +0 -0
- controller/__pycache__/RedirectController.cpython-311.pyc +0 -0
- controller/__pycache__/__init__.cpython-311.pyc +0 -0
controller/CallbackController.py
DELETED
|
@@ -1,156 +0,0 @@
|
|
| 1 |
-
from fastapi import APIRouter, Request,HTTPException
|
| 2 |
-
from fastapi.security import HTTPBearer, HTTPAuthorizationCredentials
|
| 3 |
-
from fastapi.requests import Request
|
| 4 |
-
import yaml
|
| 5 |
-
from typing import Dict
|
| 6 |
-
from fastapi.responses import RedirectResponse
|
| 7 |
-
from service import CallBackService
|
| 8 |
-
import json
|
| 9 |
-
from fastapi.responses import JSONResponse
|
| 10 |
-
with open("config.yaml", "r") as f:
|
| 11 |
-
config = yaml.safe_load(f)
|
| 12 |
-
base_backend_java = config["callback_urls"]
|
| 13 |
-
base_frontend = config["frontend"]
|
| 14 |
-
|
| 15 |
-
router = APIRouter()
|
| 16 |
-
|
| 17 |
-
class JWTBearer(HTTPBearer):
|
| 18 |
-
def __init__(self, auto_error: bool = True):
|
| 19 |
-
super(JWTBearer, self).__init__(auto_error=auto_error)
|
| 20 |
-
|
| 21 |
-
async def __call__(self, request: Request):
|
| 22 |
-
credentials: HTTPAuthorizationCredentials = await super(JWTBearer, self).__call__(request)
|
| 23 |
-
if credentials:
|
| 24 |
-
if credentials.scheme != "Bearer":
|
| 25 |
-
raise HTTPException(status_code=401, detail="Invalid authentication scheme.")
|
| 26 |
-
return credentials.credentials
|
| 27 |
-
else:
|
| 28 |
-
raise HTTPException(status_code=401, detail="Invalid authorization code.")
|
| 29 |
-
|
| 30 |
-
jwt_bearer = JWTBearer()
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
@router.post("/android/zalo")
|
| 35 |
-
async def zalo_callback_post(request: Request):
|
| 36 |
-
try:
|
| 37 |
-
json_data = await request.json()
|
| 38 |
-
data_str =json_data.get("data")
|
| 39 |
-
if data_str:
|
| 40 |
-
data_dict = json.loads(data_str)
|
| 41 |
-
app_trans_id = data_dict.get("app_trans_id")
|
| 42 |
-
print(app_trans_id)
|
| 43 |
-
data = await CallBackService.zalo_callback(str(app_trans_id))
|
| 44 |
-
return data
|
| 45 |
-
except Exception as e:
|
| 46 |
-
print("Lỗi khi gọi callback web zalo:", e)
|
| 47 |
-
return JSONResponse(content={"error": "Internal server error"}, status_code=500)
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
@router.post("/android/group/zalo")
|
| 51 |
-
async def zalo_callback_post(request: Request):
|
| 52 |
-
try:
|
| 53 |
-
json_data = await request.json()
|
| 54 |
-
data_str =json_data.get("data")
|
| 55 |
-
if data_str:
|
| 56 |
-
data_dict = json.loads(data_str)
|
| 57 |
-
app_trans_id = data_dict.get("app_trans_id")
|
| 58 |
-
print(app_trans_id)
|
| 59 |
-
data = await CallBackService.zalo_group_callback(str(app_trans_id))
|
| 60 |
-
return data
|
| 61 |
-
except Exception as e:
|
| 62 |
-
print("Lỗi khi gọi callback group ảndroid zalo:", e)
|
| 63 |
-
return JSONResponse(content={"error": "Internal server error"}, status_code=500)
|
| 64 |
-
|
| 65 |
-
|
| 66 |
-
@router.get("/android/payOs")
|
| 67 |
-
async def return_url_handler(code: str = None, id: str = None, cancel: bool = None, status: str = None, orderCode: str = None):
|
| 68 |
-
try:
|
| 69 |
-
return await CallBackService.android_payos_callback(status,orderCode)
|
| 70 |
-
except Exception as e:
|
| 71 |
-
print("Lỗi khi gọi callback android payos:", e)
|
| 72 |
-
# Trả về lỗi 500 - Internal Server Error
|
| 73 |
-
return JSONResponse(content={"error": "Internal server error"}, status_code=500)
|
| 74 |
-
|
| 75 |
-
|
| 76 |
-
@router.get("/android/group/payOs")
|
| 77 |
-
async def return_url_handler1(code: str = None, id: str = None, cancel: bool = None, status: str = None, orderCode: str = None):
|
| 78 |
-
try:
|
| 79 |
-
return await CallBackService.android_group_payOs_callback(status,orderCode)
|
| 80 |
-
except Exception as e:
|
| 81 |
-
print("Lỗi khi gọi callback group payos:", e)
|
| 82 |
-
# Trả về lỗi 500 - Internal Server Error
|
| 83 |
-
return JSONResponse(content={"error": "Internal server error"}, status_code=500)
|
| 84 |
-
|
| 85 |
-
|
| 86 |
-
@router.get("/web/payOs")
|
| 87 |
-
async def return_url_handler(code: str = None, id: str = None, cancel: bool = None, status: str = None, orderCode: str = None):
|
| 88 |
-
try:
|
| 89 |
-
return await CallBackService.web_payos_callback(code, id, cancel, status, orderCode)
|
| 90 |
-
except Exception as e:
|
| 91 |
-
print("Lỗi khi gọi callback web payos:", e)
|
| 92 |
-
# Trả về lỗi 500 - Internal Server Error
|
| 93 |
-
return JSONResponse(content={"error": "Internal server error"}, status_code=500)
|
| 94 |
-
|
| 95 |
-
|
| 96 |
-
@router.post("/android/momo")
|
| 97 |
-
async def return_url_handler(request: Request):
|
| 98 |
-
json_data = await request.json()
|
| 99 |
-
print(json_data)
|
| 100 |
-
data_str =json_data.get("data")
|
| 101 |
-
order_id = json_data.get("orderId")
|
| 102 |
-
result_code = json_data.get("resultCode")
|
| 103 |
-
print(data_str)
|
| 104 |
-
|
| 105 |
-
try:
|
| 106 |
-
result = await CallBackService.momo_callback(order_id,result_code)
|
| 107 |
-
print(result)
|
| 108 |
-
except Exception as e:
|
| 109 |
-
print("Lỗi khi gọi call back android momo:", e)
|
| 110 |
-
|
| 111 |
-
if 0 != int(result_code):
|
| 112 |
-
return RedirectResponse(url=f"{base_frontend['android_redirect_base']}?status=-49")
|
| 113 |
-
else :
|
| 114 |
-
return RedirectResponse(url=f"{base_frontend['android_redirect_base']}?status=1")
|
| 115 |
-
|
| 116 |
-
|
| 117 |
-
@router.post("/android/group/momo")
|
| 118 |
-
async def return_url_handler(request: Request):
|
| 119 |
-
json_data = await request.json()
|
| 120 |
-
print(json_data)
|
| 121 |
-
data_str =json_data.get("data")
|
| 122 |
-
order_id = json_data.get("orderId")
|
| 123 |
-
result_code = json_data.get("resultCode")
|
| 124 |
-
print(data_str)
|
| 125 |
-
|
| 126 |
-
try:
|
| 127 |
-
result = await CallBackService.momo_group_callback(order_id,result_code)
|
| 128 |
-
print(result)
|
| 129 |
-
except Exception as e:
|
| 130 |
-
print("Lỗi khi gọi callback android group momo:", e)
|
| 131 |
-
if 0 != int(result_code):
|
| 132 |
-
return RedirectResponse(url=f"""{base_frontend["android_group_redirect_base"]}?status=-49""")
|
| 133 |
-
else :
|
| 134 |
-
return RedirectResponse(url=f"""{base_frontend["android_group_redirect_base"]}?status=1""")
|
| 135 |
-
|
| 136 |
-
|
| 137 |
-
@router.get("/android/vnpay_ipn")
|
| 138 |
-
async def vnpay_ipn(request: Request):
|
| 139 |
-
params: Dict[str, str] = dict(request.query_params)
|
| 140 |
-
try:
|
| 141 |
-
return await CallBackService.vnpay_callbackk(params)
|
| 142 |
-
except Exception as e:
|
| 143 |
-
print("Lỗi khi gọi callback vnpay:", e)
|
| 144 |
-
# Trả về lỗi 500 - Internal Server Error
|
| 145 |
-
return JSONResponse(content={"error": "Internal server error"}, status_code=500)
|
| 146 |
-
|
| 147 |
-
|
| 148 |
-
@router.get("/android/group/vnpay_ipn")
|
| 149 |
-
async def vnpay_ipn(request: Request):
|
| 150 |
-
params: Dict[str, str] = dict(request.query_params)
|
| 151 |
-
try:
|
| 152 |
-
return await CallBackService.vnpay_group_callback(params)
|
| 153 |
-
except Exception as e:
|
| 154 |
-
print("Lỗi khi gọi callback group vnpay ipn:", e)
|
| 155 |
-
# Trả về lỗi 500 - Internal Server Error
|
| 156 |
-
return JSONResponse(content={"error": "Internal server error"}, status_code=500)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
controller/ChatController.py
DELETED
|
@@ -1,99 +0,0 @@
|
|
| 1 |
-
from fastapi import APIRouter, Form, Request,Depends,HTTPException
|
| 2 |
-
from service import ChatService
|
| 3 |
-
from fastapi.security import HTTPBearer, HTTPAuthorizationCredentials
|
| 4 |
-
from request import RequestChat
|
| 5 |
-
from fastapi.requests import Request
|
| 6 |
-
from fastapi.responses import JSONResponse
|
| 7 |
-
router = APIRouter()
|
| 8 |
-
|
| 9 |
-
class JWTBearer(HTTPBearer):
|
| 10 |
-
def __init__(self, auto_error: bool = True):
|
| 11 |
-
super(JWTBearer, self).__init__(auto_error=auto_error)
|
| 12 |
-
|
| 13 |
-
async def __call__(self, request: Request):
|
| 14 |
-
credentials: HTTPAuthorizationCredentials = await super(JWTBearer, self).__call__(request)
|
| 15 |
-
if credentials:
|
| 16 |
-
if credentials.scheme != "Bearer":
|
| 17 |
-
raise HTTPException(status_code=401, detail="Invalid authentication scheme.")
|
| 18 |
-
return credentials.credentials
|
| 19 |
-
else:
|
| 20 |
-
raise HTTPException(status_code=401, detail="Invalid authorization code.")
|
| 21 |
-
|
| 22 |
-
jwt_bearer = JWTBearer()
|
| 23 |
-
import decode_token
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
@router.get("/chat/user_history")
|
| 27 |
-
async def get_user_chat_history(token: str = Depends(jwt_bearer)):
|
| 28 |
-
try:
|
| 29 |
-
user_id_token = decode_token.JwtService.extract_user_id(token)
|
| 30 |
-
return await ChatService.get_user_chat_history(user_id_token)
|
| 31 |
-
except Exception as e:
|
| 32 |
-
print("Lỗi khi gọi user history chat:", e)
|
| 33 |
-
return JSONResponse(content={"error": "Internal server error"}, status_code=500)
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
@router.post("/new_chat/create/")
|
| 37 |
-
async def create_chat(token: str = Depends(jwt_bearer)):
|
| 38 |
-
try:
|
| 39 |
-
user_id_token = decode_token.JwtService.extract_user_id(token)
|
| 40 |
-
new_chat = await ChatService.create_new_chat_history(user_id_token)
|
| 41 |
-
return new_chat
|
| 42 |
-
except Exception as e:
|
| 43 |
-
print("Lỗi khi gọi create new chat:", e)
|
| 44 |
-
return JSONResponse(content={"error": "Internal server error"}, status_code=500)
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
@router.post("/question")
|
| 48 |
-
async def question(request: RequestChat.ChatWithServer, token: str = Depends(jwt_bearer)):
|
| 49 |
-
try:
|
| 50 |
-
user_id_token = decode_token.JwtService.extract_user_id(token)
|
| 51 |
-
user_role = decode_token.JwtService.extract_user_role(token)
|
| 52 |
-
new_chat = await ChatService.chat_with_user(request.user_input,user_id_token,request.language,user_role,token,request.chat_history_id)
|
| 53 |
-
return new_chat
|
| 54 |
-
except Exception as e:
|
| 55 |
-
print("Lỗi khi chạy:", e)
|
| 56 |
-
return JSONResponse(content={"error": "Internal server error"}, status_code=500)
|
| 57 |
-
|
| 58 |
-
|
| 59 |
-
@router.put("/regenerate")
|
| 60 |
-
async def regenerate(request: RequestChat.Regenerate,token: str = Depends(jwt_bearer)):
|
| 61 |
-
try:
|
| 62 |
-
user_id_token = decode_token.JwtService.extract_user_id(token)
|
| 63 |
-
user_role = decode_token.JwtService.extract_user_role(token)
|
| 64 |
-
new_chat = await ChatService.regenerate(request.question_new ,user_id_token,request.languages ,user_role,token,request.chat_id)
|
| 65 |
-
return new_chat
|
| 66 |
-
except Exception as e:
|
| 67 |
-
print("Lỗi khi gọi regenerate:", e)
|
| 68 |
-
return JSONResponse(content={"error": "Internal server error"}, status_code=500)
|
| 69 |
-
|
| 70 |
-
@router.put("/update")
|
| 71 |
-
async def update_chat_name(request: RequestChat.UpdateNameChat, token: str = Depends(jwt_bearer)):
|
| 72 |
-
try:
|
| 73 |
-
user_id_token = decode_token.JwtService.extract_user_id(token)
|
| 74 |
-
updated_chat = await ChatService.update_chat_name(request.chat_id, request.name_chat,user_id_token)
|
| 75 |
-
return updated_chat
|
| 76 |
-
except Exception as e:
|
| 77 |
-
print("Lỗi khi gọi update:", e)
|
| 78 |
-
return JSONResponse(content={"error": "Internal server error"}, status_code=500)
|
| 79 |
-
|
| 80 |
-
|
| 81 |
-
@router.delete("/delete")
|
| 82 |
-
async def delete_chat(request: RequestChat.DeleteChatRequest, token: str = Depends(jwt_bearer)):
|
| 83 |
-
try:
|
| 84 |
-
user_id_token = decode_token.JwtService.extract_user_id(token)
|
| 85 |
-
deleted_chat = await ChatService.soft_delete_chat(request.chat_id,user_id_token)
|
| 86 |
-
return deleted_chat
|
| 87 |
-
except Exception as e:
|
| 88 |
-
print("Lỗi khi gọi deleted:", e)
|
| 89 |
-
return JSONResponse(content={"error": "Internal server error"}, status_code=500)
|
| 90 |
-
|
| 91 |
-
|
| 92 |
-
@router.get("/list_detail_chat/{chat_id}")
|
| 93 |
-
async def get_chat_details(chat_id: str, token: str = Depends(jwt_bearer)):
|
| 94 |
-
try:
|
| 95 |
-
user_id_token = decode_token.JwtService.extract_user_id(token)
|
| 96 |
-
return await ChatService.get_chat_details(chat_id,user_id_token)
|
| 97 |
-
except Exception as e:
|
| 98 |
-
print("Lỗi khi gọi list_detail_chat:", e)
|
| 99 |
-
return JSONResponse(content={"error": "Internal server error"}, status_code=500)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
controller/GroupOrderController.py
DELETED
|
@@ -1,25 +0,0 @@
|
|
| 1 |
-
from fastapi import APIRouter, Form, Request,Depends,HTTPException
|
| 2 |
-
from service import ChatService
|
| 3 |
-
from fastapi.security import HTTPBearer, HTTPAuthorizationCredentials
|
| 4 |
-
from request import RequestChat
|
| 5 |
-
from typing import Optional
|
| 6 |
-
from fastapi.requests import Request
|
| 7 |
-
from fastapi.responses import JSONResponse
|
| 8 |
-
|
| 9 |
-
router = APIRouter()
|
| 10 |
-
|
| 11 |
-
class JWTBearer(HTTPBearer):
|
| 12 |
-
def __init__(self, auto_error: bool = True):
|
| 13 |
-
super(JWTBearer, self).__init__(auto_error=auto_error)
|
| 14 |
-
|
| 15 |
-
async def __call__(self, request: Request):
|
| 16 |
-
credentials: HTTPAuthorizationCredentials = await super(JWTBearer, self).__call__(request)
|
| 17 |
-
if credentials:
|
| 18 |
-
if credentials.scheme != "Bearer":
|
| 19 |
-
raise HTTPException(status_code=401, detail="Invalid authentication scheme.")
|
| 20 |
-
return credentials.credentials
|
| 21 |
-
else:
|
| 22 |
-
raise HTTPException(status_code=401, detail="Invalid authorization code.")
|
| 23 |
-
|
| 24 |
-
jwt_bearer = JWTBearer()
|
| 25 |
-
import decode_token
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
controller/RecommendController.py
DELETED
|
@@ -1,25 +0,0 @@
|
|
| 1 |
-
from fastapi import APIRouter, Form, Request,Depends,HTTPException
|
| 2 |
-
from service import ChatService
|
| 3 |
-
from fastapi.security import HTTPBearer, HTTPAuthorizationCredentials
|
| 4 |
-
from request import RequestChat
|
| 5 |
-
from typing import Optional
|
| 6 |
-
from fastapi.requests import Request
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
router = APIRouter()
|
| 10 |
-
|
| 11 |
-
class JWTBearer(HTTPBearer):
|
| 12 |
-
def __init__(self, auto_error: bool = True):
|
| 13 |
-
super(JWTBearer, self).__init__(auto_error=auto_error)
|
| 14 |
-
|
| 15 |
-
async def __call__(self, request: Request):
|
| 16 |
-
credentials: HTTPAuthorizationCredentials = await super(JWTBearer, self).__call__(request)
|
| 17 |
-
if credentials:
|
| 18 |
-
if credentials.scheme != "Bearer":
|
| 19 |
-
raise HTTPException(status_code=401, detail="Invalid authentication scheme.")
|
| 20 |
-
return credentials.credentials
|
| 21 |
-
else:
|
| 22 |
-
raise HTTPException(status_code=401, detail="Invalid authorization code.")
|
| 23 |
-
|
| 24 |
-
jwt_bearer = JWTBearer()
|
| 25 |
-
import decode_token
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
controller/RedirectController.py
DELETED
|
@@ -1,95 +0,0 @@
|
|
| 1 |
-
from fastapi import APIRouter, Form, Request,Depends,HTTPException
|
| 2 |
-
from service import ChatService
|
| 3 |
-
from fastapi.security import HTTPBearer, HTTPAuthorizationCredentials
|
| 4 |
-
from request import RequestChat
|
| 5 |
-
from typing import Optional
|
| 6 |
-
from fastapi.requests import Request
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
router = APIRouter()
|
| 10 |
-
|
| 11 |
-
class JWTBearer(HTTPBearer):
|
| 12 |
-
def __init__(self, auto_error: bool = True):
|
| 13 |
-
super(JWTBearer, self).__init__(auto_error=auto_error)
|
| 14 |
-
|
| 15 |
-
async def __call__(self, request: Request):
|
| 16 |
-
credentials: HTTPAuthorizationCredentials = await super(JWTBearer, self).__call__(request)
|
| 17 |
-
if credentials:
|
| 18 |
-
if credentials.scheme != "Bearer":
|
| 19 |
-
raise HTTPException(status_code=401, detail="Invalid authentication scheme.")
|
| 20 |
-
return credentials.credentials
|
| 21 |
-
else:
|
| 22 |
-
raise HTTPException(status_code=401, detail="Invalid authorization code.")
|
| 23 |
-
|
| 24 |
-
jwt_bearer = JWTBearer()
|
| 25 |
-
import decode_token
|
| 26 |
-
from service import RedirectService
|
| 27 |
-
from typing import Optional
|
| 28 |
-
from fastapi import Request, Query
|
| 29 |
-
from fastapi.responses import JSONResponse
|
| 30 |
-
@router.get("/android/zalo")
|
| 31 |
-
async def zalo_callback_get(
|
| 32 |
-
amount: Optional[int] = Query(None),
|
| 33 |
-
appid: Optional[str] = Query(None),
|
| 34 |
-
apptransid: Optional[str] = Query(None),
|
| 35 |
-
bankcode: Optional[str] = Query(None),
|
| 36 |
-
checksum: Optional[str] = Query(None),
|
| 37 |
-
discountamount: Optional[int] = Query(None),
|
| 38 |
-
pmcid: Optional[int] = Query(None),
|
| 39 |
-
status: Optional[int] = Query(None)
|
| 40 |
-
):
|
| 41 |
-
return await RedirectService.zalo_redirect(status)
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
@router.get("/android/group/zalo")
|
| 45 |
-
async def zalo_callback_get(
|
| 46 |
-
amount: Optional[int] = Query(None),
|
| 47 |
-
appid: Optional[str] = Query(None),
|
| 48 |
-
apptransid: Optional[str] = Query(None),
|
| 49 |
-
bankcode: Optional[str] = Query(None),
|
| 50 |
-
checksum: Optional[str] = Query(None),
|
| 51 |
-
discountamount: Optional[int] = Query(None),
|
| 52 |
-
pmcid: Optional[int] = Query(None),
|
| 53 |
-
status: Optional[int] = Query(None)
|
| 54 |
-
):
|
| 55 |
-
return await RedirectService.zalo_group_redirect(status)
|
| 56 |
-
|
| 57 |
-
@router.get("/web/zalo")
|
| 58 |
-
async def zalo_web_callback_get(request: Request):
|
| 59 |
-
return await RedirectService.zalo_web_redirect(request.query_params)
|
| 60 |
-
|
| 61 |
-
|
| 62 |
-
@router.get("/android/momo")
|
| 63 |
-
async def return_url_handler_1(request: Request):
|
| 64 |
-
query_params = request.query_params
|
| 65 |
-
return await RedirectService.android_momo_redirect(query_params)
|
| 66 |
-
|
| 67 |
-
@router.get("/android/group/momo")
|
| 68 |
-
async def return_url_handler_group_momo(request: Request):
|
| 69 |
-
query_params = request.query_params
|
| 70 |
-
return await RedirectService.android_group_momo_redirect(query_params)
|
| 71 |
-
|
| 72 |
-
|
| 73 |
-
from urllib.parse import urlencode
|
| 74 |
-
@router.get("/web/momo")
|
| 75 |
-
async def return_url_handler_web(request: Request):
|
| 76 |
-
query_params = request.query_params
|
| 77 |
-
return await RedirectService.web_momo_redirect(query_params)
|
| 78 |
-
|
| 79 |
-
|
| 80 |
-
from typing import Dict
|
| 81 |
-
@router.get("/android/vnpay")
|
| 82 |
-
async def vnpay_ipn_redirect(request: Request):
|
| 83 |
-
params: Dict[str, str] = dict(request.query_params)
|
| 84 |
-
return await RedirectService.android_vnpay_ipn_redirect(params)
|
| 85 |
-
|
| 86 |
-
|
| 87 |
-
@router.get("/android/group/vnpay")
|
| 88 |
-
async def vnpay_ipn_redirect(request: Request):
|
| 89 |
-
params: Dict[str, str] = dict(request.query_params)
|
| 90 |
-
return await RedirectService.android_vnpay_group_ipn_redirect(params)
|
| 91 |
-
|
| 92 |
-
@router.get("/web/vnpay")
|
| 93 |
-
async def vnpay_ipn_redirect(request: Request):
|
| 94 |
-
query_params = request.query_params
|
| 95 |
-
return await RedirectService.web_vnpay_ipn_redirect(query_params)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
controller/__init__.py
DELETED
|
File without changes
|
controller/__pycache__/CallbackController.cpython-311.pyc
DELETED
|
Binary file (11.1 kB)
|
|
|
controller/__pycache__/ChatController.cpython-311.pyc
DELETED
|
Binary file (8.65 kB)
|
|
|
controller/__pycache__/GroupOrderController.cpython-311.pyc
DELETED
|
Binary file (2.15 kB)
|
|
|
controller/__pycache__/RecommendController.cpython-311.pyc
DELETED
|
Binary file (2.08 kB)
|
|
|
controller/__pycache__/RedirectController.cpython-311.pyc
DELETED
|
Binary file (7 kB)
|
|
|
controller/__pycache__/__init__.cpython-311.pyc
DELETED
|
Binary file (167 Bytes)
|
|
|