"""
数据库初始化 API
"""
from flask import jsonify
from lib.db_init import init_database_tables
from . import init_bp


@init_bp.route('/init-tables', methods=['POST'])
def init_tables():
    """初始化数据库表"""
    try:
        success = init_database_tables()
        if success:
            return jsonify({'success': True, 'message': '数据库表初始化成功'})
        else:
            return jsonify({'success': False, 'message': '数据库表初始化失败'}), 500
    except Exception as e:
        return jsonify({'success': False, 'message': str(e)}), 500
