|
@@ -1,8 +1,12 @@
|
|
|
+from datetime import datetime
|
|
|
+
|
|
|
+from flask_login import current_user
|
|
|
from ..base import base
|
|
|
from ..models import DictData, DictType
|
|
|
from flask import render_template, request, jsonify
|
|
|
from sqlalchemy import asc
|
|
|
from sqlalchemy import desc
|
|
|
+from .. import db
|
|
|
|
|
|
@base.route('/system/dict/type/list', methods=['GET'])
|
|
|
def sysdict_type_list():
|
|
@@ -26,14 +30,56 @@ def sysdict_type_list():
|
|
|
page, per_page=rows, error_out=False)
|
|
|
types = pagination.items
|
|
|
|
|
|
- return jsonify({'msg': '操作成功', 'code': 200, 'rows': [type.to_json() for type in types], 'total': len(types)})
|
|
|
+ return jsonify({'msg': '操作成功', 'code': 200, 'rows': [type.to_json() for type in types], 'total': pagination.total})
|
|
|
|
|
|
@base.route('/system/dict/type/<id>', methods=['GET'])
|
|
|
def sysdict_type_get_by_id(id):
|
|
|
- type = DictData.query.get(id)
|
|
|
+ type = DictType.query.get(id)
|
|
|
|
|
|
return jsonify({'msg': '操作成功', 'code': 200, 'data': type.to_json()})
|
|
|
|
|
|
+@base.route('/system/dict/type', methods=['POST'])
|
|
|
+def sysdict_type_add():
|
|
|
+ dictType = DictType()
|
|
|
+
|
|
|
+ if 'dictName' in request.json: dictType.dict_name = request.json['dictName']
|
|
|
+ if 'status' in request.json: dictType.status = request.json['status']
|
|
|
+ if 'remark' in request.json: dictType.remark = request.json['remark']
|
|
|
+ if 'dictType' in request.json: dictType.dict_type = request.json['dictType']
|
|
|
+
|
|
|
+ dictType.create_time = datetime.now()
|
|
|
+ dictType.create_by = current_user.NAME
|
|
|
+ dictType.update_time = datetime.now()
|
|
|
+ dictType.update_by = current_user.NAME
|
|
|
+
|
|
|
+ db.session.add(dictType)
|
|
|
+
|
|
|
+ return jsonify({'code': 200, 'msg': '操作成功'})
|
|
|
+
|
|
|
+@base.route('/system/dict/type', methods=['PUT'])
|
|
|
+def sysdict_type_update():
|
|
|
+ dictType = DictType.query.get(request.json['dictId'])
|
|
|
+
|
|
|
+ if 'dictName' in request.json: dictType.dict_name = request.json['dictName']
|
|
|
+ if 'status' in request.json: dictType.status = request.json['status']
|
|
|
+ if 'remark' in request.json: dictType.remark = request.json['remark']
|
|
|
+ if 'dictType' in request.json: dictType.dict_type = request.json['dictType']
|
|
|
+
|
|
|
+ dictType.UPDATEDATETIME = datetime.now()
|
|
|
+ dictType.update_by = current_user.NAME
|
|
|
+
|
|
|
+ return jsonify({'msg': '操作成功', 'code': 200})
|
|
|
+
|
|
|
+@base.route('/system/dict/type/<string:ids>', methods=['DELETE'])
|
|
|
+def sytype_delete(ids):
|
|
|
+ idList = ids.split(',')
|
|
|
+ for id in idList:
|
|
|
+ dictType = DictType.query.get(id)
|
|
|
+ if dictType:
|
|
|
+ db.session.delete(dictType)
|
|
|
+
|
|
|
+ return jsonify({'code': 200, 'msg': '操作成功'})
|
|
|
+
|
|
|
@base.route('/system/dict/type/optionselect', methods=['GET'])
|
|
|
def sysdict_type_all():
|
|
|
types = DictData.query.all()
|