__init__.py 3.0 KB
# 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 app.modules.data.models import Task
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
from . import data_download
import configure
from flask import abort
from  app.decorators.auth_decorator import  auth_decorator
import os
from app.util.component.ParameterUtil import ParameterUtil
from app.modules.auth.models import OAuth2Token,User,db
import configure

class DataManager(BlueprintApi):

    bp:Blueprint = Blueprint("DataTool", __name__, url_prefix="/API/IO")


    @staticmethod
    @bp.route('/Download/<dir>/<file>', methods=['GET'])
    @swag_from(data_download.Api.api_doc)
    def data_download(dir,file):
        api = data_download.Api(dir,file)
        return api.result



    @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