|
@@ -1,8 +1,13 @@
|
|
|
+from datetime import datetime
|
|
|
+from distutils.command.config import config
|
|
|
+
|
|
|
+from flask_login import current_user
|
|
|
from ..base import base
|
|
|
from ..models import Config
|
|
|
from flask import render_template, request, jsonify
|
|
|
from sqlalchemy import asc
|
|
|
from sqlalchemy import desc
|
|
|
+from .. import db
|
|
|
|
|
|
@base.route('/system/config/configKey/<configKey>', methods=['GET'])
|
|
|
def sysconfig_get_value(configKey):
|
|
@@ -32,4 +37,54 @@ def sys_config_list():
|
|
|
page, per_page=rows, error_out=False)
|
|
|
config_list = pagination.items
|
|
|
|
|
|
- return jsonify({'msg': '操作成功', 'code': 200, 'rows': [config.to_json() for config in config_list], 'total': len(config_list)})
|
|
|
+ return jsonify({'msg': '操作成功', 'code': 200, 'rows': [config.to_json() for config in config_list], 'total': pagination.total})
|
|
|
+
|
|
|
+@base.route('/system/config/<id>', methods=['GET'])
|
|
|
+def sysconfig_get_by_id(id):
|
|
|
+ config = Config.query.get(id)
|
|
|
+
|
|
|
+ return jsonify({'msg': '操作成功', 'code': 200, 'data': config.to_json()})
|
|
|
+
|
|
|
+@base.route('/system/config', methods=['POST'])
|
|
|
+def sysconfig_add():
|
|
|
+ config = Config()
|
|
|
+
|
|
|
+ if 'configKey' in request.json: config.config_key = request.json['configKey']
|
|
|
+ if 'configName' in request.json: config.config_name = request.json['configName']
|
|
|
+ if 'configType' in request.json: config.config_type = request.json['configType']
|
|
|
+ if 'configValue' in request.json: config.config_value = request.json['configValue']
|
|
|
+ if 'remark' in request.json: config.remark = request.json['remark']
|
|
|
+
|
|
|
+ config.create_time = datetime.now()
|
|
|
+ config.create_by = current_user.NAME
|
|
|
+
|
|
|
+ db.session.add(config)
|
|
|
+
|
|
|
+ return jsonify({'code': 200, 'msg': '操作成功'})
|
|
|
+
|
|
|
+@base.route('/system/config', methods=['PUT'])
|
|
|
+def sysconfig_update():
|
|
|
+ config = Config.query.get(request.json['configId'])
|
|
|
+
|
|
|
+ if 'configKey' in request.json: config.config_key = request.json['configKey']
|
|
|
+ if 'configName' in request.json: config.config_name = request.json['configName']
|
|
|
+ if 'configType' in request.json: config.config_type = request.json['configType']
|
|
|
+ if 'configValue' in request.json: config.config_value = request.json['configValue']
|
|
|
+ if 'remark' in request.json: config.remark = request.json['remark']
|
|
|
+
|
|
|
+ config.UPDATEDATETIME = datetime.now()
|
|
|
+ config.update_by = current_user.NAME
|
|
|
+
|
|
|
+ db.session.add(config)
|
|
|
+
|
|
|
+ return jsonify({'msg': '操作成功', 'code': 200})
|
|
|
+
|
|
|
+@base.route('/system/config/<string:ids>', methods=['DELETE'])
|
|
|
+def syconfig_delete(ids):
|
|
|
+ idList = ids.split(',')
|
|
|
+ for id in idList:
|
|
|
+ config = Config.query.get(id)
|
|
|
+ if config:
|
|
|
+ db.session.delete(config)
|
|
|
+
|
|
|
+ return jsonify({'code': 200, 'msg': '操作成功'})
|