Files
baiyue-logistics-chat/logistics_chat/routes/admin.py
T

45 lines
1.2 KiB
Python

"""HTTP adapters for admin; business logic lives in services."""
from flask import Blueprint, Response, render_template, request
from .. import business_service
bp = Blueprint('admin', __name__)
@bp.route('/api/admin/stats')
def admin_stats():
return business_service.admin_stats()
@bp.route('/admin/login', methods=['POST'])
def admin_login():
return business_service.admin_login(request.json or {})
@bp.route('/api/export_chat')
def export_chat():
format = 'csv' if request.args.get('format') == 'csv' else 'xlsx'
mimetype = 'text/csv' if format == 'csv' else 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'
return Response(business_service.export_chat(format), mimetype=mimetype,
headers={'Content-Disposition': 'attachment;filename=chat_export.' + format})
@bp.route('/api/agents/list')
def agents_list():
return business_service.agents_list()
@bp.route('/api/search_chat')
def search_chat():
return business_service.search_chat(request.args.get('q', '').strip())
@bp.route('/admin')
def admin():
return render_template('admin_login.html')
@bp.route('/admin/dashboard')
def admin_dash():
return render_template('admin.html')