account bar

This commit is contained in:
CHIEFSOFT\ameye
2025-06-24 11:52:41 -04:00
parent 5ce0c72eaa
commit ce752fe04a
7 changed files with 203 additions and 88 deletions
+73 -74
View File
@@ -45,7 +45,6 @@ def serve_paths(filename):
swagger_dir = os.path.join("swagger") swagger_dir = os.path.join("swagger")
return send_from_directory(swagger_dir, filename) return send_from_directory(swagger_dir, filename)
# EligibilityCheck Endpoint
@api.route("/panel/Login", methods=["POST"]) @api.route("/panel/Login", methods=["POST"])
@jwt_required() @jwt_required()
def merms_login(): def merms_login():
@@ -74,7 +73,7 @@ def merms_register_complete():
response = RegisterService.process_request(data) response = RegisterService.process_request(data)
return response return response
@api.route("/panel/Account", methods=["POST"]) @api.route("/panel/account", methods=["POST"])
@jwt_required() @jwt_required()
def merms_account(): def merms_account():
data = request.get_json() data = request.get_json()
@@ -88,21 +87,21 @@ def merms_account_bar():
response = AccountService.process_bar_request(data) response = AccountService.process_bar_request(data)
return response return response
@api.route("/panel/Account/actions", methods=["POST"]) @api.route("/panel/account-actions", methods=["POST"])
@jwt_required() @jwt_required()
def merms_account_actions(): def merms_account_actions():
data = request.get_json() data = request.get_json()
response = AccountService.process_request(data) response = AccountService.process_request(data)
return response return response
@api.route("/panel/Account/products/url", methods=["POST"]) @api.route("/panel/account-productsurl", methods=["POST"])
@jwt_required() @jwt_required()
def merms_account_product_url(): def merms_account_product_url():
data = request.get_json() data = request.get_json()
response = AccountService.process_request(data) response = ProductsService.process_request(data)
return response return response
@api.route("/panel/Products", methods=["POST"]) @api.route("/panel/products", methods=["POST"])
@jwt_required() @jwt_required()
def merms_products(): def merms_products():
data = request.get_json() data = request.get_json()
@@ -110,75 +109,75 @@ def merms_products():
return response return response
# EligibilityCheck Endpoint # # EligibilityCheck Endpoint
@api.route("/EligibilityCheck", methods=["POST"]) # @api.route("/EligibilityCheck", methods=["POST"])
@jwt_required() # @jwt_required()
def eligibility_check(): # def eligibility_check():
data = request.get_json() # data = request.get_json()
# logger.info(f"EligibilityCheck request received: {data}") # # logger.info(f"EligibilityCheck request received: {data}")
response = EligibilityCheckService.process_request(data) # response = EligibilityCheckService.process_request(data)
return response # return response
#
# # SelectOffer Endpoint
# SelectOffer Endpoint # @api.route("/SelectOffer", methods=["POST"])
@api.route("/SelectOffer", methods=["POST"]) # @jwt_required()
@jwt_required() # def select_offer():
def select_offer(): # data = request.get_json()
data = request.get_json() # # logger.info(f"SelectOffer request received: {data}")
# logger.info(f"SelectOffer request received: {data}") # response = SelectOfferService.process_request(data)
response = SelectOfferService.process_request(data) # return response
return response #
#
# # ProvideLoan Endpoint
# ProvideLoan Endpoint # @api.route("/ProvideLoan", methods=["POST"])
@api.route("/ProvideLoan", methods=["POST"]) # @jwt_required()
@jwt_required() # def provide_loan():
def provide_loan(): # data = request.get_json()
data = request.get_json() # # logger.info(f"ProvideLoan request received: {data}")
# logger.info(f"ProvideLoan request received: {data}") # response = ProvideLoanService.process_request(data)
response = ProvideLoanService.process_request(data) # return response
return response #
#
# # LoanStatus Endpoint
# LoanStatus Endpoint # @api.route("/LoanStatus", methods=["POST"])
@api.route("/LoanStatus", methods=["POST"]) # @jwt_required()
@jwt_required() # def loan_status():
def loan_status(): # data = request.get_json()
data = request.get_json() # # logger.info(f"LoanStatus request received: {data}")
# logger.info(f"LoanStatus request received: {data}") # response = LoanStatusService.process_request(data)
response = LoanStatusService.process_request(data) # return response
return response #
#
# # Repayment Endpoint
# Repayment Endpoint # @api.route("/Repayment", methods=["POST"])
@api.route("/Repayment", methods=["POST"]) # @jwt_required()
@jwt_required() # def repayment():
def repayment(): # data = request.get_json()
data = request.get_json() # logger.error(f"HERE 0000a **** ")
logger.error(f"HERE 0000a **** ") # # logger.info(f"Repayment request received: {data}")
# logger.info(f"Repayment request received: {data}") # response = RepaymentService.process_request(data)
response = RepaymentService.process_request(data) # return response
return response #
#
# # CustomerConsent Endpoint
# CustomerConsent Endpoint # @api.route("/CustomerConsent", methods=["POST"])
@api.route("/CustomerConsent", methods=["POST"]) # @jwt_required()
@jwt_required() # def customer_consent():
def customer_consent(): # data = request.get_json()
data = request.get_json() # # logger.info(f"CustomerConsent request received: {data}")
# logger.info(f"CustomerConsent request received: {data}") # response = CustomerConsentService.process_request(data)
response = CustomerConsentService.process_request(data) # return response
return response #
#
# # NotificationCallback Endpoint
# NotificationCallback Endpoint # @api.route("/NotificationCallback", methods=["POST"])
@api.route("/NotificationCallback", methods=["POST"]) # @jwt_required()
@jwt_required() # def notification_callback():
def notification_callback(): # data = request.get_json()
data = request.get_json() # # logger.info(f"NotificationCallback request received: {data}")
# logger.info(f"NotificationCallback request received: {data}") # response = NotificationCallbackService.process_request(data)
response = NotificationCallbackService.process_request(data) # return response
return response
# Health Check Endpoint # Health Check Endpoint
+3 -1
View File
@@ -12,6 +12,7 @@ from flask_jwt_extended import (
get_jwt_identity, get_jwt_identity,
) )
from app.config import Config from app.config import Config
from datetime import timedelta
USERNAME = Config.BASIC_AUTH_USERNAME USERNAME = Config.BASIC_AUTH_USERNAME
PASSWORD = Config.BASIC_AUTH_PASSWORD PASSWORD = Config.BASIC_AUTH_PASSWORD
@@ -46,7 +47,8 @@ class AuthorizationService(BaseService):
): ):
return ResponseHelper.unauthorized(result_description="Invalid credentials") return ResponseHelper.unauthorized(result_description="Invalid credentials")
access_token = create_access_token(identity=validated_data["username"]) expires = timedelta(days=3)
access_token = create_access_token(identity=validated_data["username"], expires_delta=expires)
refresh_token = create_refresh_token(identity=validated_data["username"]) refresh_token = create_refresh_token(identity=validated_data["username"])
# Simulated processing logic # Simulated processing logic
+17 -12
View File
@@ -13,6 +13,7 @@ from app.api.helpers.response_helper import ResponseHelper
from werkzeug.security import generate_password_hash, check_password_hash from werkzeug.security import generate_password_hash, check_password_hash
from app.api.schemas.register import RegisterSchema from app.api.schemas.register import RegisterSchema
from app.api.schemas.products import ProductsSchema from app.api.schemas.products import ProductsSchema
from app.api.schemas.user import UserSchema
import datetime import datetime
import jwt import jwt
@@ -35,25 +36,29 @@ class ProductsService(BaseService):
""" """
try: try:
user_id = 1 # current_user["user"]["id"]
PRODUCT_LIST = f"""SELECT p.id,p.uid,p.product_id,p.name,p.description,p.status,p.banner,
mp.status AS prov_status,
(CASE WHEN mp.status =6 THEN 'Preparing' WHEN mp.status=7 THEN 'Active' ELSE 'Activate Now' END) AS status_text
FROM products p
LEFT JOIN members_products mp ON mp.product_id = p.product_id
AND mp.member_id ={user_id}
ORDER BY p.id ASC"""
print(PRODUCT_LIST)
with db.session.begin(): with db.session.begin():
validated_data = ProductsService.validate_data(data, ProductsSchema()) validated_data = ProductsService.validate_data(data, UserSchema())
# username = validated_data.get('username') token = validated_data.get('token')
# password = validated_data.get('password') uid = validated_data.get('uid')
user_id = 1 # current_user["user"]["id"]
PRODUCT_LIST = f"""SELECT p.id,p.uid,p.product_id,p.name,p.description,p.status,p.banner,
mp.status AS prov_status,
(CASE WHEN mp.status =6 THEN 'Preparing' WHEN mp.status=7 THEN 'Active' ELSE 'Activate Now' END) AS status_text
FROM products p
LEFT JOIN members_products mp ON mp.product_id = p.product_id
AND mp.member_id ={user_id}
ORDER BY p.id ASC"""
print(PRODUCT_LIST)
data = db.engine.execute(PRODUCT_LIST)
# Simulate processing # Simulate processing
response_data = { response_data = {
"data": data.fetchall(),
"member_id": 0, "member_id": 0,
"uid": 0, "uid": 0,
} }
+3
View File
@@ -85,6 +85,9 @@
"/panel/Account": { "/panel/Account": {
"$ref": "swagger/paths/Account.json" "$ref": "swagger/paths/Account.json"
}, },
"/panel/account-bar": {
"$ref": "swagger/paths/AccountBar.json"
},
"/panel/Products": { "/panel/Products": {
"$ref": "swagger/paths/Products.json" "$ref": "swagger/paths/Products.json"
} }
+57
View File
@@ -0,0 +1,57 @@
{
"post": {
"tags": [
"AccountBar"
],
"summary": "User Account Bar ",
"description": "User Bar Request",
"operationId": "accountbar",
"requestBody": {
"description": "Post JSON to conduct login request",
"content": {
"application/json": {
"schema": {
"$ref": "../schemas/UserRequest.json"
}
},
"application/xml": {
"schema": {
"$ref": "../schemas/UserRequest.json"
}
},
"application/x-www-form-urlencoded": {
"schema": {
"$ref": "../schemas/UserRequest.json"
}
}
},
"required": true
},
"responses": {
"200": {
"description": "Successful operation",
"content": {
"application/json": {
"schema": {
"$ref": "../schemas/AccountBarResponse.json"
}
},
"application/xml": {
"schema": {
"$ref": "../schemas/AccountBarResponse.json"
}
}
}
},
"400": {
"description": "Invalid request"
},
"422": {
"description": "Validation exception"
},
"500": {
"description": "Internal server error"
}
}
}
}
@@ -0,0 +1,49 @@
{
"type": "object",
"properties": {
"member_id": {
"type": "string",
"example": "200"
},
"uid": {
"type": "string",
"example": "8888-999998-9999"
},
"username": {
"type": "string",
"example": "username"
},
"account_name": {
"type": "string",
"example": "account_name"
},
"firstname": {
"type": "string",
"example": "firstname"
},
"lastname": {
"type": "string",
"example": "lastname"
},
"room": {
"type": "string",
"example": "room"
},
"token": {
"type": "string",
"example": "username"
},
"resultDescription": {
"type": "string",
"example": "Successful"
},
"resultCode": {
"type": "string",
"example": "00"
}
},
"xml": {
"name": "AccountResponse"
}
}
+1 -1
View File
@@ -5,7 +5,7 @@ services:
env_file: env_file:
- .env - .env
ports: ports:
- "${APP_PORT:-14703}:5000" - "${APP_PORT:-14700}:5000"
environment: environment:
- FLASK_APP=${FLASK_APP} - FLASK_APP=${FLASK_APP}
- FLASK_ENV=${FLASK_ENV} - FLASK_ENV=${FLASK_ENV}