__init__.py
3.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
# coding=utf-8
#author: 4N
#createtime: 2020/12/8
#email: nheweijun@sina.com
from flasgger import swag_from
from flask import Blueprint
from app.util import BlueprintApi
from flask import send_from_directory
import os
from . import data_download_task
from . import get_meta
from . import data_entry_by_meta
from . import get_data_list
from . import data_entry_simple
import configure
from app.decorators.auth_decorator import auth_decorator
import os
class DataManager(BlueprintApi):
bp:Blueprint = Blueprint("DataTool", __name__, url_prefix="/API/IO")
@staticmethod
@bp.route('/Download/<dir>/<file>', methods=['GET'])
@auth_decorator(configure.DataPermission)
def table_download_file(dir,file):
parent = os.path.dirname(os.path.dirname(os.path.realpath(__file__)))
dirpath = os.path.join(parent,"file_tmp",dir)
return send_from_directory(dirpath, filename=file, as_attachment=True)
# dirpath = os.path.join(parent, "file_tmp")
# return send_from_directory(dirpath, filename=file, as_attachment=True)
@staticmethod
@bp.route('/DeleteFile/<file>', methods=['GET'])
@auth_decorator(configure.DataPermission)
def d_file(file):
parent = os.path.dirname(os.path.dirname(os.path.realpath(__file__)))
dirpath = os.path.join(parent, "file_tmp")
result={}
try:
os.remove(os.path.join(dirpath, file))
# shutil.rmtree(dirpath)
result["message"]="删除文件成功!"
except Exception as e:
print(e)
result["message"] ="删除文件失败!"
return result
@staticmethod
@bp.route('/DataDownloadTask', methods=['POST'])
@swag_from(data_download_task.Api.api_doc)
@auth_decorator(configure.DataPermission)
def api_data_download_task():
"""
下载数据任务
"""
return data_download_task.Api().result
@staticmethod
@bp.route('/GetMeta', methods=['POST'])
@swag_from(get_meta.Api.api_doc)
# @auth_decorator(configure.DataPermission)
def get_meta():
"""
数据Meta
"""
return get_meta.Api().result
@staticmethod
@bp.route('/GetDataList', methods=['POST'])
@swag_from(get_data_list.Api.api_doc)
@auth_decorator(configure.DataPermission)
def get_data_list():
"""
本地数据list
"""
return get_data_list.Api().result
@staticmethod
@bp.route('/DataEntryByMeta', methods=['POST'])
@swag_from(data_entry_by_meta.Api.api_doc)
@auth_decorator(configure.DataPermission)
def data_entry_by_meta():
"""
数据入库ByMeta
"""
return data_entry_by_meta.Api().result
@staticmethod
@bp.route('/DataEntrySimple', methods=['POST'])
@swag_from(data_entry_simple.Api.api_doc)
@auth_decorator(configure.DataPermission)
def data_entry_simple():
"""
数据入库Simple
"""
return data_entry_simple.Api().result