悠修复自定义实收金额和求和采集功能增强
This commit is contained in:
36
lib/api/global_config_api.py
Normal file
36
lib/api/global_config_api.py
Normal file
@@ -0,0 +1,36 @@
|
||||
from flask import Blueprint, jsonify, request
|
||||
from lib.db import execute_query, execute_update
|
||||
import json
|
||||
|
||||
global_config_api = Blueprint('global_config_api', __name__)
|
||||
|
||||
|
||||
@global_config_api.route('/api/global-config/sum-data-fields', methods=['GET'])
|
||||
def get_sum_data_fields():
|
||||
"""获取求和数据采集字段配置"""
|
||||
try:
|
||||
result = execute_query("SELECT sum_data_fields FROM t_daily_report_global_config WHERE id = 1")
|
||||
if result and result[0]['sum_data_fields']:
|
||||
fields = json.loads(result[0]['sum_data_fields'])
|
||||
return jsonify({'success': True, 'data': fields})
|
||||
return jsonify({'success': True, 'data': []})
|
||||
except Exception as e:
|
||||
return jsonify({'success': False, 'message': str(e)}), 500
|
||||
|
||||
|
||||
@global_config_api.route('/api/global-config/sum-data-fields', methods=['POST'])
|
||||
def save_sum_data_fields():
|
||||
"""保存求和数据采集字段配置"""
|
||||
try:
|
||||
data = request.get_json()
|
||||
fields = data.get('sum_data_fields', [])
|
||||
fields_json = json.dumps(fields)
|
||||
|
||||
execute_update(
|
||||
"UPDATE t_daily_report_global_config SET sum_data_fields = %s, update_time = NOW() WHERE id = 1",
|
||||
(fields_json,)
|
||||
)
|
||||
|
||||
return jsonify({'success': True, 'message': '配置保存成功'})
|
||||
except Exception as e:
|
||||
return jsonify({'success': False, 'message': str(e)}), 500
|
||||
Reference in New Issue
Block a user